From 8c027dbfcf3142c3d30a53e903469090318f0b03 Mon Sep 17 00:00:00 2001 From: smart_ex Date: Fri, 1 Jul 2022 01:04:04 +1000 Subject: [PATCH] fix pub/sub --- docker-compose.test.yml | 6 +++--- src/services/health.service.ts | 3 ++- src/services/notifier.service.ts | 4 +++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/docker-compose.test.yml b/docker-compose.test.yml index dd770bc..828575e 100644 --- a/docker-compose.test.yml +++ b/docker-compose.test.yml @@ -11,21 +11,21 @@ services: dockerfile: Dockerfile ports: - 8000:8000 - depends_on: [ redis ] + depends_on: [redis] txWorker: image: tornadocash/relayer:v5.0.0 restart: unless-stopped command: 'node txWorker.js' env_file: .env - depends_on: [ redis ] + depends_on: [redis] healthWorker: image: tornadocash/relayer:v5.0.0 restart: unless-stopped command: 'node healthWorker.js' env_file: .env - depends_on: [ redis ] + depends_on: [redis] redis: image: redis diff --git a/src/services/health.service.ts b/src/services/health.service.ts index 9eb6af8..0b312c7 100644 --- a/src/services/health.service.ts +++ b/src/services/health.service.ts @@ -91,7 +91,8 @@ export class HealthService { } async pushAlert(alert: Alert) { - await this.store.publisher.publish('user-notify', JSON.stringify(alert)); + const channel = `${this.config.netId}/user-notify`; + await this.store.publisher.publish(channel, JSON.stringify(alert)); } private async _checkBalance(value, currency: 'MAIN' | 'TORN') { diff --git a/src/services/notifier.service.ts b/src/services/notifier.service.ts index 77440dd..4ae3ba4 100644 --- a/src/services/notifier.service.ts +++ b/src/services/notifier.service.ts @@ -2,6 +2,7 @@ import { Telegram } from 'telegraf'; import { autoInjectable, container } from 'tsyringe'; import { RedisStore } from '../modules/redis'; import { ExtraReplyMessage } from 'telegraf/typings/telegram-types'; +import { netId } from '../config'; export type Levels = keyof typeof AlertLevel; @@ -60,7 +61,8 @@ export class NotifierService { } async subscribe() { - this.store.subscriber.subscribe('user-notify'); + const channel = `${netId}/user-notify`; + this.store.subscriber.subscribe(channel); this.store.subscriber.on('message', async (channel, message) => { await this.processAlert(message); });