firefly-limiter - v1.0.1
    Preparing search index...

    Interface HedgeOptions

    Configuration for hedge.

    interface HedgeOptions {
        attempts: number;
        budget?: RetryBudget;
        clock?: Clock;
        delay: number | Backoff;
        onEvent?: EventSink;
        shouldHedge?: (error: unknown) => boolean;
    }
    Index
    attempts: number

    Attempts that may be in flight at once. 1 hedges nothing.

    budget?: RetryBudget

    A ceiling on the extra attempts, shared with whatever else draws on it.

    A hedge sends a second request exactly when the dependency is slow, which is exactly when it can least afford the traffic. Sharing one budget with the retry above means the two cannot quietly add up to three times the load. The hedge only spends: the call is recorded once, by the retry.

    clock?: Clock

    Defaults to the system clock.

    delay: number | Backoff

    How long to wait for the attempt in flight before starting another, as a number or as a schedule read with the number of attempts already started.

    Set it near the latency you are willing to accept (around the p95 of the call, not the p50), or every call is sent twice.

    onEvent?: EventSink

    Receives a hedge event per attempt started beyond the first.

    shouldHedge?: (error: unknown) => boolean

    Which failures start the next attempt immediately rather than waiting out the delay.

    Left out, a hedge answers latency only: a failure is passed straight to the caller and repeating it is retry's job. Supplying this makes the hedge repeat failures too, which is a decision with the same shape as shouldRetry and is why it has no default.