UNPKG

redis-smq-common

Version:

Provides essential components and utilities shared across RedisSMQ packages.

33 lines 1.79 kB
import { THeartbeatDataFn, IHeartbeatConfig, IHeartbeatPayload, THeartbeatEvent } from './types/index.js'; import { Runnable } from '../runnable/index.js'; import { IRedisClient } from '../redis-client/index.js'; import { ILogger } from '../logger/index.js'; import { ICallback } from '../async/index.js'; import { Backoff } from '../backoff/backoff.js'; import { Timer } from '../timer/index.js'; export declare class Heartbeat<T = Record<string, unknown>> extends Runnable<THeartbeatEvent<T>> { protected static readonly MIN_HEARTBEAT_TTL = 3000; protected static readonly DEFAULT_HEARTBEAT_TTL: number; protected readonly redisClient: IRedisClient; protected readonly componentId: string; protected readonly componentType: string; protected readonly heartbeatKey: string; protected readonly heartbeatTTL: number; protected readonly heartbeatInterval: number; protected readonly logger: ILogger; protected readonly dataFn: THeartbeatDataFn<T>; protected timer: Timer; protected backoff: Backoff; constructor(redisClient: IRedisClient, logger: ILogger, config: IHeartbeatConfig, dataFn: THeartbeatDataFn<T>); static isComponentAlive(redisClient: IRedisClient, heartbeatKey: string, cb: ICallback<boolean>): void; static areComponentsAlive(redisClient: IRedisClient, heartbeatKeys: string[], cb: ICallback<Record<string, boolean>>): void; private getPayload; private scheduleNextBeat; protected beat: (cb: ICallback<IHeartbeatPayload<T>>) => void; protected handleError(err: Error): void; protected finalizeUp(): void; protected finalizeDown(): void; protected goingUp(): ((cb: ICallback<void>) => void)[]; protected goingDown(): ((cb: ICallback) => void)[]; } //# sourceMappingURL=heartbeart.d.ts.map