Skip to content

Commit

Permalink
fix: don't save profiles in s3 bucket (#500)
Browse files Browse the repository at this point in the history
* fix: don't save profiles in s3 bucket

* chore: remote prettier

* style: linter

* refactor: deployEntity

---------

Co-authored-by: Braian Mellor <[email protected]>
  • Loading branch information
subzet and braianj authored Sep 18, 2024
1 parent b6b169e commit b74afff
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 40 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"
}
}
}
78 changes: 39 additions & 39 deletions src/adapters/deployer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,38 +25,37 @@ export function createDeployerComponent(

const isSnsEventToSend = !!components.sns.eventArn

if (exists || !(isSnsEntityToSend && isSnsEventToSend)) {
if (exists) {
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(',')
})
const deploymentToSqs: DeploymentToSqs = {
entity,
contentServerUrls: servers
}

await downloadEntityAndContentFiles(
{ ...components, fetcher: components.fetch },
entity.entityId,
servers,
new Map(),
'content',
10,
1000
)
if (isSnsEntityToSend) {
await components.downloadQueue.onSizeLessThan(1000)

logger.info('Entity stored', { entityId: entity.entityId, entityType: entity.entityType })
void components.downloadQueue.scheduleJob(async () => {
logger.info('Downloading entity', {
entityId: entity.entityId,
entityType: entity.entityType,
servers: servers.join(',')
})

const deploymentToSqs: DeploymentToSqs = {
entity,
contentServerUrls: servers
}
await downloadEntityAndContentFiles(
{ ...components, fetcher: components.fetch },
entity.entityId,
servers,
new Map(),
'content',
10,
1000
)

// send sns
if (isSnsEntityToSend) {
logger.info('Entity stored', { entityId: entity.entityId, entityType: entity.entityType })
// send sns
const receipt = await client.send(
new PublishCommand({
TopicArn: components.sns.arn,
Expand All @@ -67,22 +66,23 @@ 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)
})
)
logger.info('Notification sent to events SNS', {
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)
})
}
await markAsDeployed()
})
)
logger.info('Notification sent to events SNS', {
MessageId: receipt.MessageId as any,
SequenceNumber: receipt.SequenceNumber as any
})
}

await markAsDeployed()
} catch (error: any) {
const isNotRetryable = /status: 4\d{2}/.test(error.message)
if (isNotRetryable) {
Expand Down

0 comments on commit b74afff

Please sign in to comment.