createCachedProbe(options: CachedProbeOptions<boolean>): () => Promise<boolean>
Builds a cached, coalesced, time-bounded reachability probe.
The returned function answers the same factual question as
options.probe — true when the backend is reachable — but only issues a
fresh probe when the cached outcome has aged past ttlMs (measured on the
injected monotonic hrtime). Concurrent callers during a single in-flight
probe share one probe call. Each probe is bounded by timeoutMs; a probe
that exceeds the window, rejects, or throws synchronously resolves false
— the attempt never rejects.
options: CachedProbeOptions<boolean>
Probe, cache TTL, timeout and monotonic clock
createCachedProbe<T>(options: CachedProbeOptions<T> & { readonly fallback: T; }): () => Promise<T>
Widened-outcome form: fallback is REQUIRED.
The default fallback is false, which this function cannot produce for an
outcome type that does not include it. Requiring the caller to name theirs
is what keeps the returned Promise<T> honest — without this overload a
createCachedProbe<'up' | 'down'> call that omitted fallback would hand
back false on a timeout under a type promising it could not.
fallback: undefined is a valid value here, not an omission: it is the one
the tri-state Service Bus probe passes to mean "could not determine".
options: CachedProbeOptions<T> & { readonly fallback: T; }
() => Promise<T>