From 763e528e053926ebe1d1d3d8864bdda44dd3cd63 Mon Sep 17 00:00:00 2001 From: Alejo Thomas Ortega Date: Wed, 4 Dec 2024 20:04:29 -0300 Subject: [PATCH] feat: publish AssetBundleConverted event --- consumer-server/.env.default | 3 +++ consumer-server/package.json | 2 +- consumer-server/src/adapters/sns.ts | 38 ++++++++++++++--------------- consumer-server/src/service.ts | 12 ++++++--- consumer-server/src/types.ts | 4 +-- consumer-server/yarn.lock | 16 +++--------- 6 files changed, 37 insertions(+), 38 deletions(-) diff --git a/consumer-server/.env.default b/consumer-server/.env.default index f63f91e..4a15556 100644 --- a/consumer-server/.env.default +++ b/consumer-server/.env.default @@ -13,5 +13,8 @@ HTTP_SERVER_HOST=0.0.0.0 # reset metrics at 00:00UTC WKC_METRICS_RESET_AT_NIGHT=false + ENV=prd SENTRY_DSN= + +AWS_SNS_ARN=any diff --git a/consumer-server/package.json b/consumer-server/package.json index 12ff672..7ace4fb 100644 --- a/consumer-server/package.json +++ b/consumer-server/package.json @@ -17,7 +17,7 @@ "dependencies": { "@aws-sdk/client-sns": "^3.699.0", "@dcl/cdn-uploader": "^1.4.1-20230208155013.commit-f75a6ee", - "@dcl/schemas": "https://sdk-team-cdn.decentraland.org/@dcl/schemas/branch/feat/asset-bundle-events/dcl-schemas-15.1.3-12164880486.commit-e79c069.tgz", + "@dcl/schemas": "^15.2.0", "@sentry/node": "^8.27.0", "@well-known-components/env-config-provider": "^1.2.0", "@well-known-components/http-server": "^2.1.0", diff --git a/consumer-server/src/adapters/sns.ts b/consumer-server/src/adapters/sns.ts index d1889db..7993c7c 100644 --- a/consumer-server/src/adapters/sns.ts +++ b/consumer-server/src/adapters/sns.ts @@ -1,34 +1,32 @@ import { PublishCommand, SNSClient } from '@aws-sdk/client-sns' import { AppComponents, PublisherComponent } from '../types' -export async function createSnsComponent({ - config, -}: Pick): Promise { +export async function createSnsComponent({ config }: Pick): Promise { const snsArn = await config.requireString('AWS_SNS_ARN') const optionalEndpoint = await config.getString('AWS_SNS_ENDPOINT') const client = new SNSClient({ - endpoint: optionalEndpoint ? optionalEndpoint : undefined, + endpoint: optionalEndpoint ? optionalEndpoint : undefined }) - async function publishMessage(event: any): Promise { - const command = new PublishCommand({ - TopicArn: snsArn, - Message: JSON.stringify(event), - MessageAttributes: { - type: { - DataType: 'String', - StringValue: event.type, - }, - subType: { - DataType: 'String', - StringValue: event.subType, - }, + async function publishMessage(event: any, attributes: { type: string; subType: string }): Promise { + const command = new PublishCommand({ + TopicArn: snsArn, + Message: JSON.stringify(event), + MessageAttributes: { + type: { + DataType: 'String', + StringValue: attributes.type }, - }) + subType: { + DataType: 'String', + StringValue: attributes.subType + } + } + }) - await client.send(command) + await client.send(command) } return { publishMessage } -} \ No newline at end of file +} diff --git a/consumer-server/src/service.ts b/consumer-server/src/service.ts index 88eceda..f1f25fc 100644 --- a/consumer-server/src/service.ts +++ b/consumer-server/src/service.ts @@ -27,7 +27,10 @@ export async function main(program: Lifecycle.EntryPointParameters { - const platform = (await components.config.requireString('PLATFORM')).toLocaleLowerCase() + const platform = (await components.config.requireString('PLATFORM')).toLocaleLowerCase() as + | 'windows' + | 'mac' + | 'webgl' while (opt.isRunning) { if (await machineRanOutOfSpace(components)) { logger.warn('Stopping program due to lack of disk space') @@ -56,12 +59,15 @@ export async function main(program: Lifecycle.EntryPointParameters = IHttpServerComponent.PathAwareContext export type PublisherComponent = { - publishMessage(event: any): Promise -} \ No newline at end of file + publishMessage(event: any, attributes: { type: string; subType: string }): Promise +} diff --git a/consumer-server/yarn.lock b/consumer-server/yarn.lock index 8724824..b3be314 100644 --- a/consumer-server/yarn.lock +++ b/consumer-server/yarn.lock @@ -751,18 +751,10 @@ eslint-plugin-prettier "^5.1.3" prettier "^3.3.2" -"@dcl/schemas@https://sdk-team-cdn.decentraland.org/@dcl/schemas/branch/feat/asset-bundle-events/dcl-schemas-15.1.2-11920921023.commit-b42e8e5.tgz": - version "15.1.2-11920921023.commit-b42e8e5" - resolved "https://sdk-team-cdn.decentraland.org/@dcl/schemas/branch/feat/asset-bundle-events/dcl-schemas-15.1.2-11920921023.commit-b42e8e5.tgz#5d536bbee83ffd8bc4170d812958f541a5bbd24e" - dependencies: - ajv "^8.11.0" - ajv-errors "^3.0.0" - ajv-keywords "^5.1.0" - mitt "^3.0.1" - -"@dcl/schemas@https://sdk-team-cdn.decentraland.org/@dcl/schemas/branch/feat/asset-bundle-events/dcl-schemas-15.1.3-12164880486.commit-e79c069.tgz": - version "15.1.3-12164880486.commit-e79c069" - resolved "https://sdk-team-cdn.decentraland.org/@dcl/schemas/branch/feat/asset-bundle-events/dcl-schemas-15.1.3-12164880486.commit-e79c069.tgz#5694c4efab8f91b46661a1c9d483c52422410825" +"@dcl/schemas@^15.2.0": + version "15.2.0" + resolved "https://registry.yarnpkg.com/@dcl/schemas/-/schemas-15.2.0.tgz#9463426cc939a45e4e8dd94dc9f99b95dfc27976" + integrity sha512-sF7PWZ6Cexf9qXssY7Kt4L5qI1l/87ei4jSEMcGE4AKyI6tCgtAMr2OwHslnKp5D4zT1UliDAt239gk/+/fk7A== dependencies: ajv "^8.11.0" ajv-errors "^3.0.0"