-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathwebsocket.cron.service.ts
More file actions
32 lines (29 loc) · 1.11 KB
/
websocket.cron.service.ts
File metadata and controls
32 lines (29 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { Injectable } from '@nestjs/common';
import { Cron } from '@nestjs/schedule';
import { TransactionsGateway } from '../../endpoints/transactions/transaction.gateway';
import { BlocksGateway } from 'src/endpoints/blocks/blocks.gateway';
import { NetworkGateway } from 'src/endpoints/network/network.gateway';
import { Lock } from "@multiversx/sdk-nestjs-common";
@Injectable()
export class WebsocketCronService {
constructor(
private readonly transactionsGateway: TransactionsGateway,
private readonly blocksGateway: BlocksGateway,
private readonly networkGateway: NetworkGateway,
) { }
@Cron('*/6 * * * * *')
@Lock({ name: 'Push transactions to subscribers', verbose: true })
async handleTransactionsUpdate() {
await this.transactionsGateway.pushTransactions();
}
@Cron('*/6 * * * * *')
@Lock({ name: 'Push blocks to subscribers', verbose: true })
async handleBlocksUpdate() {
await this.blocksGateway.pushBlocks();
}
@Cron('*/6 * * * * *')
@Lock({ name: 'Push stats to subscribers', verbose: true })
async handleStatsUpdate() {
await this.networkGateway.pushStats();
}
}