diff --git a/redis.conf b/redis.conf index ba96fee..01ca1ae 100644 --- a/redis.conf +++ b/redis.conf @@ -2,4 +2,3 @@ timeout 0 tcp-keepalive 0 databases 1 save 60 100000 -notify-keyspace-events KAE diff --git a/src/services/health.service.ts b/src/services/health.service.ts index 69a6c00..4caab11 100644 --- a/src/services/health.service.ts +++ b/src/services/health.service.ts @@ -59,7 +59,7 @@ export class HealthService { async getStatus() { const { errorsLog, errorsCode } = await this._getErrors(); - if (errorsCode['NETWORK_ERROR'] > 5) { + if (errorsCode['NETWORK_ERROR'] > 6) { await this.setStatus({ status: false, error: 'Network error' }); } const heathStatus = await this._getStatus(); @@ -87,7 +87,7 @@ export class HealthService { } async pushAlert(alert: Alert) { - await this.store.client.rpush('alerts:list', JSON.stringify(alert)); + await this.store.publisher.publish('user-notify', JSON.stringify(alert)); } private async _checkBalance(value, currency: 'MAIN' | 'TORN') { @@ -126,7 +126,6 @@ export class HealthService { throw new RelayerError(tornStatus.message, 'INSUFFICIENT_TORN_BALANCE'); } } - } type HealthData = { diff --git a/src/services/notifier.service.ts b/src/services/notifier.service.ts index 3cbfecc..668e190 100644 --- a/src/services/notifier.service.ts +++ b/src/services/notifier.service.ts @@ -47,16 +47,13 @@ export class NotifierService { } async subscribe() { - const sub = await this.store.subscriber; - sub.subscribe('__keyspace@0__:alerts:list', 'rpush'); - sub.on('message', async (channel, event) => { - if (event === 'rpush') { - const messages = await this.store.client.rpop('alerts:list', 10); - messages?.forEach(message => { - this.processAlert(message); - }); - } - }); + this.store.subscriber.subscribe('user-notify'); + this.store.subscriber.on('message', async (channel, message) => { + await this.processAlert(message); + }, + ); + + } send(message: string, level: Levels) { diff --git a/tsconfig.json b/tsconfig.json index 17bd9dc..9a8fe53 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -10,7 +10,6 @@ "outDir": "./build", "emitDecoratorMetadata": true, "experimentalDecorators": true, - "sourceMap": true, "allowSyntheticDefaultImports": true, "esModuleInterop": true, "resolveJsonModule": true