interface CachedProbeOptions
Since 0.1.0

Options for createCachedProbe.

Type Parameters

T = boolean

Properties

readonly
probe: () => Promise<T>

The reachability probe. Resolving true means the backend is reachable; resolving false or rejecting means it is not.

A probe may resolve a wider outcome than boolean — see CachedProbeOptions.fallback. T defaults to boolean, so every existing caller is unchanged.

readonly
optional
fallback: T

Outcome recorded when the probe times out or rejects.

Defaults to false — the policy this helper was built for, where a backend that will not answer counts as unreachable. That is the right answer when the probe reads the thing whose health is being reported.

It is the WRONG answer when the probe reads a proxy for that thing and the proxy can fail independently: messaging-plugin's Service Bus probe reads the namespace's MANAGEMENT plane to report on its DATA plane, so a management endpoint that is firewalled, absent (the emulator ships no TLS listener for it) or merely slow used to report a live, publishing broker as down and drain the replica. Such a probe passes fallback: undefined and widens T, so "I could not determine this" stays distinguishable from "it is down".

readonly
optional
ttlMs: number

How long to cache the last outcome, in milliseconds.

readonly
optional
timeoutMs: number

Per-probe timeout, in milliseconds. A probe that does not settle within this window resolves CachedProbeOptions.fallback, which is false — unreachable — unless the caller widened it.

readonly
hrtime: () => number

Monotonic clock in milliseconds (e.g. IRuntimeServices.hrtime()). Injected so the TTL is an interval, not a wall-clock reading.

readonly
optional
setTimer: (
fn: () => void,
ms: number
) => TimerHandle

Timer used to bound each probe (e.g. IRuntimeServices.setTimeout).

readonly
optional
clearTimer: (handle: TimerHandle) => void

Cancels a timer created by CachedProbeOptions.setTimer (e.g. IRuntimeServices.clearTimeout).

Usage

import { type CachedProbeOptions } from "common/src/index.ts";