Press n or j to go to the next uncovered block, b, p or k for the previous block.
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 33 34 35 36 37 38 39 40 41 42 | 57x 57x 57x 55x 55x 55x 55x 319x 319x 281x 281x 281x 38x 55x 316x 55x 55x | import { events } from 'redis-smq'; import { TMessageRateFields } from '../../../../types'; import { Ticker } from 'redis-smq-common'; import { ICallback } from 'redis-smq-common/dist/types'; export abstract class MessageRateWriter< TRateFields extends TMessageRateFields, > { protected writerTicker: Ticker; protected rateStack: [number, TMessageRateFields][] = []; constructor() { this.writerTicker = new Ticker(this.updateTimeSeries); this.writerTicker.nextTick(); } protected updateTimeSeries = (): void => { const item = this.rateStack.shift(); if (item) { const [ts, rates] = item; this.onUpdate(ts, rates, () => { this.writerTicker.nextTick(); }); } else this.writerTicker.nextTick(); }; abstract onUpdate( ts: number, rates: TMessageRateFields, cb: ICallback<void>, ): void; onRateTick = (ts: number, rates: TRateFields): void => { this.rateStack.push([ts, rates]); }; quit(cb: ICallback<void>): void { this.writerTicker.on(events.DOWN, cb); this.writerTicker.quit(); } } |