use simple pup/sub chanel
This commit is contained in:
parent
2c20febcab
commit
66dc7efa60
@ -2,4 +2,3 @@ timeout 0
|
||||
tcp-keepalive 0
|
||||
databases 1
|
||||
save 60 100000
|
||||
notify-keyspace-events KAE
|
||||
|
@ -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 = {
|
||||
|
@ -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(<string>message);
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
|
||||
send(message: string, level: Levels) {
|
||||
|
@ -10,7 +10,6 @@
|
||||
"outDir": "./build",
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"sourceMap": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"esModuleInterop": true,
|
||||
"resolveJsonModule": true
|
||||
|
Loading…
Reference in New Issue
Block a user