Skip to content

Commit

Permalink
fix: forward of events with unchanged content
Browse files Browse the repository at this point in the history
  • Loading branch information
aleortega committed Oct 28, 2024
1 parent 71dde43 commit e9653b6
Showing 1 changed file with 22 additions and 23 deletions.
45 changes: 22 additions & 23 deletions src/adapters/deployer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,39 +25,36 @@ export function createDeployerComponent(

const isSnsEventToSend = !!components.sns.eventArn

if (exists || !(isSnsEntityToSend && isSnsEventToSend)) {
logger.info('Entity already stored', { entityId: entity.entityId, entityType: entity.entityType })
return await markAsDeployed()
}

await components.downloadQueue.onSizeLessThan(1000)

void components.downloadQueue.scheduleJob(async () => {
logger.info('Downloading entity', {
entityId: entity.entityId,
entityType: entity.entityType,
servers: servers.join(',')
})
if (!exists) {
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 })
logger.info('Entity stored', { entityId: entity.entityId, entityType: entity.entityType })
}

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

// send sns
if (isSnsEntityToSend) {
if (isSnsEntityToSend && !exists) {
const receipt = await client.send(
new PublishCommand({
TopicArn: components.sns.arn,
Expand All @@ -66,7 +63,8 @@ export function createDeployerComponent(
)
logger.info('Notification sent', {
messageId: receipt.MessageId as any,
sequenceNumber: receipt.SequenceNumber as any
sequenceNumber: receipt.SequenceNumber as any,
entityId: entity.entityId
})
}

Expand All @@ -79,7 +77,8 @@ export function createDeployerComponent(
)
logger.info('Notification sent to events SNS', {
MessageId: receipt.MessageId as any,
SequenceNumber: receipt.SequenceNumber as any
SequenceNumber: receipt.SequenceNumber as any,
entityId: entity.entityId
})
}
await markAsDeployed()
Expand Down

0 comments on commit e9653b6

Please sign in to comment.