/// import { EventEmitter } from "events"; import Command from "../Command"; export interface HealthCheckedConnection extends EventEmitter { sendCommand(command: Command): unknown; disconnect(): void; } /** * Disconnects a connection that stops answering commands. * * Before ready, the handshake must complete within one interval. After ready, * PING is sent once per interval and must be answered before the next one. * The first PING waits a random 50-200ms longer, so subscribers that become * ready together do not ping in lockstep. * A `commandTimeout` shorter than the interval is extended for the PING, so * the interval alone decides. Replies arrive in order, so a PING queued behind * a stuck command hangs too. Sharded messages are ignored because a node can * keep pushing them while it answers no commands. A server error reply (for * example NOPERM) still proves the node answers, while a local rejection does * not, so only the former counts as an answer. */ export default class ShardedSubscriberHealthCheck { private readonly instance; private readonly intervalMs; private readonly nodeKey; private timer; private ready; private pendingPing; constructor(instance: HealthCheckedConnection, intervalMs: number, nodeKey: string); stop: () => void; private arm; private onReady; private onFire; }