import type { Procedure } from "../procedure.ts"; import { type WebSocketLike, type WebSocketOptions } from "../ws.ts"; export interface HealthCheckedWebSocketOptions { /** * Interval between health checks, in milliseconds. The countdown starts when * the previous check succeeds, so the actual time between two checks * may be longer than this interval. */ checkEveryMs: number; /** * Timeout in milliseconds before a running health check is considered failed. */ timeoutMs: number; /** * When connection is closed because the health check has failed, these arguments * are used as status code and reason for closure. */ closeArgs: [code: number, reason: string]; /** * Optional {@link Timers timers} implementation. Useful for using alternative timer * implementations (e.g. running timers from a Web Worker to reduce throttling). */ timers?: Timers; } export interface Timers { setTimeout(handler: () => void, timeout?: number): number; clearTimeout(id: number | undefined): void; } /** * Creates a `WebSocketClient` and wraps it with * {@link makeHealthchecked `makeHealthchecked`}. */ export declare const createHealthCheckedWebSocketClient: (options: WebSocketOptions & HealthCheckedWebSocketOptions) => ((healthcheck: Procedure) => WebSocketLike); /** * Wraps the provided `WebSocketClient` and adds a health check. Health check * is a {@link WebSocketClient.exec procedure} that runs periodically. If this * procedure completes successfully, the health check is considered passed. If * it fails, health check is considered failed, the `close` event is dispatched * and the connection is closed. */ export declare const makeHealthChecked: (ws: WebSocketLike, options: HealthCheckedWebSocketOptions) => (healthcheck: Procedure) => WebSocketLike; //# sourceMappingURL=healthcheck.d.ts.map