mirror of
https://github.com/tornadocash/tornado-relayer
synced 2024-02-02 15:04:06 +01:00
use simple pup/sub chanel
This commit is contained in:
parent
2c20febcab
commit
66dc7efa60
@ -2,4 +2,3 @@ timeout 0
|
|||||||
tcp-keepalive 0
|
tcp-keepalive 0
|
||||||
databases 1
|
databases 1
|
||||||
save 60 100000
|
save 60 100000
|
||||||
notify-keyspace-events KAE
|
|
||||||
|
@ -59,7 +59,7 @@ export class HealthService {
|
|||||||
|
|
||||||
async getStatus() {
|
async getStatus() {
|
||||||
const { errorsLog, errorsCode } = await this._getErrors();
|
const { errorsLog, errorsCode } = await this._getErrors();
|
||||||
if (errorsCode['NETWORK_ERROR'] > 5) {
|
if (errorsCode['NETWORK_ERROR'] > 6) {
|
||||||
await this.setStatus({ status: false, error: 'Network error' });
|
await this.setStatus({ status: false, error: 'Network error' });
|
||||||
}
|
}
|
||||||
const heathStatus = await this._getStatus();
|
const heathStatus = await this._getStatus();
|
||||||
@ -87,7 +87,7 @@ export class HealthService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async pushAlert(alert: Alert) {
|
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') {
|
private async _checkBalance(value, currency: 'MAIN' | 'TORN') {
|
||||||
@ -126,7 +126,6 @@ export class HealthService {
|
|||||||
throw new RelayerError(tornStatus.message, 'INSUFFICIENT_TORN_BALANCE');
|
throw new RelayerError(tornStatus.message, 'INSUFFICIENT_TORN_BALANCE');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type HealthData = {
|
type HealthData = {
|
||||||
|
@ -47,16 +47,13 @@ export class NotifierService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async subscribe() {
|
async subscribe() {
|
||||||
const sub = await this.store.subscriber;
|
this.store.subscriber.subscribe('user-notify');
|
||||||
sub.subscribe('__keyspace@0__:alerts:list', 'rpush');
|
this.store.subscriber.on('message', async (channel, message) => {
|
||||||
sub.on('message', async (channel, event) => {
|
await this.processAlert(<string>message);
|
||||||
if (event === 'rpush') {
|
},
|
||||||
const messages = await this.store.client.rpop('alerts:list', 10);
|
);
|
||||||
messages?.forEach(message => {
|
|
||||||
this.processAlert(message);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
send(message: string, level: Levels) {
|
send(message: string, level: Levels) {
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
"outDir": "./build",
|
"outDir": "./build",
|
||||||
"emitDecoratorMetadata": true,
|
"emitDecoratorMetadata": true,
|
||||||
"experimentalDecorators": true,
|
"experimentalDecorators": true,
|
||||||
"sourceMap": true,
|
|
||||||
"allowSyntheticDefaultImports": true,
|
"allowSyntheticDefaultImports": true,
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"resolveJsonModule": true
|
"resolveJsonModule": true
|
||||||
|
Loading…
Reference in New Issue
Block a user