Setu-TS
    Preparing search index...

    Function createCachedProbe

    • 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.

      Parameters

      Returns () => Promise<boolean>

      An async function resolving the backend's reachability

      const isHealthy = createCachedProbe({
      probe: () => client.ping().then(() => true, () => false),
      hrtime: () => runtime.hrtime(),
      });

      0.1.0

    • 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".

      Type Parameters

      • T

      Parameters

      Returns () => Promise<T>