From e07612fe24bb6241b5dce104a138a21474807ff1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karol=20S=C3=B3jko?= Date: Mon, 6 Feb 2023 11:31:47 +0100 Subject: [PATCH] remove redis events channels --- docker/docker-entrypoint.sh | 10 -- packages/analytics/.env.sample | 1 - packages/analytics/src/Bootstrap/Container.ts | 97 +++++--------- packages/analytics/src/Bootstrap/Types.ts | 1 - packages/api-gateway/.env.sample | 1 - .../api-gateway/src/Bootstrap/Container.ts | 1 - packages/api-gateway/src/Bootstrap/Types.ts | 1 - packages/auth/.env.sample | 2 - packages/auth/src/Bootstrap/Container.ts | 121 +++++++----------- packages/auth/src/Bootstrap/Types.ts | 1 - packages/files/.env.sample | 1 - packages/files/src/Bootstrap/Container.ts | 69 +++------- packages/files/src/Bootstrap/Types.ts | 1 - packages/revisions/.env.sample | 2 - packages/revisions/src/Bootstrap/Container.ts | 52 +++----- packages/revisions/src/Bootstrap/Types.ts | 1 - packages/scheduler/.env.sample | 1 - packages/scheduler/src/Bootstrap/Container.ts | 69 +++------- packages/scheduler/src/Bootstrap/Types.ts | 1 - packages/syncing-server/.env.sample | 2 - .../syncing-server/src/Bootstrap/Container.ts | 69 +++------- .../syncing-server/src/Bootstrap/Types.ts | 1 - packages/websockets/.env.sample | 2 - .../websockets/src/Bootstrap/Container.ts | 52 +++----- packages/websockets/src/Bootstrap/Types.ts | 1 - packages/workspace/.env.sample | 2 - packages/workspace/src/Bootstrap/Container.ts | 69 +++------- packages/workspace/src/Bootstrap/Types.ts | 1 - 28 files changed, 197 insertions(+), 435 deletions(-) diff --git a/docker/docker-entrypoint.sh b/docker/docker-entrypoint.sh index c418a3cc2..bd6c2fa4e 100755 --- a/docker/docker-entrypoint.sh +++ b/docker/docker-entrypoint.sh @@ -96,8 +96,6 @@ export AUTH_SERVER_NEW_RELIC_ENABLED=false export AUTH_SERVER_NEW_RELIC_APP_NAME=Auth export AUTH_SERVER_NEW_RELIC_NO_CONFIG_FILE=true -export AUTH_SERVER_REDIS_EVENTS_CHANNEL="auth-events" - if [ -z "$AUTH_SERVER_DISABLE_USER_REGISTRATION" ]; then export AUTH_SERVER_DISABLE_USER_REGISTRATION=false fi @@ -224,8 +222,6 @@ if [ -z "$SYNCING_SERVER_SQS_ENDPOINT" ]; then export SYNCING_SERVER_SQS_ENDPOINT="http://localstack:4566" fi -export SYNCING_SERVER_REDIS_EVENTS_CHANNEL="syncing-sever-events" - export SYNCING_SERVER_AUTH_SERVER_URL=http://localhost:$AUTH_SERVER_PORT if [ -z "$SYNCING_SERVER_EMAIL_ATTACHMENT_MAX_BYTE_SIZE" ]; then @@ -257,8 +253,6 @@ fi export FILES_SERVER_NODE_ENV="production" export FILES_SERVER_VERSION="local" -export FILES_SERVER_REDIS_EVENTS_CHANNEL="files-events" - if [ -z "$FILES_SERVER_MAX_CHUNK_BYTES" ]; then export FILES_SERVER_MAX_CHUNK_BYTES=100000000 fi @@ -309,8 +303,6 @@ fi export REVISIONS_SERVER_NODE_ENV="production" export REVISIONS_SERVER_VERSION="local" -export REVISIONS_SERVER_REDIS_EVENTS_CHANNEL="revisions-events" - export REVISIONS_SERVER_NEW_RELIC_ENABLED=false if [ -z "$REVISIONS_SERVER_SNS_TOPIC_ARN" ]; then @@ -370,8 +362,6 @@ else export API_GATEWAY_FILES_SERVER_URL=$PUBLIC_FILES_SERVER_URL fi -export API_GATEWAY_REDIS_EVENTS_CHANNEL="api-gateway-event" - printenv | grep API_GATEWAY_ | sed 's/API_GATEWAY_//g' > /opt/server/packages/api-gateway/.env # Run supervisor diff --git a/packages/analytics/.env.sample b/packages/analytics/.env.sample index 2f6b507b6..46e8f968f 100644 --- a/packages/analytics/.env.sample +++ b/packages/analytics/.env.sample @@ -13,7 +13,6 @@ DB_MIGRATIONS_PATH=dist/migrations/*.js ADMIN_EMAILS=test@standardnotes.com REDIS_URL=redis://cache -REDIS_EVENTS_CHANNEL=events SNS_TOPIC_ARN= SNS_AWS_REGION= diff --git a/packages/analytics/src/Bootstrap/Container.ts b/packages/analytics/src/Bootstrap/Container.ts index 248dbf8ea..9953d9486 100644 --- a/packages/analytics/src/Bootstrap/Container.ts +++ b/packages/analytics/src/Bootstrap/Container.ts @@ -15,9 +15,6 @@ import TYPES from './Types' import { AppDataSource } from './DataSource' import { DomainEventFactory } from '../Domain/Event/DomainEventFactory' import { - RedisDomainEventPublisher, - RedisDomainEventSubscriberFactory, - RedisEventMessageHandler, SNSDomainEventPublisher, SQSDomainEventSubscriberFactory, SQSEventMessageHandler, @@ -95,22 +92,20 @@ export class ContainerConfigLoader { }) container.bind(TYPES.Logger).toConstantValue(logger) - if (env.get('SNS_TOPIC_ARN', true)) { - const snsConfig: SNSClientConfig = { - apiVersion: 'latest', - region: env.get('SNS_AWS_REGION', true), - } - if (env.get('SNS_ENDPOINT', true)) { - snsConfig.endpoint = env.get('SNS_ENDPOINT', true) - } - if (env.get('SNS_ACCESS_KEY_ID', true) && env.get('SNS_SECRET_ACCESS_KEY', true)) { - snsConfig.credentials = { - accessKeyId: env.get('SNS_ACCESS_KEY_ID', true), - secretAccessKey: env.get('SNS_SECRET_ACCESS_KEY', true), - } - } - container.bind(TYPES.SNS).toConstantValue(new SNSClient(snsConfig)) + const snsConfig: SNSClientConfig = { + apiVersion: 'latest', + region: env.get('SNS_AWS_REGION', true), } + if (env.get('SNS_ENDPOINT', true)) { + snsConfig.endpoint = env.get('SNS_ENDPOINT', true) + } + if (env.get('SNS_ACCESS_KEY_ID', true) && env.get('SNS_SECRET_ACCESS_KEY', true)) { + snsConfig.credentials = { + accessKeyId: env.get('SNS_ACCESS_KEY_ID', true), + secretAccessKey: env.get('SNS_SECRET_ACCESS_KEY', true), + } + } + container.bind(TYPES.SNS).toConstantValue(new SNSClient(snsConfig)) if (env.get('SQS_QUEUE_URL', true)) { const sqsConfig: SQSClientConfig = { @@ -130,10 +125,9 @@ export class ContainerConfigLoader { // env vars container.bind(TYPES.REDIS_URL).toConstantValue(env.get('REDIS_URL')) - container.bind(TYPES.SNS_TOPIC_ARN).toConstantValue(env.get('SNS_TOPIC_ARN', true)) + container.bind(TYPES.SNS_TOPIC_ARN).toConstantValue(env.get('SNS_TOPIC_ARN')) container.bind(TYPES.SNS_AWS_REGION).toConstantValue(env.get('SNS_AWS_REGION', true)) - container.bind(TYPES.SQS_QUEUE_URL).toConstantValue(env.get('SQS_QUEUE_URL', true)) - container.bind(TYPES.REDIS_EVENTS_CHANNEL).toConstantValue(env.get('REDIS_EVENTS_CHANNEL')) + container.bind(TYPES.SQS_QUEUE_URL).toConstantValue(env.get('SQS_QUEUE_URL')) container.bind(TYPES.NEW_RELIC_ENABLED).toConstantValue(env.get('NEW_RELIC_ENABLED', true)) container.bind(TYPES.ADMIN_EMAILS).toConstantValue(env.get('ADMIN_EMAILS').split(',')) container.bind(TYPES.MIXPANEL_TOKEN).toConstantValue(env.get('MIXPANEL_TOKEN', true)) @@ -149,17 +143,9 @@ export class ContainerConfigLoader { .toConstantValue(new RedisStatisticsStore(container.get(TYPES.PeriodKeyGenerator), container.get(TYPES.Redis))) container.bind(TYPES.Timer).toConstantValue(new Timer()) - if (env.get('SNS_TOPIC_ARN', true)) { - container - .bind(TYPES.DomainEventPublisher) - .toConstantValue(new SNSDomainEventPublisher(container.get(TYPES.SNS), container.get(TYPES.SNS_TOPIC_ARN))) - } else { - container - .bind(TYPES.DomainEventPublisher) - .toConstantValue( - new RedisDomainEventPublisher(container.get(TYPES.Redis), container.get(TYPES.REDIS_EVENTS_CHANNEL)), - ) - } + container + .bind(TYPES.DomainEventPublisher) + .toConstantValue(new SNSDomainEventPublisher(container.get(TYPES.SNS), container.get(TYPES.SNS_TOPIC_ARN))) if (env.get('MIXPANEL_TOKEN', true)) { container.bind(TYPES.MixpanelClient).toConstantValue(Mixpanel.init(env.get('MIXPANEL_TOKEN', true))) } @@ -250,37 +236,22 @@ export class ContainerConfigLoader { ['STATISTIC_PERSISTENCE_REQUESTED', container.get(TYPES.StatisticPersistenceRequestedEventHandler)], ]) - if (env.get('SQS_QUEUE_URL', true)) { - container - .bind(TYPES.DomainEventMessageHandler) - .toConstantValue( - env.get('NEW_RELIC_ENABLED', true) === 'true' - ? new SQSNewRelicEventMessageHandler(eventHandlers, container.get(TYPES.Logger)) - : new SQSEventMessageHandler(eventHandlers, container.get(TYPES.Logger)), - ) - container - .bind(TYPES.DomainEventSubscriberFactory) - .toConstantValue( - new SQSDomainEventSubscriberFactory( - container.get(TYPES.SQS), - container.get(TYPES.SQS_QUEUE_URL), - container.get(TYPES.DomainEventMessageHandler), - ), - ) - } else { - container - .bind(TYPES.DomainEventMessageHandler) - .toConstantValue(new RedisEventMessageHandler(eventHandlers, container.get(TYPES.Logger))) - container - .bind(TYPES.DomainEventSubscriberFactory) - .toConstantValue( - new RedisDomainEventSubscriberFactory( - container.get(TYPES.Redis), - container.get(TYPES.DomainEventMessageHandler), - container.get(TYPES.REDIS_EVENTS_CHANNEL), - ), - ) - } + container + .bind(TYPES.DomainEventMessageHandler) + .toConstantValue( + env.get('NEW_RELIC_ENABLED', true) === 'true' + ? new SQSNewRelicEventMessageHandler(eventHandlers, container.get(TYPES.Logger)) + : new SQSEventMessageHandler(eventHandlers, container.get(TYPES.Logger)), + ) + container + .bind(TYPES.DomainEventSubscriberFactory) + .toConstantValue( + new SQSDomainEventSubscriberFactory( + container.get(TYPES.SQS), + container.get(TYPES.SQS_QUEUE_URL), + container.get(TYPES.DomainEventMessageHandler), + ), + ) return container } diff --git a/packages/analytics/src/Bootstrap/Types.ts b/packages/analytics/src/Bootstrap/Types.ts index a9dca5267..a72c8900e 100644 --- a/packages/analytics/src/Bootstrap/Types.ts +++ b/packages/analytics/src/Bootstrap/Types.ts @@ -9,7 +9,6 @@ const TYPES = { SNS_AWS_REGION: Symbol.for('SNS_AWS_REGION'), SQS_QUEUE_URL: Symbol.for('SQS_QUEUE_URL'), SQS_AWS_REGION: Symbol.for('SQS_AWS_REGION'), - REDIS_EVENTS_CHANNEL: Symbol.for('REDIS_EVENTS_CHANNEL'), NEW_RELIC_ENABLED: Symbol.for('NEW_RELIC_ENABLED'), ADMIN_EMAILS: Symbol.for('ADMIN_EMAILS'), MIXPANEL_TOKEN: Symbol.for('MIXPANEL_TOKEN'), diff --git a/packages/api-gateway/.env.sample b/packages/api-gateway/.env.sample index 1d67d9045..2959c2a60 100644 --- a/packages/api-gateway/.env.sample +++ b/packages/api-gateway/.env.sample @@ -27,7 +27,6 @@ NEW_RELIC_LOG_ENABLED=false NEW_RELIC_LOG_LEVEL=info REDIS_URL=redis://cache -REDIS_EVENTS_CHANNEL=events # (Optional) Caching Cross Service Tokens CROSS_SERVICE_TOKEN_CACHE_TTL= diff --git a/packages/api-gateway/src/Bootstrap/Container.ts b/packages/api-gateway/src/Bootstrap/Container.ts index 90c51a779..76cf28883 100644 --- a/packages/api-gateway/src/Bootstrap/Container.ts +++ b/packages/api-gateway/src/Bootstrap/Container.ts @@ -65,7 +65,6 @@ export class ContainerConfigLoader { .bind(TYPES.HTTP_CALL_TIMEOUT) .toConstantValue(env.get('HTTP_CALL_TIMEOUT', true) ? +env.get('HTTP_CALL_TIMEOUT', true) : 60_000) container.bind(TYPES.VERSION).toConstantValue(env.get('VERSION')) - container.bind(TYPES.REDIS_EVENTS_CHANNEL).toConstantValue(env.get('REDIS_EVENTS_CHANNEL')) container.bind(TYPES.CROSS_SERVICE_TOKEN_CACHE_TTL).toConstantValue(+env.get('CROSS_SERVICE_TOKEN_CACHE_TTL', true)) // Middleware diff --git a/packages/api-gateway/src/Bootstrap/Types.ts b/packages/api-gateway/src/Bootstrap/Types.ts index 7fce61c04..3c0082162 100644 --- a/packages/api-gateway/src/Bootstrap/Types.ts +++ b/packages/api-gateway/src/Bootstrap/Types.ts @@ -14,7 +14,6 @@ const TYPES = { AUTH_JWT_SECRET: Symbol.for('AUTH_JWT_SECRET'), HTTP_CALL_TIMEOUT: Symbol.for('HTTP_CALL_TIMEOUT'), VERSION: Symbol.for('VERSION'), - REDIS_EVENTS_CHANNEL: Symbol.for('REDIS_EVENTS_CHANNEL'), CROSS_SERVICE_TOKEN_CACHE_TTL: Symbol.for('CROSS_SERVICE_TOKEN_CACHE_TTL'), // Middleware AuthMiddleware: Symbol.for('AuthMiddleware'), diff --git a/packages/auth/.env.sample b/packages/auth/.env.sample index f492d1523..f0dc1f33d 100644 --- a/packages/auth/.env.sample +++ b/packages/auth/.env.sample @@ -43,8 +43,6 @@ SQS_AWS_REGION= SYNCING_SERVER_URL=http://syncing-server-js:3000 -REDIS_EVENTS_CHANNEL=events - # (Optional) New Relic Setup NEW_RELIC_ENABLED=false NEW_RELIC_APP_NAME=Auth diff --git a/packages/auth/src/Bootstrap/Container.ts b/packages/auth/src/Bootstrap/Container.ts index 1a0f580db..d1dcea6ed 100644 --- a/packages/auth/src/Bootstrap/Container.ts +++ b/packages/auth/src/Bootstrap/Container.ts @@ -90,9 +90,6 @@ import { FeatureService } from '../Domain/Feature/FeatureService' import { SettingServiceInterface } from '../Domain/Setting/SettingServiceInterface' import { ExtensionKeyGrantedEventHandler } from '../Domain/Handler/ExtensionKeyGrantedEventHandler' import { - RedisDomainEventPublisher, - RedisDomainEventSubscriberFactory, - RedisEventMessageHandler, SNSDomainEventPublisher, SQSDomainEventSubscriberFactory, SQSEventMessageHandler, @@ -258,37 +255,33 @@ export class ContainerConfigLoader { container.bind(TYPES.Timer).toConstantValue(new Timer()) - if (env.get('SNS_TOPIC_ARN', true)) { - const snsConfig: SNSClientConfig = { - region: env.get('SNS_AWS_REGION', true), - } - if (env.get('SNS_ENDPOINT', true)) { - snsConfig.endpoint = env.get('SNS_ENDPOINT', true) - } - if (env.get('SNS_ACCESS_KEY_ID', true) && env.get('SNS_SECRET_ACCESS_KEY', true)) { - snsConfig.credentials = { - accessKeyId: env.get('SNS_ACCESS_KEY_ID', true), - secretAccessKey: env.get('SNS_SECRET_ACCESS_KEY', true), - } - } - container.bind(TYPES.SNS).toConstantValue(new SNSClient(snsConfig)) + const snsConfig: SNSClientConfig = { + region: env.get('SNS_AWS_REGION', true), } + if (env.get('SNS_ENDPOINT', true)) { + snsConfig.endpoint = env.get('SNS_ENDPOINT', true) + } + if (env.get('SNS_ACCESS_KEY_ID', true) && env.get('SNS_SECRET_ACCESS_KEY', true)) { + snsConfig.credentials = { + accessKeyId: env.get('SNS_ACCESS_KEY_ID', true), + secretAccessKey: env.get('SNS_SECRET_ACCESS_KEY', true), + } + } + container.bind(TYPES.SNS).toConstantValue(new SNSClient(snsConfig)) - if (env.get('SQS_QUEUE_URL', true)) { - const sqsConfig: SQSClientConfig = { - region: env.get('SQS_AWS_REGION', true), - } - if (env.get('SQS_ENDPOINT', true)) { - sqsConfig.endpoint = env.get('SQS_ENDPOINT', true) - } - if (env.get('SQS_ACCESS_KEY_ID', true) && env.get('SQS_SECRET_ACCESS_KEY', true)) { - sqsConfig.credentials = { - accessKeyId: env.get('SQS_ACCESS_KEY_ID', true), - secretAccessKey: env.get('SQS_SECRET_ACCESS_KEY', true), - } - } - container.bind(TYPES.SQS).toConstantValue(new SQSClient(sqsConfig)) + const sqsConfig: SQSClientConfig = { + region: env.get('SQS_AWS_REGION', true), } + if (env.get('SQS_ENDPOINT', true)) { + sqsConfig.endpoint = env.get('SQS_ENDPOINT', true) + } + if (env.get('SQS_ACCESS_KEY_ID', true) && env.get('SQS_SECRET_ACCESS_KEY', true)) { + sqsConfig.credentials = { + accessKeyId: env.get('SQS_ACCESS_KEY_ID', true), + secretAccessKey: env.get('SQS_SECRET_ACCESS_KEY', true), + } + } + container.bind(TYPES.SQS).toConstantValue(new SQSClient(sqsConfig)) // Mapping container @@ -441,13 +434,12 @@ export class ContainerConfigLoader { container .bind(TYPES.DISABLE_USER_REGISTRATION) .toConstantValue(env.get('DISABLE_USER_REGISTRATION', true) === 'true') - container.bind(TYPES.SNS_TOPIC_ARN).toConstantValue(env.get('SNS_TOPIC_ARN', true)) + container.bind(TYPES.SNS_TOPIC_ARN).toConstantValue(env.get('SNS_TOPIC_ARN')) container.bind(TYPES.SNS_AWS_REGION).toConstantValue(env.get('SNS_AWS_REGION', true)) - container.bind(TYPES.SQS_QUEUE_URL).toConstantValue(env.get('SQS_QUEUE_URL', true)) + container.bind(TYPES.SQS_QUEUE_URL).toConstantValue(env.get('SQS_QUEUE_URL')) container.bind(TYPES.USER_SERVER_REGISTRATION_URL).toConstantValue(env.get('USER_SERVER_REGISTRATION_URL', true)) container.bind(TYPES.USER_SERVER_AUTH_KEY).toConstantValue(env.get('USER_SERVER_AUTH_KEY', true)) container.bind(TYPES.USER_SERVER_CHANGE_EMAIL_URL).toConstantValue(env.get('USER_SERVER_CHANGE_EMAIL_URL', true)) - container.bind(TYPES.REDIS_EVENTS_CHANNEL).toConstantValue(env.get('REDIS_EVENTS_CHANNEL')) container.bind(TYPES.NEW_RELIC_ENABLED).toConstantValue(env.get('NEW_RELIC_ENABLED', true)) container.bind(TYPES.SYNCING_SERVER_URL).toConstantValue(env.get('SYNCING_SERVER_URL')) container.bind(TYPES.VERSION).toConstantValue(env.get('VERSION')) @@ -535,17 +527,9 @@ export class ContainerConfigLoader { .toConstantValue(new DeterministicSelector()) container.bind(TYPES.UserSubscriptionService).to(UserSubscriptionService) - if (env.get('SNS_TOPIC_ARN', true)) { - container - .bind(TYPES.DomainEventPublisher) - .toConstantValue(new SNSDomainEventPublisher(container.get(TYPES.SNS), container.get(TYPES.SNS_TOPIC_ARN))) - } else { - container - .bind(TYPES.DomainEventPublisher) - .toConstantValue( - new RedisDomainEventPublisher(container.get(TYPES.Redis), container.get(TYPES.REDIS_EVENTS_CHANNEL)), - ) - } + container + .bind(TYPES.DomainEventPublisher) + .toConstantValue(new SNSDomainEventPublisher(container.get(TYPES.SNS), container.get(TYPES.SNS_TOPIC_ARN))) // use cases container @@ -803,37 +787,22 @@ export class ContainerConfigLoader { ['EMAIL_SUBSCRIPTION_UNSUBSCRIBED', container.get(TYPES.EmailSubscriptionUnsubscribedEventHandler)], ]) - if (env.get('SQS_QUEUE_URL', true)) { - container - .bind(TYPES.DomainEventMessageHandler) - .toConstantValue( - env.get('NEW_RELIC_ENABLED', true) === 'true' - ? new SQSNewRelicEventMessageHandler(eventHandlers, container.get(TYPES.Logger)) - : new SQSEventMessageHandler(eventHandlers, container.get(TYPES.Logger)), - ) - container - .bind(TYPES.DomainEventSubscriberFactory) - .toConstantValue( - new SQSDomainEventSubscriberFactory( - container.get(TYPES.SQS), - container.get(TYPES.SQS_QUEUE_URL), - container.get(TYPES.DomainEventMessageHandler), - ), - ) - } else { - container - .bind(TYPES.DomainEventMessageHandler) - .toConstantValue(new RedisEventMessageHandler(eventHandlers, container.get(TYPES.Logger))) - container - .bind(TYPES.DomainEventSubscriberFactory) - .toConstantValue( - new RedisDomainEventSubscriberFactory( - container.get(TYPES.Redis), - container.get(TYPES.DomainEventMessageHandler), - container.get(TYPES.REDIS_EVENTS_CHANNEL), - ), - ) - } + container + .bind(TYPES.DomainEventMessageHandler) + .toConstantValue( + env.get('NEW_RELIC_ENABLED', true) === 'true' + ? new SQSNewRelicEventMessageHandler(eventHandlers, container.get(TYPES.Logger)) + : new SQSEventMessageHandler(eventHandlers, container.get(TYPES.Logger)), + ) + container + .bind(TYPES.DomainEventSubscriberFactory) + .toConstantValue( + new SQSDomainEventSubscriberFactory( + container.get(TYPES.SQS), + container.get(TYPES.SQS_QUEUE_URL), + container.get(TYPES.DomainEventMessageHandler), + ), + ) return container } diff --git a/packages/auth/src/Bootstrap/Types.ts b/packages/auth/src/Bootstrap/Types.ts index 9ac3ae91e..fd56af303 100644 --- a/packages/auth/src/Bootstrap/Types.ts +++ b/packages/auth/src/Bootstrap/Types.ts @@ -88,7 +88,6 @@ const TYPES = { USER_SERVER_REGISTRATION_URL: Symbol.for('USER_SERVER_REGISTRATION_URL'), USER_SERVER_AUTH_KEY: Symbol.for('USER_SERVER_AUTH_KEY'), USER_SERVER_CHANGE_EMAIL_URL: Symbol.for('USER_SERVER_CHANGE_EMAIL_URL'), - REDIS_EVENTS_CHANNEL: Symbol.for('REDIS_EVENTS_CHANNEL'), NEW_RELIC_ENABLED: Symbol.for('NEW_RELIC_ENABLED'), SYNCING_SERVER_URL: Symbol.for('SYNCING_SERVER_URL'), VERSION: Symbol.for('VERSION'), diff --git a/packages/files/.env.sample b/packages/files/.env.sample index 46895413b..2f22aed27 100644 --- a/packages/files/.env.sample +++ b/packages/files/.env.sample @@ -5,7 +5,6 @@ VERSION=development PORT=3000 REDIS_URL=redis://cache -REDIS_EVENTS_CHANNEL=events VALET_TOKEN_SECRET=change-me-! diff --git a/packages/files/src/Bootstrap/Container.ts b/packages/files/src/Bootstrap/Container.ts index cf454ea6b..e7df9ae89 100644 --- a/packages/files/src/Bootstrap/Container.ts +++ b/packages/files/src/Bootstrap/Container.ts @@ -14,9 +14,6 @@ import { Timer, TimerInterface } from '@standardnotes/time' import { DomainEventFactoryInterface } from '../Domain/Event/DomainEventFactoryInterface' import { DomainEventFactory } from '../Domain/Event/DomainEventFactory' import { - RedisDomainEventPublisher, - RedisDomainEventSubscriberFactory, - RedisEventMessageHandler, SNSDomainEventPublisher, SQSDomainEventSubscriberFactory, SQSEventMessageHandler, @@ -61,13 +58,12 @@ export class ContainerConfigLoader { container.bind(TYPES.S3_BUCKET_NAME).toConstantValue(env.get('S3_BUCKET_NAME', true)) container.bind(TYPES.S3_AWS_REGION).toConstantValue(env.get('S3_AWS_REGION', true)) container.bind(TYPES.VALET_TOKEN_SECRET).toConstantValue(env.get('VALET_TOKEN_SECRET')) - container.bind(TYPES.SNS_TOPIC_ARN).toConstantValue(env.get('SNS_TOPIC_ARN', true)) + container.bind(TYPES.SNS_TOPIC_ARN).toConstantValue(env.get('SNS_TOPIC_ARN')) container.bind(TYPES.SNS_AWS_REGION).toConstantValue(env.get('SNS_AWS_REGION', true)) container.bind(TYPES.REDIS_URL).toConstantValue(env.get('REDIS_URL')) - container.bind(TYPES.REDIS_EVENTS_CHANNEL).toConstantValue(env.get('REDIS_EVENTS_CHANNEL')) container.bind(TYPES.MAX_CHUNK_BYTES).toConstantValue(+env.get('MAX_CHUNK_BYTES')) container.bind(TYPES.VERSION).toConstantValue(env.get('VERSION')) - container.bind(TYPES.SQS_QUEUE_URL).toConstantValue(env.get('SQS_QUEUE_URL', true)) + container.bind(TYPES.SQS_QUEUE_URL).toConstantValue(env.get('SQS_QUEUE_URL')) container .bind(TYPES.FILE_UPLOAD_PATH) .toConstantValue(env.get('FILE_UPLOAD_PATH', true) ?? `${__dirname}/../../uploads`) @@ -161,17 +157,9 @@ export class ContainerConfigLoader { // repositories container.bind(TYPES.UploadRepository).to(RedisUploadRepository) - if (env.get('SNS_TOPIC_ARN', true)) { - container - .bind(TYPES.DomainEventPublisher) - .toConstantValue(new SNSDomainEventPublisher(container.get(TYPES.SNS), container.get(TYPES.SNS_TOPIC_ARN))) - } else { - container - .bind(TYPES.DomainEventPublisher) - .toConstantValue( - new RedisDomainEventPublisher(container.get(TYPES.Redis), container.get(TYPES.REDIS_EVENTS_CHANNEL)), - ) - } + container + .bind(TYPES.DomainEventPublisher) + .toConstantValue(new SNSDomainEventPublisher(container.get(TYPES.SNS), container.get(TYPES.SNS_TOPIC_ARN))) // Handlers container @@ -189,37 +177,22 @@ export class ContainerConfigLoader { ], ]) - if (env.get('SQS_QUEUE_URL', true)) { - container - .bind(TYPES.DomainEventMessageHandler) - .toConstantValue( - env.get('NEW_RELIC_ENABLED', true) === 'true' - ? new SQSNewRelicEventMessageHandler(eventHandlers, container.get(TYPES.Logger)) - : new SQSEventMessageHandler(eventHandlers, container.get(TYPES.Logger)), - ) - container - .bind(TYPES.DomainEventSubscriberFactory) - .toConstantValue( - new SQSDomainEventSubscriberFactory( - container.get(TYPES.SQS), - container.get(TYPES.SQS_QUEUE_URL), - container.get(TYPES.DomainEventMessageHandler), - ), - ) - } else { - container - .bind(TYPES.DomainEventMessageHandler) - .toConstantValue(new RedisEventMessageHandler(eventHandlers, container.get(TYPES.Logger))) - container - .bind(TYPES.DomainEventSubscriberFactory) - .toConstantValue( - new RedisDomainEventSubscriberFactory( - container.get(TYPES.Redis), - container.get(TYPES.DomainEventMessageHandler), - container.get(TYPES.REDIS_EVENTS_CHANNEL), - ), - ) - } + container + .bind(TYPES.DomainEventMessageHandler) + .toConstantValue( + env.get('NEW_RELIC_ENABLED', true) === 'true' + ? new SQSNewRelicEventMessageHandler(eventHandlers, container.get(TYPES.Logger)) + : new SQSEventMessageHandler(eventHandlers, container.get(TYPES.Logger)), + ) + container + .bind(TYPES.DomainEventSubscriberFactory) + .toConstantValue( + new SQSDomainEventSubscriberFactory( + container.get(TYPES.SQS), + container.get(TYPES.SQS_QUEUE_URL), + container.get(TYPES.DomainEventMessageHandler), + ), + ) return container } diff --git a/packages/files/src/Bootstrap/Types.ts b/packages/files/src/Bootstrap/Types.ts index ea6c22ff4..8f0dbc8a6 100644 --- a/packages/files/src/Bootstrap/Types.ts +++ b/packages/files/src/Bootstrap/Types.ts @@ -40,7 +40,6 @@ const TYPES = { SQS_AWS_REGION: Symbol.for('SQS_AWS_REGION'), VALET_TOKEN_SECRET: Symbol.for('VALET_TOKEN_SECRET'), REDIS_URL: Symbol.for('REDIS_URL'), - REDIS_EVENTS_CHANNEL: Symbol.for('REDIS_EVENTS_CHANNEL'), MAX_CHUNK_BYTES: Symbol.for('MAX_CHUNK_BYTES'), VERSION: Symbol.for('VERSION'), NEW_RELIC_ENABLED: Symbol.for('NEW_RELIC_ENABLED'), diff --git a/packages/revisions/.env.sample b/packages/revisions/.env.sample index 980bf2676..52d29302b 100644 --- a/packages/revisions/.env.sample +++ b/packages/revisions/.env.sample @@ -22,8 +22,6 @@ SQS_AWS_REGION= S3_AWS_REGION= S3_BACKUP_BUCKET_NAME= -REDIS_EVENTS_CHANNEL=revisions - # (Optional) New Relic Setup NEW_RELIC_ENABLED=false NEW_RELIC_APP_NAME="Revisions Server" diff --git a/packages/revisions/src/Bootstrap/Container.ts b/packages/revisions/src/Bootstrap/Container.ts index 0ef5df9be..94fd5aad7 100644 --- a/packages/revisions/src/Bootstrap/Container.ts +++ b/packages/revisions/src/Bootstrap/Container.ts @@ -12,8 +12,6 @@ import { } from '@standardnotes/domain-events' import { TokenDecoderInterface, CrossServiceTokenData, TokenDecoder } from '@standardnotes/security' import { - RedisDomainEventSubscriberFactory, - RedisEventMessageHandler, SQSDomainEventSubscriberFactory, SQSEventMessageHandler, SQSNewRelicEventMessageHandler, @@ -164,8 +162,7 @@ export class ContainerConfigLoader { // env vars container.bind(TYPES.REDIS_URL).toConstantValue(env.get('REDIS_URL')) - container.bind(TYPES.SQS_QUEUE_URL).toConstantValue(env.get('SQS_QUEUE_URL', true)) - container.bind(TYPES.REDIS_EVENTS_CHANNEL).toConstantValue(env.get('REDIS_EVENTS_CHANNEL')) + container.bind(TYPES.SQS_QUEUE_URL).toConstantValue(env.get('SQS_QUEUE_URL')) container.bind(TYPES.AUTH_JWT_SECRET).toConstantValue(env.get('AUTH_JWT_SECRET')) container.bind(TYPES.S3_AWS_REGION).toConstantValue(env.get('S3_AWS_REGION', true)) container.bind(TYPES.S3_BACKUP_BUCKET_NAME).toConstantValue(env.get('S3_BACKUP_BUCKET_NAME', true)) @@ -264,37 +261,22 @@ export class ContainerConfigLoader { ['REVISIONS_OWNERSHIP_UPDATE_REQUESTED', container.get(TYPES.RevisionsOwnershipUpdateRequestedEventHandler)], ]) - if (env.get('SQS_QUEUE_URL', true)) { - container - .bind(TYPES.DomainEventMessageHandler) - .toConstantValue( - env.get('NEW_RELIC_ENABLED', true) === 'true' - ? new SQSNewRelicEventMessageHandler(eventHandlers, container.get(TYPES.Logger)) - : new SQSEventMessageHandler(eventHandlers, container.get(TYPES.Logger)), - ) - container - .bind(TYPES.DomainEventSubscriberFactory) - .toConstantValue( - new SQSDomainEventSubscriberFactory( - container.get(TYPES.SQS), - container.get(TYPES.SQS_QUEUE_URL), - container.get(TYPES.DomainEventMessageHandler), - ), - ) - } else { - container - .bind(TYPES.DomainEventMessageHandler) - .toConstantValue(new RedisEventMessageHandler(eventHandlers, container.get(TYPES.Logger))) - container - .bind(TYPES.DomainEventSubscriberFactory) - .toConstantValue( - new RedisDomainEventSubscriberFactory( - container.get(TYPES.Redis), - container.get(TYPES.DomainEventMessageHandler), - container.get(TYPES.REDIS_EVENTS_CHANNEL), - ), - ) - } + container + .bind(TYPES.DomainEventMessageHandler) + .toConstantValue( + env.get('NEW_RELIC_ENABLED', true) === 'true' + ? new SQSNewRelicEventMessageHandler(eventHandlers, container.get(TYPES.Logger)) + : new SQSEventMessageHandler(eventHandlers, container.get(TYPES.Logger)), + ) + container + .bind(TYPES.DomainEventSubscriberFactory) + .toConstantValue( + new SQSDomainEventSubscriberFactory( + container.get(TYPES.SQS), + container.get(TYPES.SQS_QUEUE_URL), + container.get(TYPES.DomainEventMessageHandler), + ), + ) return container } diff --git a/packages/revisions/src/Bootstrap/Types.ts b/packages/revisions/src/Bootstrap/Types.ts index d64d006c9..9e4b38c7f 100644 --- a/packages/revisions/src/Bootstrap/Types.ts +++ b/packages/revisions/src/Bootstrap/Types.ts @@ -19,7 +19,6 @@ const TYPES = { REDIS_URL: Symbol.for('REDIS_URL'), SQS_QUEUE_URL: Symbol.for('SQS_QUEUE_URL'), SQS_AWS_REGION: Symbol.for('SQS_AWS_REGION'), - REDIS_EVENTS_CHANNEL: Symbol.for('REDIS_EVENTS_CHANNEL'), AUTH_JWT_SECRET: Symbol.for('AUTH_JWT_SECRET'), S3_AWS_REGION: Symbol.for('S3_AWS_REGION'), S3_BACKUP_BUCKET_NAME: Symbol.for('S3_BACKUP_BUCKET_NAME'), diff --git a/packages/scheduler/.env.sample b/packages/scheduler/.env.sample index 0039f5edc..77ee806ae 100644 --- a/packages/scheduler/.env.sample +++ b/packages/scheduler/.env.sample @@ -11,7 +11,6 @@ DB_DEBUG_LEVEL=all # "all" | "query" | "schema" | "error" | "warn" | "info" | "l DB_MIGRATIONS_PATH=dist/migrations/*.js REDIS_URL=redis://cache -REDIS_EVENTS_CHANNEL=events SNS_TOPIC_ARN= SNS_AWS_REGION= diff --git a/packages/scheduler/src/Bootstrap/Container.ts b/packages/scheduler/src/Bootstrap/Container.ts index d136e55e8..9f036b134 100644 --- a/packages/scheduler/src/Bootstrap/Container.ts +++ b/packages/scheduler/src/Bootstrap/Container.ts @@ -14,9 +14,6 @@ import TYPES from './Types' import { AppDataSource } from './DataSource' import { DomainEventFactory } from '../Domain/Event/DomainEventFactory' import { - RedisDomainEventPublisher, - RedisDomainEventSubscriberFactory, - RedisEventMessageHandler, SNSDomainEventPublisher, SQSDomainEventSubscriberFactory, SQSEventMessageHandler, @@ -110,10 +107,9 @@ export class ContainerConfigLoader { // env vars container.bind(TYPES.REDIS_URL).toConstantValue(env.get('REDIS_URL')) - container.bind(TYPES.SNS_TOPIC_ARN).toConstantValue(env.get('SNS_TOPIC_ARN', true)) + container.bind(TYPES.SNS_TOPIC_ARN).toConstantValue(env.get('SNS_TOPIC_ARN')) container.bind(TYPES.SNS_AWS_REGION).toConstantValue(env.get('SNS_AWS_REGION', true)) - container.bind(TYPES.SQS_QUEUE_URL).toConstantValue(env.get('SQS_QUEUE_URL', true)) - container.bind(TYPES.REDIS_EVENTS_CHANNEL).toConstantValue(env.get('REDIS_EVENTS_CHANNEL')) + container.bind(TYPES.SQS_QUEUE_URL).toConstantValue(env.get('SQS_QUEUE_URL')) container.bind(TYPES.NEW_RELIC_ENABLED).toConstantValue(env.get('NEW_RELIC_ENABLED', true)) // Repositories @@ -145,17 +141,9 @@ export class ContainerConfigLoader { container.bind(TYPES.Timer).toConstantValue(new Timer()) container.bind(TYPES.JobDoneInterpreter).to(JobDoneInterpreter) - if (env.get('SNS_TOPIC_ARN', true)) { - container - .bind(TYPES.DomainEventPublisher) - .toConstantValue(new SNSDomainEventPublisher(container.get(TYPES.SNS), container.get(TYPES.SNS_TOPIC_ARN))) - } else { - container - .bind(TYPES.DomainEventPublisher) - .toConstantValue( - new RedisDomainEventPublisher(container.get(TYPES.Redis), container.get(TYPES.REDIS_EVENTS_CHANNEL)), - ) - } + container + .bind(TYPES.DomainEventPublisher) + .toConstantValue(new SNSDomainEventPublisher(container.get(TYPES.SNS), container.get(TYPES.SNS_TOPIC_ARN))) const eventHandlers: Map = new Map([ ['PREDICATE_VERIFIED', container.get(TYPES.PredicateVerifiedEventHandler)], @@ -164,37 +152,22 @@ export class ContainerConfigLoader { ['EXIT_DISCOUNT_APPLIED', container.get(TYPES.ExitDiscountAppliedEventHandler)], ]) - if (env.get('SQS_QUEUE_URL', true)) { - container - .bind(TYPES.DomainEventMessageHandler) - .toConstantValue( - env.get('NEW_RELIC_ENABLED', true) === 'true' - ? new SQSNewRelicEventMessageHandler(eventHandlers, container.get(TYPES.Logger)) - : new SQSEventMessageHandler(eventHandlers, container.get(TYPES.Logger)), - ) - container - .bind(TYPES.DomainEventSubscriberFactory) - .toConstantValue( - new SQSDomainEventSubscriberFactory( - container.get(TYPES.SQS), - container.get(TYPES.SQS_QUEUE_URL), - container.get(TYPES.DomainEventMessageHandler), - ), - ) - } else { - container - .bind(TYPES.DomainEventMessageHandler) - .toConstantValue(new RedisEventMessageHandler(eventHandlers, container.get(TYPES.Logger))) - container - .bind(TYPES.DomainEventSubscriberFactory) - .toConstantValue( - new RedisDomainEventSubscriberFactory( - container.get(TYPES.Redis), - container.get(TYPES.DomainEventMessageHandler), - container.get(TYPES.REDIS_EVENTS_CHANNEL), - ), - ) - } + container + .bind(TYPES.DomainEventMessageHandler) + .toConstantValue( + env.get('NEW_RELIC_ENABLED', true) === 'true' + ? new SQSNewRelicEventMessageHandler(eventHandlers, container.get(TYPES.Logger)) + : new SQSEventMessageHandler(eventHandlers, container.get(TYPES.Logger)), + ) + container + .bind(TYPES.DomainEventSubscriberFactory) + .toConstantValue( + new SQSDomainEventSubscriberFactory( + container.get(TYPES.SQS), + container.get(TYPES.SQS_QUEUE_URL), + container.get(TYPES.DomainEventMessageHandler), + ), + ) return container } diff --git a/packages/scheduler/src/Bootstrap/Types.ts b/packages/scheduler/src/Bootstrap/Types.ts index 31ed49ba6..5561520ac 100644 --- a/packages/scheduler/src/Bootstrap/Types.ts +++ b/packages/scheduler/src/Bootstrap/Types.ts @@ -9,7 +9,6 @@ const TYPES = { SNS_AWS_REGION: Symbol.for('SNS_AWS_REGION'), SQS_QUEUE_URL: Symbol.for('SQS_QUEUE_URL'), SQS_AWS_REGION: Symbol.for('SQS_AWS_REGION'), - REDIS_EVENTS_CHANNEL: Symbol.for('REDIS_EVENTS_CHANNEL'), NEW_RELIC_ENABLED: Symbol.for('NEW_RELIC_ENABLED'), // Repositories PredicateRepository: Symbol.for('PredicateRepository'), diff --git a/packages/syncing-server/.env.sample b/packages/syncing-server/.env.sample index aa1573c20..442a08b2e 100644 --- a/packages/syncing-server/.env.sample +++ b/packages/syncing-server/.env.sample @@ -24,8 +24,6 @@ SQS_AWS_REGION= S3_AWS_REGION= S3_BACKUP_BUCKET_NAME= -REDIS_EVENTS_CHANNEL=events - INTERNAL_DNS_REROUTE_ENABLED=false EXTENSIONS_SERVER_URL=http://extensions-server:3004 AUTH_SERVER_URL=http://auth:3000 diff --git a/packages/syncing-server/src/Bootstrap/Container.ts b/packages/syncing-server/src/Bootstrap/Container.ts index 4fe421524..43ee7dc35 100644 --- a/packages/syncing-server/src/Bootstrap/Container.ts +++ b/packages/syncing-server/src/Bootstrap/Container.ts @@ -54,9 +54,6 @@ import { UuidFilter } from '../Domain/Item/SaveRule/UuidFilter' import { ContentTypeFilter } from '../Domain/Item/SaveRule/ContentTypeFilter' import { ContentFilter } from '../Domain/Item/SaveRule/ContentFilter' import { - RedisDomainEventPublisher, - RedisDomainEventSubscriberFactory, - RedisEventMessageHandler, SNSDomainEventPublisher, SQSDomainEventSubscriberFactory, SQSEventMessageHandler, @@ -192,10 +189,9 @@ export class ContainerConfigLoader { // env vars container.bind(TYPES.REDIS_URL).toConstantValue(env.get('REDIS_URL')) - container.bind(TYPES.SNS_TOPIC_ARN).toConstantValue(env.get('SNS_TOPIC_ARN', true)) + container.bind(TYPES.SNS_TOPIC_ARN).toConstantValue(env.get('SNS_TOPIC_ARN')) container.bind(TYPES.SNS_AWS_REGION).toConstantValue(env.get('SNS_AWS_REGION', true)) - container.bind(TYPES.SQS_QUEUE_URL).toConstantValue(env.get('SQS_QUEUE_URL', true)) - container.bind(TYPES.REDIS_EVENTS_CHANNEL).toConstantValue(env.get('REDIS_EVENTS_CHANNEL')) + container.bind(TYPES.SQS_QUEUE_URL).toConstantValue(env.get('SQS_QUEUE_URL')) container.bind(TYPES.AUTH_JWT_SECRET).toConstantValue(env.get('AUTH_JWT_SECRET')) container .bind(TYPES.INTERNAL_DNS_REROUTE_ENABLED) @@ -277,17 +273,9 @@ export class ContainerConfigLoader { } container.bind(TYPES.RevisionService).to(RevisionService) - if (env.get('SNS_TOPIC_ARN', true)) { - container - .bind(TYPES.DomainEventPublisher) - .toConstantValue(new SNSDomainEventPublisher(container.get(TYPES.SNS), container.get(TYPES.SNS_TOPIC_ARN))) - } else { - container - .bind(TYPES.DomainEventPublisher) - .toConstantValue( - new RedisDomainEventPublisher(container.get(TYPES.Redis), container.get(TYPES.REDIS_EVENTS_CHANNEL)), - ) - } + container + .bind(TYPES.DomainEventPublisher) + .toConstantValue(new SNSDomainEventPublisher(container.get(TYPES.SNS), container.get(TYPES.SNS_TOPIC_ARN))) const eventHandlers: Map = new Map([ ['DUPLICATE_ITEM_SYNCED', container.get(TYPES.DuplicateItemSyncedEventHandler)], @@ -301,37 +289,22 @@ export class ContainerConfigLoader { ['ITEM_REVISION_CREATION_REQUESTED', container.get(TYPES.ItemRevisionCreationRequestedEventHandler)], ]) - if (env.get('SQS_QUEUE_URL', true)) { - container - .bind(TYPES.DomainEventMessageHandler) - .toConstantValue( - env.get('NEW_RELIC_ENABLED', true) === 'true' - ? new SQSNewRelicEventMessageHandler(eventHandlers, container.get(TYPES.Logger)) - : new SQSEventMessageHandler(eventHandlers, container.get(TYPES.Logger)), - ) - container - .bind(TYPES.DomainEventSubscriberFactory) - .toConstantValue( - new SQSDomainEventSubscriberFactory( - container.get(TYPES.SQS), - container.get(TYPES.SQS_QUEUE_URL), - container.get(TYPES.DomainEventMessageHandler), - ), - ) - } else { - container - .bind(TYPES.DomainEventMessageHandler) - .toConstantValue(new RedisEventMessageHandler(eventHandlers, container.get(TYPES.Logger))) - container - .bind(TYPES.DomainEventSubscriberFactory) - .toConstantValue( - new RedisDomainEventSubscriberFactory( - container.get(TYPES.Redis), - container.get(TYPES.DomainEventMessageHandler), - container.get(TYPES.REDIS_EVENTS_CHANNEL), - ), - ) - } + container + .bind(TYPES.DomainEventMessageHandler) + .toConstantValue( + env.get('NEW_RELIC_ENABLED', true) === 'true' + ? new SQSNewRelicEventMessageHandler(eventHandlers, container.get(TYPES.Logger)) + : new SQSEventMessageHandler(eventHandlers, container.get(TYPES.Logger)), + ) + container + .bind(TYPES.DomainEventSubscriberFactory) + .toConstantValue( + new SQSDomainEventSubscriberFactory( + container.get(TYPES.SQS), + container.get(TYPES.SQS_QUEUE_URL), + container.get(TYPES.DomainEventMessageHandler), + ), + ) container.bind(TYPES.ItemFactory).to(ItemFactory) diff --git a/packages/syncing-server/src/Bootstrap/Types.ts b/packages/syncing-server/src/Bootstrap/Types.ts index 1e5d91812..e4d039b4e 100644 --- a/packages/syncing-server/src/Bootstrap/Types.ts +++ b/packages/syncing-server/src/Bootstrap/Types.ts @@ -24,7 +24,6 @@ const TYPES = { SNS_AWS_REGION: Symbol.for('SNS_AWS_REGION'), SQS_QUEUE_URL: Symbol.for('SQS_QUEUE_URL'), SQS_AWS_REGION: Symbol.for('SQS_AWS_REGION'), - REDIS_EVENTS_CHANNEL: Symbol.for('REDIS_EVENTS_CHANNEL'), AUTH_JWT_SECRET: Symbol.for('AUTH_JWT_SECRET'), INTERNAL_DNS_REROUTE_ENABLED: Symbol.for('INTERNAL_DNS_REROUTE_ENABLED'), EXTENSIONS_SERVER_URL: Symbol.for('EXTENSIONS_SERVER_URL'), diff --git a/packages/websockets/.env.sample b/packages/websockets/.env.sample index a6d59702a..7169356b0 100644 --- a/packages/websockets/.env.sample +++ b/packages/websockets/.env.sample @@ -13,8 +13,6 @@ SNS_AWS_REGION= SQS_QUEUE_URL= SQS_AWS_REGION= -REDIS_EVENTS_CHANNEL=events - WEB_SOCKET_CONNECTION_TOKEN_SECRET= WEB_SOCKET_CONNECTION_TOKEN_TTL= diff --git a/packages/websockets/src/Bootstrap/Container.ts b/packages/websockets/src/Bootstrap/Container.ts index e67be7522..98fb15a47 100644 --- a/packages/websockets/src/Bootstrap/Container.ts +++ b/packages/websockets/src/Bootstrap/Container.ts @@ -18,8 +18,6 @@ import { AddWebSocketsConnection } from '../Domain/UseCase/AddWebSocketsConnecti import { RemoveWebSocketsConnection } from '../Domain/UseCase/RemoveWebSocketsConnection/RemoveWebSocketsConnection' import { WebSocketsClientMessenger } from '../Infra/WebSockets/WebSocketsClientMessenger' import { - RedisDomainEventSubscriberFactory, - RedisEventMessageHandler, SQSDomainEventSubscriberFactory, SQSEventMessageHandler, SQSNewRelicEventMessageHandler, @@ -110,8 +108,7 @@ export class ContainerConfigLoader { .bind(TYPES.WEB_SOCKET_CONNECTION_TOKEN_TTL) .toConstantValue(+env.get('WEB_SOCKET_CONNECTION_TOKEN_TTL', true)) container.bind(TYPES.REDIS_URL).toConstantValue(env.get('REDIS_URL')) - container.bind(TYPES.SQS_QUEUE_URL).toConstantValue(env.get('SQS_QUEUE_URL', true)) - container.bind(TYPES.REDIS_EVENTS_CHANNEL).toConstantValue(env.get('REDIS_EVENTS_CHANNEL')) + container.bind(TYPES.SQS_QUEUE_URL).toConstantValue(env.get('SQS_QUEUE_URL')) container.bind(TYPES.NEW_RELIC_ENABLED).toConstantValue(env.get('NEW_RELIC_ENABLED', true)) container.bind(TYPES.WEBSOCKETS_API_URL).toConstantValue(env.get('WEBSOCKETS_API_URL', true)) container.bind(TYPES.VERSION).toConstantValue(env.get('VERSION')) @@ -144,37 +141,22 @@ export class ContainerConfigLoader { ['WEB_SOCKET_MESSAGE_REQUESTED', container.get(TYPES.WebSocketMessageRequestedEventHandler)], ]) - if (env.get('SQS_QUEUE_URL', true)) { - container - .bind(TYPES.DomainEventMessageHandler) - .toConstantValue( - env.get('NEW_RELIC_ENABLED', true) === 'true' - ? new SQSNewRelicEventMessageHandler(eventHandlers, container.get(TYPES.Logger)) - : new SQSEventMessageHandler(eventHandlers, container.get(TYPES.Logger)), - ) - container - .bind(TYPES.DomainEventSubscriberFactory) - .toConstantValue( - new SQSDomainEventSubscriberFactory( - container.get(TYPES.SQS), - container.get(TYPES.SQS_QUEUE_URL), - container.get(TYPES.DomainEventMessageHandler), - ), - ) - } else { - container - .bind(TYPES.DomainEventMessageHandler) - .toConstantValue(new RedisEventMessageHandler(eventHandlers, container.get(TYPES.Logger))) - container - .bind(TYPES.DomainEventSubscriberFactory) - .toConstantValue( - new RedisDomainEventSubscriberFactory( - container.get(TYPES.Redis), - container.get(TYPES.DomainEventMessageHandler), - container.get(TYPES.REDIS_EVENTS_CHANNEL), - ), - ) - } + container + .bind(TYPES.DomainEventMessageHandler) + .toConstantValue( + env.get('NEW_RELIC_ENABLED', true) === 'true' + ? new SQSNewRelicEventMessageHandler(eventHandlers, container.get(TYPES.Logger)) + : new SQSEventMessageHandler(eventHandlers, container.get(TYPES.Logger)), + ) + container + .bind(TYPES.DomainEventSubscriberFactory) + .toConstantValue( + new SQSDomainEventSubscriberFactory( + container.get(TYPES.SQS), + container.get(TYPES.SQS_QUEUE_URL), + container.get(TYPES.DomainEventMessageHandler), + ), + ) return container } diff --git a/packages/websockets/src/Bootstrap/Types.ts b/packages/websockets/src/Bootstrap/Types.ts index a673b79f5..7e52b0663 100644 --- a/packages/websockets/src/Bootstrap/Types.ts +++ b/packages/websockets/src/Bootstrap/Types.ts @@ -15,7 +15,6 @@ const TYPES = { REDIS_URL: Symbol.for('REDIS_URL'), SQS_QUEUE_URL: Symbol.for('SQS_QUEUE_URL'), SQS_AWS_REGION: Symbol.for('SQS_AWS_REGION'), - REDIS_EVENTS_CHANNEL: Symbol.for('REDIS_EVENTS_CHANNEL'), NEW_RELIC_ENABLED: Symbol.for('NEW_RELIC_ENABLED'), WEBSOCKETS_API_URL: Symbol.for('WEBSOCKETS_API_URL'), VERSION: Symbol.for('VERSION'), diff --git a/packages/workspace/.env.sample b/packages/workspace/.env.sample index 6ff4aaa9e..fb2268eb1 100644 --- a/packages/workspace/.env.sample +++ b/packages/workspace/.env.sample @@ -22,8 +22,6 @@ SNS_AWS_REGION= SQS_QUEUE_URL= SQS_AWS_REGION= -REDIS_EVENTS_CHANNEL=events - # (Optional) New Relic Setup NEW_RELIC_ENABLED=false NEW_RELIC_APP_NAME=Workspace diff --git a/packages/workspace/src/Bootstrap/Container.ts b/packages/workspace/src/Bootstrap/Container.ts index b476ef8fb..6a93b26dd 100644 --- a/packages/workspace/src/Bootstrap/Container.ts +++ b/packages/workspace/src/Bootstrap/Container.ts @@ -13,9 +13,6 @@ import { Env } from './Env' import TYPES from './Types' import { AppDataSource } from './DataSource' import { - RedisDomainEventPublisher, - RedisDomainEventSubscriberFactory, - RedisEventMessageHandler, SNSDomainEventPublisher, SQSDomainEventSubscriberFactory, SQSEventMessageHandler, @@ -141,10 +138,9 @@ export class ContainerConfigLoader { // env vars container.bind(TYPES.AUTH_JWT_SECRET).toConstantValue(env.get('AUTH_JWT_SECRET')) container.bind(TYPES.REDIS_URL).toConstantValue(env.get('REDIS_URL')) - container.bind(TYPES.SNS_TOPIC_ARN).toConstantValue(env.get('SNS_TOPIC_ARN', true)) + container.bind(TYPES.SNS_TOPIC_ARN).toConstantValue(env.get('SNS_TOPIC_ARN')) container.bind(TYPES.SNS_AWS_REGION).toConstantValue(env.get('SNS_AWS_REGION', true)) - container.bind(TYPES.SQS_QUEUE_URL).toConstantValue(env.get('SQS_QUEUE_URL', true)) - container.bind(TYPES.REDIS_EVENTS_CHANNEL).toConstantValue(env.get('REDIS_EVENTS_CHANNEL')) + container.bind(TYPES.SQS_QUEUE_URL).toConstantValue(env.get('SQS_QUEUE_URL')) container.bind(TYPES.NEW_RELIC_ENABLED).toConstantValue(env.get('NEW_RELIC_ENABLED', true)) container.bind(TYPES.VERSION).toConstantValue(env.get('VERSION')) @@ -169,53 +165,30 @@ export class ContainerConfigLoader { .bind>(TYPES.CrossServiceTokenDecoder) .toConstantValue(new TokenDecoder(container.get(TYPES.AUTH_JWT_SECRET))) - if (env.get('SNS_TOPIC_ARN', true)) { - container - .bind(TYPES.DomainEventPublisher) - .toConstantValue(new SNSDomainEventPublisher(container.get(TYPES.SNS), container.get(TYPES.SNS_TOPIC_ARN))) - } else { - container - .bind(TYPES.DomainEventPublisher) - .toConstantValue( - new RedisDomainEventPublisher(container.get(TYPES.Redis), container.get(TYPES.REDIS_EVENTS_CHANNEL)), - ) - } + container + .bind(TYPES.DomainEventPublisher) + .toConstantValue(new SNSDomainEventPublisher(container.get(TYPES.SNS), container.get(TYPES.SNS_TOPIC_ARN))) const eventHandlers: Map = new Map([ ['USER_REGISTERED', container.get(TYPES.UserRegisteredEventHandler)], ]) - if (env.get('SQS_QUEUE_URL', true)) { - container - .bind(TYPES.DomainEventMessageHandler) - .toConstantValue( - env.get('NEW_RELIC_ENABLED', true) === 'true' - ? new SQSNewRelicEventMessageHandler(eventHandlers, container.get(TYPES.Logger)) - : new SQSEventMessageHandler(eventHandlers, container.get(TYPES.Logger)), - ) - container - .bind(TYPES.DomainEventSubscriberFactory) - .toConstantValue( - new SQSDomainEventSubscriberFactory( - container.get(TYPES.SQS), - container.get(TYPES.SQS_QUEUE_URL), - container.get(TYPES.DomainEventMessageHandler), - ), - ) - } else { - container - .bind(TYPES.DomainEventMessageHandler) - .toConstantValue(new RedisEventMessageHandler(eventHandlers, container.get(TYPES.Logger))) - container - .bind(TYPES.DomainEventSubscriberFactory) - .toConstantValue( - new RedisDomainEventSubscriberFactory( - container.get(TYPES.Redis), - container.get(TYPES.DomainEventMessageHandler), - container.get(TYPES.REDIS_EVENTS_CHANNEL), - ), - ) - } + container + .bind(TYPES.DomainEventMessageHandler) + .toConstantValue( + env.get('NEW_RELIC_ENABLED', true) === 'true' + ? new SQSNewRelicEventMessageHandler(eventHandlers, container.get(TYPES.Logger)) + : new SQSEventMessageHandler(eventHandlers, container.get(TYPES.Logger)), + ) + container + .bind(TYPES.DomainEventSubscriberFactory) + .toConstantValue( + new SQSDomainEventSubscriberFactory( + container.get(TYPES.SQS), + container.get(TYPES.SQS_QUEUE_URL), + container.get(TYPES.DomainEventMessageHandler), + ), + ) return container } diff --git a/packages/workspace/src/Bootstrap/Types.ts b/packages/workspace/src/Bootstrap/Types.ts index ccf229ca1..8bcd87b0f 100644 --- a/packages/workspace/src/Bootstrap/Types.ts +++ b/packages/workspace/src/Bootstrap/Types.ts @@ -22,7 +22,6 @@ const TYPES = { SNS_AWS_REGION: Symbol.for('SNS_AWS_REGION'), SQS_QUEUE_URL: Symbol.for('SQS_QUEUE_URL'), SQS_AWS_REGION: Symbol.for('SQS_AWS_REGION'), - REDIS_EVENTS_CHANNEL: Symbol.for('REDIS_EVENTS_CHANNEL'), NEW_RELIC_ENABLED: Symbol.for('NEW_RELIC_ENABLED'), VERSION: Symbol.for('VERSION'), // use cases