Type Alias IRateLimiterStorageAdapterTransaction<TType>

IRateLimiterStorageAdapterTransaction: {
    find(
        context: IReadableContext,
        key: string,
    ): Promise<null | IRateLimiterData<TType>>;
    upsert(
        context: IReadableContext,
        key: string,
        state: TType,
        expiration: Date,
    ): Promise<void>;
}

Transaction interface for rate limiter storage operations. Provides atomic operations within a database transaction context. All methods execute within the same transaction for ACID compliance.

IMPORT_PATH: "@daiso-tech/core/rate-limiter/contracts"

Type Parameters

  • TType = unknown

    The type of metrics/state object being stored

Type declaration

  • find:function
  • upsert:function
    • Inserts a new rate limiter or updates an existing one (upsert operation). Used when recording a new attempt or updating metrics after evaluation. Implementations should use database UPSERT semantics if available.

      Parameters

      • context: IReadableContext

        Readable execution context for the operation

      • key: string

        Unique identifier for the rate limiter

      • state: TType

        The new metrics/state object from the policy

      • expiration: Date

        The calculated expiration date for this state

      Returns Promise<void>