Skip to content

Commit

Permalink
fix: scenes forward (#505)
Browse files Browse the repository at this point in the history
* fix: scenes forward

* Revert "fix: don't save profiles in s3 bucket (#500)"

This reverts commit b74afff.
  • Loading branch information
aleortega authored Oct 11, 2024
1 parent 0e20c50 commit ac66739
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 41 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@
"@well-known-components/logger": "^3.1.2",
"@well-known-components/metrics": "^2.0.1"
}
}
}
86 changes: 46 additions & 40 deletions src/adapters/deployer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,37 +25,38 @@ export function createDeployerComponent(

const isSnsEventToSend = !!components.sns.eventArn

if (exists) {
if (exists || !(isSnsEntityToSend && isSnsEventToSend)) {
return await markAsDeployed()
}

const deploymentToSqs: DeploymentToSqs = {
entity,
contentServerUrls: servers
}
await components.downloadQueue.onSizeLessThan(1000)

if (isSnsEntityToSend) {
await components.downloadQueue.onSizeLessThan(1000)
void components.downloadQueue.scheduleJob(async () => {
logger.info('Downloading entity', {
entityId: entity.entityId,
entityType: entity.entityType,
servers: servers.join(',')
})

void components.downloadQueue.scheduleJob(async () => {
logger.info('Downloading entity', {
entityId: entity.entityId,
entityType: entity.entityType,
servers: servers.join(',')
})
await downloadEntityAndContentFiles(
{ ...components, fetcher: components.fetch },
entity.entityId,
servers,
new Map(),
'content',
10,
1000
)

await downloadEntityAndContentFiles(
{ ...components, fetcher: components.fetch },
entity.entityId,
servers,
new Map(),
'content',
10,
1000
)
logger.info('Entity stored', { entityId: entity.entityId, entityType: entity.entityType })

const deploymentToSqs: DeploymentToSqs = {
entity,
contentServerUrls: servers
}

logger.info('Entity stored', { entityId: entity.entityId, entityType: entity.entityType })
// send sns
// send sns
if (isSnsEntityToSend) {
const receipt = await client.send(
new PublishCommand({
TopicArn: components.sns.arn,
Expand All @@ -66,26 +67,31 @@ export function createDeployerComponent(
messageId: receipt.MessageId as any,
sequenceNumber: receipt.SequenceNumber as any
})
})
}
}

if (isSnsEventToSend) {
const receipt = await client.send(
new PublishCommand({
TopicArn: components.sns.eventArn,
Message: JSON.stringify(deploymentToSqs)
if (isSnsEventToSend) {
const receipt = await client.send(
new PublishCommand({
TopicArn: components.sns.eventArn,
Message: JSON.stringify(deploymentToSqs)
})
)
logger.info('Notification sent to events SNS', {
MessageId: receipt.MessageId as any,
SequenceNumber: receipt.SequenceNumber as any
})
)
logger.info('Notification sent to events SNS', {
messageId: receipt.MessageId as any,
sequenceNumber: receipt.SequenceNumber as any,
entityId: deploymentToSqs.entity.entityId
})
}

await markAsDeployed()
}
await markAsDeployed()
})
} catch (error: any) {
const isNotRetryable = /status: 4\d{2}/.test(error.message)
logger.error('Failed to publish entity', {
entityId: entity.entityId,
entityType: entity.entityType,
error: error?.message,
stack: error?.stack
})

if (isNotRetryable) {
logger.error('Failed to download entity', {
entityId: entity.entityId,
Expand Down

0 comments on commit ac66739

Please sign in to comment.