diff --git a/src/config/config.ts b/src/config/config.ts index 47768609f..11aa6aa00 100644 --- a/src/config/config.ts +++ b/src/config/config.ts @@ -201,6 +201,12 @@ const config = convict({ format: "required-string", default: "", }, + areQueuesDeprecated: { + doc: "Whether the queues are deprecated", + env: "ARE_QUEUES_DEPRECATED", + format: "required-boolean", + default: false, + }, }, }, github: { diff --git a/src/services/infra/DynamoDBService.ts b/src/services/infra/DynamoDBService.ts index fbc6babfa..6166d51f0 100644 --- a/src/services/infra/DynamoDBService.ts +++ b/src/services/infra/DynamoDBService.ts @@ -22,7 +22,7 @@ export default class DynamoDBService { await this.dynamoDBClient.createItem(this.TABLE_NAME, message) } - async getAllSuccessOrFailureLaunches(): Promise { + async getAllCompletedLaunches(): Promise { const entries = ((await this.dynamoDBClient.getAllItems(this.TABLE_NAME)) .Items as unknown) as SiteLaunchMessage[] diff --git a/src/services/infra/InfraService.ts b/src/services/infra/InfraService.ts index 5444eb025..f05d8defd 100644 --- a/src/services/infra/InfraService.ts +++ b/src/services/infra/InfraService.ts @@ -54,7 +54,7 @@ type CreateSiteParams = { isEmailLogin: boolean } -const ARE_QUEUES_DEPRECIATED = false +const ARE_QUEUES_DEPRECATED = config.get("aws.sqs.areQueuesDeprecated") export default class InfraService { private readonly sitesService: InfraServiceProps["sitesService"] @@ -384,7 +384,7 @@ export default class InfraService { message.redirectionDomain = [redirectionDomainObject] } - if (ARE_QUEUES_DEPRECIATED) { + if (ARE_QUEUES_DEPRECATED) { this.dynamoDBService.createItem(message) this.stepFunctionsService.triggerFlow(message) } else { @@ -402,8 +402,8 @@ export default class InfraService { } siteUpdate = async () => { - const messages = ARE_QUEUES_DEPRECIATED - ? await this.dynamoDBService.getAllSuccessOrFailureLaunches() + const messages = ARE_QUEUES_DEPRECATED + ? await this.dynamoDBService.getAllCompletedLaunches() : await this.queueService.pollMessages() await Promise.all( messages.map(async (message) => { diff --git a/src/services/infra/__tests__/DynamoDBService.spec.ts b/src/services/infra/__tests__/DynamoDBService.spec.ts index 90aaec54d..59ea946d8 100644 --- a/src/services/infra/__tests__/DynamoDBService.spec.ts +++ b/src/services/infra/__tests__/DynamoDBService.spec.ts @@ -76,7 +76,7 @@ describe("DynamoDBService", () => { Items: [mockSuccessLaunch, mockLaunch, mockFailureLaunch], } mockDynamoDBClient.getAllItems.mockReturnValueOnce(scanCommandOutput) - const result: SiteLaunchMessage[] = await dynamoDBService.getAllSuccessOrFailureLaunches() + const result: SiteLaunchMessage[] = await dynamoDBService.getAllCompletedLaunches() expect(dynamoDBClient.getAllItems).toHaveBeenCalledWith(tableName) expect(spyDynamoDBService.deleteItem).toHaveBeenCalledWith( mockSuccessLaunch