Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: scenes forward #505

Merged
merged 2 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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