Logos DX
    Preparing search index...

    Class ResiliencePolicy<TConfig, TRule, S, H, P>Abstract

    Abstract base class for resilience policies.

    Provides the common three-method pattern used by all policies:

    • init: Parse config, initialize state (O(1))
    • resolve: Memoized lookup + dynamic checks (O(1) amortized)
    • compute: Rule matching, memoized (O(n) first call only)

    Subclasses must implement:

    • getDefaultSerializer(): Return the default serializer for this policy
    • getDefaultMethods(): Return the default HTTP methods for this policy
    • mergeRuleWithDefaults(rule): Merge a rule with policy defaults

    Type Parameters

    • TConfig extends BasePolicyConfig<any, any, any, TRule>

      The policy config type extending BasePolicyConfig

    • TRule extends BasePolicyRule<any, any, any>

      The rule type extending BasePolicyRule

    • S = any

      Instance state type

    • H = any

      Headers type

    • P = any

      Params type

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    config: TConfig | null = null
    state: PolicyInternalState<TRule, S, H, P> | null = null

    Accessors

    Methods

    • Clear the rules cache.

      Call this if you need to force re-computation of rules, though typically this is not needed.

      Returns void

    • Compute rule configuration for a method+path combination.

      This is the expensive O(n) operation that gets memoized. Finds matching rule and merges with policy defaults.

      Parameters

      • method: string

        HTTP method (uppercase)

      • path: string

        Request path

      Returns TRule | null

      Computed rule or null if disabled

    • Initialize the policy with configuration.

      Parses the config (boolean or object), validates rules, and sets up internal state for fast lookups.

      Parameters

      • Optionalconfig: boolean | TConfig

        Boolean true for defaults, or full config object

      Returns void

    • Merge a matched rule with policy defaults. Subclasses must implement this to handle policy-specific fields.

      Parameters

      • rule: TRule | null

        The matched rule (or null for global defaults)

      Returns TRule

      The merged rule with all defaults applied

    • Resolve policy configuration for a specific request.

      Uses memoization for rule matching (O(n) only once per method+path). Skip callbacks are always evaluated since they depend on request context.

      Parameters

      • method: string

        HTTP method (uppercase)

      • path: string

        Request path

      • ctx: RequestKeyOptions<S, H, P>

        Full request context for skip callback

      • OptionalskipCallback: (ctx: RequestKeyOptions<S, H, P>) => boolean | undefined

        Optional skip callback from config

      Returns TRule | null

      Resolved rule or null if disabled