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

    Class Dependency

    One thing you call, and everything you have decided about calling it.

    A policy stack is assembled per call site, which puts the state in the wrong place: a breaker built inside a client factory is a breaker per client, and a breaker only some call sites go through is not measuring the dependency. Here the state and the scope are the same object: one per upstream, constructed where you can see it, shared by everything that talks to it.

    The numbers are all yours: attempts, deadline and breaker have no defaults, because how many attempts and how long a deadline are properties of your traffic and your budget. What is not yours is the order the policies go in, which has one right answer and is assembled here so it cannot be got wrong. That includes the two policies decided per call rather than per dependency, which are CallOptions.share and CallOptions.fallback.

    const payments = new Dependency({
    name: "payments",
    attempts: 3,
    backoff: exponential({ base: 200, max: 10_000 }),
    shouldRetry: retryableApiError,
    deadline: 5_000,
    breaker: { threshold: 5, resetAfter: 30_000 },
    });
    Index
    breaker: CircuitBreaker | undefined

    The breaker for this dependency, or undefined if it was configured without one.

    budget: RetryBudget | undefined

    The retry budget for this dependency, if it has one.

    bulkhead: Bulkhead | undefined

    The bulkhead for this dependency, if it has one.

    limiter: RateLimiter | undefined

    The rate limiter for this dependency, if it has one.

    name: string

    What this dependency is called.

    shared: SingleFlight = ...

    Where calls given a CallOptions.share key are collapsed. It has nothing to configure and keeps nothing once a call settles, so unlike the rest of them it is always here.

    • get policy(): Policy

      Everything that applies to every call, as one policy, for a transport or a call site. What one call decided for itself is not in here; see CallOptions.

      Returns Policy

    • A wrapped action, for handing somewhere that expects to call it later. The signal is passed when it is called rather than here, because it belongs to the call and this can be called more than once.

      Type Parameters

      • T

      Parameters

      Returns Wrapped<T>