/** * Settings for how a reactor or reducer waits before opening its observation stream again. * Every setting is optional; the defaults match the .NET client. */ export interface ObservationReconnectBackoffOptions { /** The wait in milliseconds after a stream that had worked. Defaults to 2 seconds. */ baseDelayMs?: number; /** The longest wait in milliseconds, however often streams end. Defaults to 60 seconds. */ maxDelayMs?: number; /** How long in milliseconds a stream must stay open to count as having worked. Defaults to 3 minutes. */ healthyStreamDurationMs?: number; /** Returns the current time in milliseconds, measuring how long a stream stayed open. Defaults to `performance.now`. */ now?: () => number; /** Returns a value in [0, 1) choosing where in the upper half of the wait this one lands. Defaults to `Math.random`. */ nextJitter?: () => number; } /** * Decides how long one reactor or reducer waits before opening its observation stream again after it ended. * * A fixed delay is right for one observer and wrong for many: seventy reactors whose streams fail together * come back together, every two seconds, against a kernel that is still busy. So each stream that ends without * having worked doubles the wait, up to a ceiling, and every wait lands at random in its upper half so a herd * spreads out. * * The wait starts over once a stream has worked: it delivered something, or it stayed open long enough to have * been established. A base delay of zero or less is used as it is. */ export declare class ObservationReconnectBackoff { /** The default wait after a stream that had worked. */ static readonly defaultBaseDelayMs = 2000; /** The default longest wait between attempts. */ static readonly defaultMaxDelayMs = 60000; /** * The default time a stream must stay open to count as having worked. * * It is longer than the kernel takes to give up establishing a stream: the kernel asks a busy observer again * on the same stream, up to four attempts of a thirty-second grain call each, before it fails the stream. A * shorter threshold would count every such stream as having worked and start the wait over at the base delay. */ static readonly defaultHealthyStreamDurationMs = 180000; private static readonly _maxExponent; private readonly _baseDelayMs; private readonly _maxDelayMs; private readonly _healthyStreamDurationMs; private readonly _now; private readonly _nextJitter; private _streamsEndedWithoutWorking; private _streamOpenedAt; /** * Creates a new {@link ObservationReconnectBackoff}. * @param options - The settings; anything left out uses its default. */ constructor(options?: ObservationReconnectBackoffOptions); /** Records that a new observation stream was opened. */ streamOpened(): void; /** Records that the open stream delivered something, which proves it was established. */ streamDelivered(): void; /** * Gets how long to wait before opening the stream again, now that the open one has ended. * @returns The wait in milliseconds. */ nextDelayMs(): number; } //# sourceMappingURL=ObservationReconnectBackoff.d.ts.map