Setu-TS
    Preparing search index...

    Interface IIdempotencyService

    The service an idempotency provider registers under CAPABILITIES.IDEMPOTENCY. Every entry point funnels through it so one configuration governs every path.

    0.9.0

    interface IIdempotencyService {
        behavior(options: IdempotentIngressOptions): IIngressBehavior;
        middleware(options?: IdempotentRouteOptions): MiddlewareFunction;
        purgeTransactional(): Promise<number>;
        within<R, S = unknown>(
            options: IdempotentWithinOptions,
            fn: (scope: S) => Promise<R>,
        ): Promise<IdempotentWithinResult<R>>;
    }
    Index
    • Deletes up to the configured batch of expired tier-C records.

      REQUIRED, like within: an unconfigured provider refuses with IdempotencyConfigurationError('transactional', …).

      Returns Promise<number>

      The number of records deleted

    • Runs work and its idempotency record in ONE transaction (tier C): a repeated key whose record is committed returns the stored result without running work; a concurrent duplicate loses the claim's primary key and its business writes roll back with it (then it replays, or rejects with a retryable 409 before the winner committed).

      REQUIRED: a provider without a transactional store refuses with IdempotencyConfigurationError('transactional', …).

      Type Parameters

      • R

        The work's result type, unconstrained

      • S = unknown

        The caller's annotation of the transaction scope, unchecked

      Parameters

      • options: IdempotentWithinOptions

        The key, namespace, scope, fingerprint and TTL

      • fn: (scope: S) => Promise<R>

        The work, given the transaction's scope

      Returns Promise<IdempotentWithinResult<R>>

      The value and whether it was replayed