Public .NET API ReferenceL2 Cross-Cutting & ReliabilityStableAOT: Full

EricksonLopez.Idempotency

High-performance, Native AOT-first architectural idempotency engine, lease fencing, deterministic SHA-256 fingerprinting, and distributed consistency for modern .NET.

13 namespaces81 types364 membersGenerated from XML docs & assemblies · UTC 2026-12-01

Showing 81 of 81 types (364 members)

EricksonLopez.Idempotency#

36
class

AsyncLocalIdempotencyContextAccessor

Assembly: EricksonLopez.Idempotency
public sealed class AsyncLocalIdempotencyContextAccessor : IIdempotencyContextAccessor
Implements: IIdempotencyContextAccessor

Provides access to the ambient `IdempotencyContext` flowed across asynchronous execution contexts.

Members (1)

  • propertyIdempotencyContext
    public IdempotencyContext? IdempotencyContext { get; set; }

    Gets or sets the current `IdempotencyContext`.

record

CachedIdempotencyResponse

Assembly: EricksonLopez.Idempotency.Abstractions
public sealed record CachedIdempotencyResponse(int StatusCode, IReadOnlyDictionary<string, string[]> Headers, ReadOnlyMemory<byte> Body)

Represents the cached HTTP or application response associated with a completed idempotent operation.

Members (4)

  • constructorCachedIdempotencyResponse
    public CachedIdempotencyResponse(int StatusCode, IReadOnlyDictionary<string, string[]> Headers, ReadOnlyMemory<byte> Body)

    Initializes a new instance of CachedIdempotencyResponse.

    StatusCode: int
    The HTTP or logical status code of the response.
    Headers: IReadOnlyDictionary<string, string[]>
    The headers associated with the response.
    Body: ReadOnlyMemory<byte>
    The serialized raw body payload.
  • propertyBody
    public ReadOnlyMemory<byte> Body { get; init; }

    The serialized raw body payload.

  • propertyHeaders
    public IReadOnlyDictionary<string, string[]> Headers { get; init; }

    The headers associated with the response.

  • propertyStatusCode
    public int StatusCode { get; init; }

    The HTTP or logical status code of the response.

enum

ClaimResultStatus

Assembly: EricksonLopez.Idempotency.Abstractions
public enum ClaimResultStatus : byte

Defines the specific outcome of an attempt to acquire ownership or claim an idempotency key.

Members (5)

  • fieldAcquiredNew
    AcquiredNew = 1

    Specifies that the key did not exist previously and ownership was successfully acquired as a new operation.

  • fieldAcquiredStale
    AcquiredStale = 2

    Specifies that the key existed but was stale due to an expired lease or failure, and ownership was reclaimed.

  • fieldCompletedReplay
    CompletedReplay = 3

    Specifies that the operation was already completed previously and the stored cached response should be replayed.

  • fieldFingerprintMismatch
    FingerprintMismatch = 5

    Specifies that the key was previously used with a different request payload or cryptographic fingerprint.

  • fieldInFlightConflict
    InFlightConflict = 4

    Specifies that the operation is currently being executed by another concurrent worker under an active lease.

class

DefaultIdempotencyPolicy

Assembly: EricksonLopez.Idempotency
public sealed class DefaultIdempotencyPolicy : IIdempotencyPolicy
Implements: IIdempotencyPolicy

Provides a default evaluation policy for idempotent operation execution based on configured options.

Members (5)

  • constructorDefaultIdempotencyPolicy
    public DefaultIdempotencyPolicy(IdempotencyOptions options)

    Initializes a new instance of the `DefaultIdempotencyPolicy` class with the specified idempotency options.

    options: IdempotencyOptions
    The idempotency configuration options.

    Exceptions: ArgumentNullException: `options` is `null`

  • methodIsCacheableStatusCode
    public bool IsCacheableStatusCode(int statusCode)

    Evaluates whether an HTTP or application status code is considered cacheable.

    statusCode: int
    The status code to evaluate.

    Returns: `true` if the response should be stored; otherwise, `false`.

  • propertyAllowRetryOnFailure
    public bool AllowRetryOnFailure { get; }

    Gets a value indicating whether failed executions can be retried by acquiring a new lease.

  • propertyLeaseDuration
    public TimeSpan LeaseDuration { get; }

    Gets the duration an execution lease is granted before it can be stolen by another worker.

  • propertyRetentionDuration
    public TimeSpan RetentionDuration { get; }

    Gets the duration for which completed idempotency records are retained before becoming eligible for cleanup.

record

ExecutionResponse

Assembly: EricksonLopez.Idempotency.Abstractions
public sealed record ExecutionResponse

Represents the protocol-agnostic response produced by an executed operation, containing the status code, response headers, and raw body payload.

Members (13)

  • constructorExecutionResponse
    public ExecutionResponse()

    Initializes a new instance of the `ExecutionResponse` record.

  • constructorExecutionResponse
    public ExecutionResponse(int statusCode, IReadOnlyDictionary<string, string[]>? headers = null, ReadOnlyMemory<byte> body = default)

    Initializes a new instance of the `ExecutionResponse` record with the specified status code, headers, and body payload.

    statusCode: int
    The HTTP or logical status code.
    headers: IReadOnlyDictionary<string, string[]>?
    The response headers dictionary, or `null` for empty headers.
    body: ReadOnlyMemory<byte>
    The serialized raw body payload.
  • propertyBody
    public ReadOnlyMemory<byte> Body { get; init; }

    Gets the serialized raw response body payload.

  • propertyBypassCaching
    public bool BypassCaching { get; init; }

    Gets a value indicating whether response caching in persistence stores should be bypassed (e.g. when payload limits are exceeded).

  • propertyConnection
    public System.Data.IDbConnection? Connection { get; init; }

    Gets the active database connection associated with this response, if any.

  • propertyHandledTransactionally
    public bool HandledTransactionally { get; init; }

    Gets a value indicating whether transactional completion was already performed by the execution delegate. When `true`, `IdempotencyEngine` skips calling `MarkCompletedAsync`.

  • propertyHeaders
    public IReadOnlyDictionary<string, string[]> Headers { get; init; }

    Gets the collection of headers associated with the execution response.

  • propertyIsSuccess
    public bool IsSuccess { get; }

    Gets a value indicating whether the status code represents a successful outcome (HTTP 200–299).

  • propertyStatusCode
    public required int StatusCode { get; init; }

    Gets the HTTP or logical status code of the execution response.

  • propertyTransaction
    public System.Data.IDbTransaction? Transaction { get; init; }

    Gets the active database transaction associated with this response, if any.

  • propertyTransactionContext
    public ITransactionContext? TransactionContext { get; init; }

    Gets the transactional context coordinating commit and rollback, if any.

  • fieldEmptyHeaders
    public static readonly IReadOnlyDictionary<string, string[]> EmptyHeaders

    Gets a shared empty read-only headers dictionary.

  • fieldstring
    public static readonly IReadOnlyDictionary<string, string[]> string

    Gets a shared empty read-only headers dictionary.

record

FallbackCacheEntry

Assembly: EricksonLopez.Idempotency.Abstractions
public sealed record FallbackCacheEntry(string Fingerprint, int StatusCode, IReadOnlyDictionary<string, string[]> Headers, ReadOnlyMemory<byte> Body, DateTimeOffset CreatedAtUtc, DateTimeOffset RetentionExpiresAtUtc)

Represents a cached response entry stored within the in-memory fallback cache.

Members (7)

  • constructorFallbackCacheEntry
    public FallbackCacheEntry(string Fingerprint, int StatusCode, IReadOnlyDictionary<string, string[]> Headers, ReadOnlyMemory<byte> Body, DateTimeOffset CreatedAtUtc, DateTimeOffset RetentionExpiresAtUtc)

    Initializes a new instance of FallbackCacheEntry.

    Fingerprint: string
    The cryptographic fingerprint of the original request.
    StatusCode: int
    The HTTP or protocol status code.
    Headers: IReadOnlyDictionary<string, string[]>
    The collection of cached response headers.
    Body: ReadOnlyMemory<byte>
    The payload body bytes.
    CreatedAtUtc: DateTimeOffset
    The timestamp when the entry was created.
    RetentionExpiresAtUtc: DateTimeOffset
    The expiration timestamp for retention.
  • propertyBody
    public ReadOnlyMemory<byte> Body { get; init; }

    The payload body bytes.

  • propertyCreatedAtUtc
    public DateTimeOffset CreatedAtUtc { get; init; }

    The timestamp when the entry was created.

  • propertyFingerprint
    public string Fingerprint { get; init; }

    The cryptographic fingerprint of the original request.

  • propertyHeaders
    public IReadOnlyDictionary<string, string[]> Headers { get; init; }

    The collection of cached response headers.

  • propertyRetentionExpiresAtUtc
    public DateTimeOffset RetentionExpiresAtUtc { get; init; }

    The expiration timestamp for retention.

  • propertyStatusCode
    public int StatusCode { get; init; }

    The HTTP or protocol status code.

interface

IFallbackCache

Assembly: EricksonLopez.Idempotency.Abstractions
public interface IFallbackCache

Defines the abstraction for an in-memory fallback cache to provide high-resilience idempotency replay when the primary persistent storage provider is unavailable.

Members (6)

  • methodClear
    void Clear()

    Clears all entries from the fallback cache.

  • methodRelease
    void Release(string key, Guid ownerToken)

    Releases an acquired in-flight lease if the owner token matches.

    key: string
    The idempotency cache key.
    ownerToken: Guid
    The lease owner token.
  • methodRemove
    void Remove(string key)

    Removes an entry from the fallback cache.

    key: string
    The idempotency cache key.
  • methodSet
    void Set(string key, FallbackCacheEntry entry, TimeSpan retentionDuration)

    Stores or updates an idempotency response entry in the fallback cache.

    key: string
    The idempotency cache key.
    entry: FallbackCacheEntry
    The response entry to cache.
    retentionDuration: TimeSpan
    The retention duration before eviction.
  • methodTryAcquire
    bool TryAcquire(string key, string fingerprint, TimeSpan leaseDuration, out Guid ownerToken)

    Attempts to acquire an in-flight lease in the fallback cache.

    key: string
    The idempotency cache key.
    fingerprint: string
    The cryptographic fingerprint of the request.
    leaseDuration: TimeSpan
    The lease duration.
    ownerToken: out Guid
    When successful, contains the unique token for the lease owner.

    Returns: `true` if the lease was acquired; otherwise, `false`.

  • methodTryGet
    bool TryGet(string key, out FallbackCacheEntry? entry)

    Attempts to retrieve a completed idempotency response entry from the fallback cache.

    key: string
    The idempotency cache key.
    entry: out FallbackCacheEntry?
    When this method returns, contains the cached entry if found and unexpired; otherwise, null.

    Returns: `true` if an unexpired entry was found; otherwise, `false`.

interface

IIdempotencyContextAccessor

Assembly: EricksonLopez.Idempotency.Abstractions
public interface IIdempotencyContextAccessor

Provides access to the current `IdempotencyContext`.

Members (1)

  • propertyIdempotencyContext
    IdempotencyContext? IdempotencyContext { get; set; }

    Gets or sets the current `IdempotencyContext`.

interface

IIdempotencyFingerprintGenerator

Assembly: EricksonLopez.Idempotency.Abstractions
public interface IIdempotencyFingerprintGenerator

Defines a strategy for computing deterministic fingerprints from request components.

Members (1)

  • methodGenerateFingerprint
    string GenerateFingerprint(string operationName, string scope, string tenantId, string? authenticatedSubject, ReadOnlySpan<byte> payloadBytes)

    Computes a deterministic hexadecimal fingerprint string from the specified operation components.

    operationName: string
    The logical operation or endpoint route name.
    scope: string
    The functional partition scope.
    tenantId: string
    The string tenant identifier.
    authenticatedSubject: string?
    The authenticated subject or user identifier if present; otherwise, `null`.
    payloadBytes: ReadOnlySpan<byte>
    The raw payload bytes to hash.

    Returns: An uppercase hexadecimal hash string representing the request fingerprint.

    Implementations are free to choose any deterministic hashing algorithm (SHA-256, HMAC-SHA256, etc.). The default implementation uses SHA-256 and returns an uppercase hexadecimal string.

interface

IIdempotencyKeyProvider<TContext>

Assembly: EricksonLopez.Idempotency.Abstractions
public interface IIdempotencyKeyProvider<TContext>

Defines a strategy for resolving an idempotency key from an incoming request or message context.

Remarks:

Type parameters: TContext: The request or execution context type.

Members (1)

  • methodTryGetKeyAsync
    ValueTask<IdempotencyKey?> TryGetKeyAsync(TContext context, CancellationToken cancellationToken = default)

    Attempts to resolve an idempotency key from the specified context.

    context: TContext
    The execution context.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A value task representing the asynchronous operation. The task result contains the resolved `IdempotencyKey`, or `null` if none was found.

interface

IIdempotencyPolicy

Assembly: EricksonLopez.Idempotency.Abstractions
public interface IIdempotencyPolicy

Defines policy rules and evaluation criteria for idempotent operation execution.

Members (4)

  • methodIsCacheableStatusCode
    bool IsCacheableStatusCode(int statusCode)

    Evaluates whether an HTTP or application status code is considered cacheable.

    statusCode: int
    The status code to evaluate.

    Returns: `true` if the response should be stored; otherwise, `false`.

  • propertyAllowRetryOnFailure
    bool AllowRetryOnFailure { get; }

    Gets a value indicating whether failed executions can be retried by acquiring a new lease.

  • propertyLeaseDuration
    TimeSpan LeaseDuration { get; }

    Gets the duration an execution lease is granted before it can be stolen by another worker.

  • propertyRetentionDuration
    TimeSpan RetentionDuration { get; }

    Gets the duration for which completed idempotency records are retained before becoming eligible for cleanup.

interface

IIdempotencySerializer

Assembly: EricksonLopez.Idempotency.Abstractions
public interface IIdempotencySerializer

Defines a contract for serializing and deserializing response and request payloads for idempotency storage.

Members (2)

  • methodDeserialize<T>
    T? Deserialize<T>(ReadOnlyMemory<byte> bytes)

    Deserializes a raw byte payload into an instance of `T`.

    bytes: ReadOnlyMemory<byte>
    The memory buffer containing the serialized payload bytes.

    Returns: The deserialized object instance, or `null` if deserialization produces no value.

    Type parameters: T: The target deserialization type.

  • methodSerialize<T>
    byte[] Serialize<T>(T value)

    Serializes an object value into a raw UTF-8 byte array.

    value: T
    The value to serialize.

    Returns: A byte array containing the serialized representation.

    Type parameters: T: The type of the value to serialize.

interface

IIdempotencyStore

Assembly: EricksonLopez.Idempotency.Abstractions
public interface IIdempotencyStore

Defines the persistence contract for atomically recording, updating, and querying idempotency state across distributed instances.

Members (4)

  • methodCleanupExpiredRecordsAsync
    Task<int> CleanupExpiredRecordsAsync(DateTimeOffset utcNow, int batchSize, CancellationToken cancellationToken = default)

    Deletes expired completed idempotency records in batches to reclaim storage.

    utcNow: DateTimeOffset
    The current UTC timestamp threshold for expiration.
    batchSize: int
    The maximum number of records to purge per execution batch.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A task representing the asynchronous operation. The task result contains the number of expired records permanently purged.

  • methodMarkCompletedAsync
    Task<bool> MarkCompletedAsync(Guid tenantId, string scope, IdempotencyKey key, Guid ownerToken, int concurrencyVersion, int statusCode, IReadOnlyDictionary<string, string[]> headers, ReadOnlyMemory<byte> responseBody, TimeSpan retentionDuration, CancellationToken cancellationToken = default)

    Atomically marks an in-flight idempotency record as completed, storing the produced response payload.

    tenantId: Guid
    The unique identifier of the tenant.
    scope: string
    The functional scope of the operation.
    key: IdempotencyKey
    The idempotency key.
    ownerToken: Guid
    The ownership token issued during key acquisition.
    concurrencyVersion: int
    The concurrency version issued during key acquisition.
    statusCode: int
    The HTTP or logical status code to cache.
    headers: IReadOnlyDictionary<string, string[]>
    The response headers to cache.
    responseBody: ReadOnlyMemory<byte>
    The serialized response body bytes to cache.
    retentionDuration: TimeSpan
    The retention duration for the completed record.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A task representing the asynchronous operation. The task result contains `true` if the record was successfully updated with matching fencing tokens; otherwise, `false`.

  • methodMarkFailedAsync
    Task<bool> MarkFailedAsync(Guid tenantId, string scope, IdempotencyKey key, Guid ownerToken, int concurrencyVersion, CancellationToken cancellationToken = default)

    Atomically marks an in-flight idempotency record as failed, enabling subsequent retries depending on policy.

    tenantId: Guid
    The unique identifier of the tenant.
    scope: string
    The functional scope of the operation.
    key: IdempotencyKey
    The idempotency key.
    ownerToken: Guid
    The ownership token issued during key acquisition.
    concurrencyVersion: int
    The concurrency version issued during key acquisition.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A task representing the asynchronous operation. The task result contains `true` if the record was successfully marked as failed; otherwise, `false`.

  • methodTryAcquireAsync
    Task<IdempotencyClaimResult> TryAcquireAsync(Guid tenantId, string scope, IdempotencyKey key, string fingerprint, TimeSpan leaseDuration, TimeSpan retentionDuration, CancellationToken cancellationToken = default)

    Attempts to acquire exclusive execution ownership for an idempotency key within the specified tenant and scope.

    tenantId: Guid
    The unique identifier of the tenant.
    scope: string
    The functional scope or partition of the operation.
    key: IdempotencyKey
    The unique idempotency key.
    fingerprint: string
    The cryptographic fingerprint representing the canonical request.
    leaseDuration: TimeSpan
    The duration for which the ownership lease remains valid before considering it stale.
    retentionDuration: TimeSpan
    The retention period for retaining completed records.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A task representing the asynchronous operation. The task result contains the `IdempotencyClaimResult` describing the acquisition outcome.

interface

ITransactionContext

Assembly: EricksonLopez.Idempotency.Abstractions
public interface ITransactionContext

Encapsulates an active database connection and transaction, coordinating atomic commit and rollback operations.

Members (4)

  • methodCommitAsync
    Task CommitAsync(CancellationToken cancellationToken = default)

    Asynchronously commits the database transaction.

    cancellationToken: CancellationToken
    A token to monitor for cancellation requests.
  • methodRollbackAsync
    Task RollbackAsync(CancellationToken cancellationToken = default)

    Asynchronously rolls back the database transaction.

    cancellationToken: CancellationToken
    A token to monitor for cancellation requests.
  • propertyConnection
    IDbConnection Connection { get; }

    Gets the active database connection.

  • propertyTransaction
    IDbTransaction? Transaction { get; }

    Gets the active database transaction, or `null` if uncommitted on connection.

interface

ITransactionalIdempotencyStore

Assembly: EricksonLopez.Idempotency.Abstractions
public interface ITransactionalIdempotencyStore : IIdempotencyStore
Implements: IIdempotencyStore

Extends `IIdempotencyStore` with the ability to participate in an existing database transaction, enabling atomic coordination with domain operations in the Outbox and CQRS transactional patterns.

Remarks:

Implementing stores that use relational databases (PostgreSQL, SQL Server, MySQL, MariaDB, Oracle) implement this interface to allow the caller to share an existing `IDbConnection` and optional `IDbTransaction` with the idempotency store operations. When both `connection` and `transaction` are provided, the store must use them directly without opening a new connection. This ensures that the idempotency record mutation participates in the same database transaction as the caller's domain operation. When the caller does not provide a connection/transaction, implementations fall back to opening their own connection, preserving backward-compatible behavior. See `docs/transaction-integration.md` and `docs/adr/adr-011-transactional-store-participation.md` for the architectural rationale and usage patterns. Example:

// Outbox + Idempotency atomic pattern
await using var conn = await dataSource.OpenConnectionAsync(ct);
await using var tx = await conn.BeginTransactionAsync(ct);

// 1. Domain operation
await domainRepository.SaveAsync(order, conn, tx, ct);

// 2. Outbox message
await outboxWriter.WriteAsync(orderPlacedEvent, conn, tx, ct);

// 3. Mark idempotency as completed — same transaction
if (store is ITransactionalIdempotencyStore txStore)
{
    await txStore.MarkCompletedAsync(tenantId, scope, key, ownerToken, version,
        statusCode, headers, body, retention, conn, tx, ct);
}

await tx.CommitAsync(ct);

Members (3)

  • methodMarkCompletedAsync
    Task<bool> MarkCompletedAsync(Guid tenantId, string scope, IdempotencyKey key, Guid ownerToken, int concurrencyVersion, int statusCode, IReadOnlyDictionary<string, string[]> headers, ReadOnlyMemory<byte> responseBody, TimeSpan retentionDuration, IDbConnection connection, IDbTransaction? transaction, CancellationToken cancellationToken = default)

    Atomically marks an in-flight idempotency record as completed within the provided database transaction, storing the produced response payload.

    tenantId: Guid
    The unique identifier of the tenant.
    scope: string
    The functional scope of the operation.
    key: IdempotencyKey
    The idempotency key.
    ownerToken: Guid
    The ownership token issued during key acquisition.
    concurrencyVersion: int
    The concurrency version issued during key acquisition.
    statusCode: int
    The HTTP or logical status code to cache.
    headers: IReadOnlyDictionary<string, string[]>
    The response headers to cache.
    responseBody: ReadOnlyMemory<byte>
    The serialized response body bytes to cache.
    retentionDuration: TimeSpan
    The retention duration for the completed record.
    connection: IDbConnection
    An existing open `IDbConnection` to use. Must not be `null`. The store will use this connection without opening a new one.
    transaction: IDbTransaction?
    An optional active `IDbTransaction` the operation should participate in. If `null`, the operation runs without a transaction but still uses the provided connection.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A task representing the asynchronous operation. The task result contains `true` if the record was successfully updated; otherwise, `false` (fencing token mismatch or owner mismatch).

  • methodMarkFailedAsync
    Task<bool> MarkFailedAsync(Guid tenantId, string scope, IdempotencyKey key, Guid ownerToken, int concurrencyVersion, IDbConnection connection, IDbTransaction? transaction, CancellationToken cancellationToken = default)

    Atomically marks an in-flight idempotency record as failed within the provided database transaction, enabling subsequent retries depending on policy.

    tenantId: Guid
    The unique identifier of the tenant.
    scope: string
    The functional scope of the operation.
    key: IdempotencyKey
    The idempotency key.
    ownerToken: Guid
    The ownership token issued during key acquisition.
    concurrencyVersion: int
    The concurrency version issued during key acquisition.
    connection: IDbConnection
    An existing open `IDbConnection` to use. Must not be `null`.
    transaction: IDbTransaction?
    An optional active `IDbTransaction` the operation should participate in. If `null`, the operation runs without a transaction but still uses the provided connection.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A task representing the asynchronous operation. The task result contains `true` if the record was successfully marked as failed; otherwise, `false`.

  • methodTryAcquireAsync
    Task<IdempotencyClaimResult> TryAcquireAsync(Guid tenantId, string scope, IdempotencyKey key, string fingerprint, TimeSpan leaseDuration, TimeSpan retentionDuration, IDbConnection connection, IDbTransaction? transaction, CancellationToken cancellationToken = default)

    Attempts to acquire exclusive execution ownership for an idempotency key within the specified database transaction.

    tenantId: Guid
    The unique identifier of the tenant.
    scope: string
    The functional scope or partition of the operation.
    key: IdempotencyKey
    The unique idempotency key.
    fingerprint: string
    The cryptographic fingerprint representing the canonical request.
    leaseDuration: TimeSpan
    The duration for which the ownership lease remains valid before considering it stale.
    retentionDuration: TimeSpan
    The retention period for retaining completed records.
    connection: IDbConnection
    An existing open database connection to use.
    transaction: IDbTransaction?
    An optional active database transaction to participate in.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A task representing the asynchronous operation. The task result contains the `IdempotencyClaimResult` indicating whether ownership was acquired, if a cached response is available for replay, or if a conflict occurred.

record

IdempotencyClaimResult

Assembly: EricksonLopez.Idempotency.Abstractions
public sealed record IdempotencyClaimResult(ClaimResultStatus Status, Guid? OwnerToken, int? ConcurrencyVersion, CachedIdempotencyResponse? CachedResponse, string? ExistingFingerprint)

Represents the result of an atomic key acquisition attempt against the idempotency store.

Members (8)

  • constructorIdempotencyClaimResult
    public IdempotencyClaimResult(ClaimResultStatus Status, Guid? OwnerToken, int? ConcurrencyVersion, CachedIdempotencyResponse? CachedResponse, string? ExistingFingerprint)

    Initializes a new instance of IdempotencyClaimResult.

    Status: ClaimResultStatus
    The specific status outcome of the claim attempt.
    OwnerToken: Guid?
    The unique owner token issued if acquisition succeeded.
    ConcurrencyVersion: int?
    The concurrency version token if acquisition succeeded.
    CachedResponse: CachedIdempotencyResponse?
    The cached response payload if status is `ClaimResultStatus.CompletedReplay`.
    ExistingFingerprint: string?
    The recorded fingerprint on collision or mismatch.
  • propertyCachedResponse
    public CachedIdempotencyResponse? CachedResponse { get; init; }

    The cached response payload if status is `ClaimResultStatus.CompletedReplay`.

  • propertyConcurrencyVersion
    public int? ConcurrencyVersion { get; init; }

    The concurrency version token if acquisition succeeded.

  • propertyExistingFingerprint
    public string? ExistingFingerprint { get; init; }

    The recorded fingerprint on collision or mismatch.

  • propertyIsAcquired
    public bool IsAcquired { get; }

    Gets a value indicating whether ownership of the idempotency key was successfully acquired to execute the operation.

  • propertyIsReplay
    public bool IsReplay { get; }

    Gets a value indicating whether this claim represents a replay of a previously completed operation.

  • propertyOwnerToken
    public Guid? OwnerToken { get; init; }

    The unique owner token issued if acquisition succeeded.

  • propertyStatus
    public ClaimResultStatus Status { get; init; }

    The specific status outcome of the claim attempt.

class

IdempotencyCleanupOptions

Assembly: EricksonLopez.Idempotency
public sealed class IdempotencyCleanupOptions

Encapsulates configuration options for the idempotency cleanup background service.

Members (2)

  • propertyBatchSize
    public int BatchSize { get; set; }

    Gets or sets the maximum number of expired records to purge per cleanup cycle.

    Limiting the batch size prevents long-running deletes from impacting concurrent store operations.

  • propertyInterval
    public TimeSpan Interval { get; set; }

    Gets or sets the interval between consecutive cleanup cycles.

record

IdempotencyContext

Assembly: EricksonLopez.Idempotency.Abstractions
public sealed record IdempotencyContext

Encapsulates the execution context of the currently executing idempotent request.

Remarks:

An instance is populated by the idempotency infrastructure before invoking the handler and is accessible via `IIdempotencyContextAccessor` during execution. This record is immutable; all properties are init-only.

Members (15)

  • constructorIdempotencyContext
    public IdempotencyContext()

    Initializes a new instance of the `IdempotencyContext` record with default values.

  • methodCreateAcquired
    public static IdempotencyContext CreateAcquired(Guid tenantId, string scope, IdempotencyKey key, Guid? ownerToken = null, int? concurrencyVersion = null)

    Creates a new `IdempotencyContext` representing an actively acquired idempotency lease.

    tenantId: Guid
    The tenant identifier that partitions idempotency records.
    scope: string
    The functional scope or logical partition.
    key: IdempotencyKey
    The unique idempotency key identifying the operation.
    ownerToken: Guid?
    The ownership token issued for this lease.
    concurrencyVersion: int?
    The concurrency version token issued with the lease.

    Returns: An immutable `IdempotencyContext` configured for an acquired operation.

  • methodCreateReplay
    public static IdempotencyContext CreateReplay(Guid tenantId, string scope, IdempotencyKey key)

    Creates a new `IdempotencyContext` representing a replayed cached execution.

    tenantId: Guid
    The tenant identifier that partitions idempotency records.
    scope: string
    The functional scope or logical partition.
    key: IdempotencyKey
    The unique idempotency key identifying the operation.

    Returns: An immutable `IdempotencyContext` configured for a replayed operation.

  • methodCreateReplayed
    public static IdempotencyContext CreateReplayed(Guid tenantId, string scope, IdempotencyKey key)

    Creates a new `IdempotencyContext` representing a replayed cached execution.

    tenantId: Guid
    The tenant identifier that partitions idempotency records.
    scope: string
    The functional scope or logical partition.
    key: IdempotencyKey
    The unique idempotency key identifying the operation.

    Returns: An immutable `IdempotencyContext` configured for a replayed operation.

  • methodWithTransaction
    public IdempotencyContext WithTransaction(ITransactionContext transactionContext)

    Returns a new `IdempotencyContext` with the specified transaction context.

    transactionContext: ITransactionContext
    The transactional context coordinating database interactions.

    Returns: A new `IdempotencyContext` with the updated transaction context.

  • methodWithTransaction
    public IdempotencyContext WithTransaction(System.Data.IDbConnection connection, System.Data.IDbTransaction? transaction = null)

    Returns a new `IdempotencyContext` with the specified connection and transaction.

    connection: System.Data.IDbConnection
    The database connection participating in the operation.
    transaction: System.Data.IDbTransaction?
    The optional database transaction associated with the connection.

    Returns: A new `IdempotencyContext` with the updated connection and transaction.

  • propertyConcurrencyVersion
    public int? ConcurrencyVersion { get; init; }

    Gets the fencing token version number issued with the ownership lease to detect zombie workers.

    `null` when the current execution is a replay of a cached response.

  • propertyConnection
    public System.Data.IDbConnection? Connection { get; init; }

    Gets the active database connection associated with this operation, if any.

  • propertyIsReplay
    public bool IsReplay { get; init; }

    Gets a value indicating whether the handler is being invoked as part of a cached response replay.

  • propertyKey
    public IdempotencyKey? Key { get; init; }

    Gets the unique idempotency key identifying the current operation.

  • propertyOwnerToken
    public Guid? OwnerToken { get; init; }

    Gets the ownership token issued when this instance successfully acquired the idempotency lease.

    `null` when the current execution is a replay of a cached response.

  • propertyScope
    public string Scope { get; init; }

    Gets the functional scope or logical partition that isolates this operation's idempotency records.

  • propertyTenantId
    public Guid TenantId { get; init; }

    Gets the tenant identifier that partitions idempotency records for the current operation.

  • propertyTransaction
    public System.Data.IDbTransaction? Transaction { get; init; }

    Gets the active database transaction associated with this operation, if any.

  • propertyTransactionContext
    public ITransactionContext? TransactionContext { get; init; }

    Gets the transactional context coordinating commit and rollback, if any.

class

IdempotencyDiagnostics

Assembly: EricksonLopez.Idempotency
public static class IdempotencyDiagnostics

Provides unified OpenTelemetry activity tracing and metric meters for the idempotency framework.

Members (18)

  • methodMaskKey
    public static string MaskKey(string? key)

    Masks an idempotency key to prevent PII and credential leakage in logs and telemetry traces. Preserves the first 2 and last 2 characters, masking intermediate characters with '****', or fully masking if 4 characters or fewer.

    key: string?
    The raw idempotency key.

    Returns: The masked key string, or empty string if `key` is null or empty.

  • methodRecordCompleted
    public static void RecordCompleted(string scope)

    Records a successfully completed and cached idempotent operation for the specified functional scope.

    scope: string
    The functional partition scope of the operation.
  • methodRecordConflict
    public static void RecordConflict(string scope)

    Records an in-flight concurrent execution conflict for the specified functional scope.

    scope: string
    The functional partition scope of the operation.
  • methodRecordDuplicate
    public static void RecordDuplicate(string scope)

    Records a detected duplicate request attempt for the specified functional scope.

    scope: string
    The functional partition scope of the operation.
  • methodRecordDuration
    public static void RecordDuration(double milliseconds, string scope)

    Records the total end-to-end execution duration of an idempotent operation.

    milliseconds: double
    The elapsed execution time in milliseconds.
    scope: string
    The functional partition scope of the operation.
  • methodRecordExecution
    public static void RecordExecution(string scope)

    Records a newly executed underlying business operation for the specified functional scope.

    scope: string
    The functional partition scope of the operation.
  • methodRecordFailed
    public static void RecordFailed(string scope)

    Records a failed idempotent operation for the specified functional scope.

    scope: string
    The functional partition scope of the operation.
  • methodRecordFingerprintMismatch
    public static void RecordFingerprintMismatch(string scope)

    Records an idempotency key reuse collision with mismatched payload fingerprints.

    scope: string
    The functional partition scope of the operation.
  • methodRecordLeaseLoss
    public static void RecordLeaseLoss(string scope)

    Records an idempotency execution lease loss before completion for the specified functional scope.

    scope: string
    The functional partition scope of the operation.
  • methodRecordReplayed
    public static void RecordReplayed(string scope)

    Records a cached response replay served for the specified functional scope.

    scope: string
    The functional partition scope of the operation.
  • methodRecordRequest
    public static void RecordRequest(string scope)

    Records an incoming request attempt for the specified functional scope.

    scope: string
    The functional partition scope of the operation.
  • methodRecordStorageLatency
    public static void RecordStorageLatency(double milliseconds, string operation)

    Records the latency of a storage interaction operation.

    milliseconds: double
    The elapsed storage operation time in milliseconds.
    operation: string
    The storage operation name.
  • methodRecordStoreOutage
    public static void RecordStoreOutage(string scope)

    Records an idempotency store outage or infrastructure failure for the specified functional scope.

    scope: string
    The functional partition scope of the operation.
  • methodSanitizeScope
    public static string SanitizeScope(string? scope)

    Sanitizes the scope dimension value by replacing dynamic path parameters (GUIDs, numeric identifiers) with generic placeholders to prevent metric cardinality explosion.

    scope: string?
    The raw scope string.

    Returns: A bounded, sanitized scope string safe for metric dimension tagging.

  • fieldActivitySource
    public static readonly ActivitySource ActivitySource

    Gets the `Diagnostics.ActivitySource` for distributed tracing of idempotency operations.

  • fieldMeter
    public static readonly Meter Meter

    Gets the `Metrics.Meter` for exporting operational idempotency metrics.

  • fieldServiceName
    public const string ServiceName

    Gets the service name for OpenTelemetry meter and activity source registration.

  • fieldServiceVersion
    public const string ServiceVersion

    Gets the version string of the instrumentation library.

class

IdempotencyEngine

Assembly: EricksonLopez.Idempotency
public sealed partial class IdempotencyEngine

Coordinates the execution workflow and state machine transitions for idempotent operations.

Members (3)

  • constructorIdempotencyEngine
    public IdempotencyEngine(IIdempotencyStore store, IIdempotencyPolicy policy, IIdempotencySerializer serializer, IIdempotencyContextAccessor contextAccessor, ILogger<IdempotencyEngine> logger, IFallbackCache? fallbackCache = null)

    Initializes a new instance of the `IdempotencyEngine` class with the specified dependencies.

    store: IIdempotencyStore
    The persistence store for recording idempotency state.
    policy: IIdempotencyPolicy
    The evaluation policy determining lease and retention rules.
    serializer: IIdempotencySerializer
    The serializer used for response caching.
    contextAccessor: IIdempotencyContextAccessor
    The accessor for current idempotency context.
    logger: ILogger<IdempotencyEngine>
    The logger for diagnostics and runtime events.
    fallbackCache: IFallbackCache?
    An optional fallback cache used during primary store outages.

    Exceptions: ArgumentNullException: `store`, `policy`, `serializer`, `contextAccessor`, or `logger` is `null`

  • methodExecuteAsync<TResult>
    public async Task<TResult> ExecuteAsync<TResult>(Guid tenantId, string scope, IdempotencyKey key, string fingerprint, Func<CancellationToken, Task<TResult>> operation, CancellationToken cancellationToken = default)

    Executes an operation idempotently, ensuring effectively-once execution semantics.

    tenantId: Guid
    The unique tenant identifier.
    scope: string
    The functional scope of the operation.
    key: IdempotencyKey
    The idempotency key.
    fingerprint: string
    The cryptographic fingerprint of the request.
    operation: Func<CancellationToken, Task<TResult>>
    The asynchronous operation delegate to execute.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A task representing the asynchronous operation. The task result contains the freshly computed result if ownership was acquired, or the deserialized cached value if the operation was already completed.

    Type parameters: TResult: The operation result payload type. Exceptions: ArgumentNullException: `operation` is `null`; OperationCanceledException: The `cancellationToken` was cancelled; IdempotencyFingerprintMismatchException: The key was previously used with a different request fingerprint; IdempotencyConflictException: An identical operation is currently in-flight and executing; IdempotencyLeaseExpiredException: The lease expired before completion could be finalized

  • methodExecutePipelineAsync
    public async Task<IdempotencyPipelineResult> ExecutePipelineAsync(Guid tenantId, string scope, IdempotencyKey key, string fingerprint, TimeSpan leaseDuration, TimeSpan retentionDuration, Func<IdempotencyContext, Task<ExecutionResponse>> executionDelegate, CancellationToken cancellationToken = default)

    Executes an operation through the unified idempotency pipeline, returning an `IdempotencyPipelineResult`.

    tenantId: Guid
    The unique tenant identifier.
    scope: string
    The functional scope of the operation.
    key: IdempotencyKey
    The idempotency key.
    fingerprint: string
    The cryptographic fingerprint of the request.
    leaseDuration: TimeSpan
    The duration of the execution lease.
    retentionDuration: TimeSpan
    The retention duration of the completed record.
    executionDelegate: Func<IdempotencyContext, Task<ExecutionResponse>>
    The operation delegate to execute if ownership is acquired.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A task representing the pipeline result.

    Exceptions: ArgumentNullException: `executionDelegate` is `null`; IdempotencyLeaseExpiredException: The lease expired before completion could be finalized

class

IdempotencyFingerprintHasher

Assembly: EricksonLopez.Idempotency
public sealed class IdempotencyFingerprintHasher : IIdempotencyFingerprintGenerator
Implements: IIdempotencyFingerprintGenerator

Provides high-performance, deterministic SHA-256 cryptographic fingerprint generation for idempotent operations.

Members (2)

  • methodCompute
    public static string Compute(string operationName, string scope, string tenantId, string? authenticatedSubject, ReadOnlySpan<byte> payloadBytes)

    Computes a deterministic hexadecimal SHA-256 fingerprint from the canonical components of an operation.

    operationName: string
    The logical operation or endpoint route name.
    scope: string
    The functional partition scope.
    tenantId: string
    The string tenant identifier.
    authenticatedSubject: string?
    The authenticated subject or user identifier if present; otherwise, `null`.
    payloadBytes: ReadOnlySpan<byte>
    The raw payload byte content to hash.

    Returns: An uppercase hexadecimal SHA-256 hash string uniquely identifying the combination of all provided inputs.

  • methodGenerateFingerprint
    public string GenerateFingerprint(string operationName, string scope, string tenantId, string? authenticatedSubject, ReadOnlySpan<byte> payloadBytes)

    Computes a deterministic hexadecimal fingerprint string from the specified operation components.

    operationName: string
    The logical operation or endpoint route name.
    scope: string
    The functional partition scope.
    tenantId: string
    The string tenant identifier.
    authenticatedSubject: string?
    The authenticated subject or user identifier if present; otherwise, `null`.
    payloadBytes: ReadOnlySpan<byte>
    The raw payload bytes to hash.

    Returns: An uppercase hexadecimal hash string representing the request fingerprint.

    Implementations are free to choose any deterministic hashing algorithm (SHA-256, HMAC-SHA256, etc.). The default implementation uses SHA-256 and returns an uppercase hexadecimal string.

class

IdempotencyJsonContext

Assembly: EricksonLopez.Idempotency.Abstractions
public sealed partial class IdempotencyJsonContext : JsonSerializerContext
Inherits: JsonSerializerContext

Provides source-generated JSON serialization metadata for Native AOT compatibility.

Members (0)

This type declares 0 public members (e.g. marker interface or empty enum/record).

record

IdempotencyKey

Assembly: EricksonLopez.Idempotency.Abstractions
public readonly record struct IdempotencyKey : IEquatable<IdempotencyKey>, IComparable<IdempotencyKey>, IComparable
Implements: IComparable, IComparable<IdempotencyKey>, IEquatable<IdempotencyKey>

Represents an immutable, strongly-typed idempotency key value object.

Remarks:

This type encapsulates a trimmed, non-empty key string of up to 128 characters. Value equality and ordinal comparison are supported. Leading and trailing white-space characters are trimmed before storage. The stored value is the trimmed form of the input — not the original string.

Members (17)

  • constructorIdempotencyKey
    public IdempotencyKey(string value)

    Initializes a new instance of the `IdempotencyKey` struct.

    value: string
    The unique string key supplied by the client or producer.

    Exceptions: ArgumentException: `value` is `null`, empty, or consists only of white-space characters; ArgumentOutOfRangeException: `value` exceeds 128 characters

  • methodCompareTo
    public int CompareTo(IdempotencyKey other)

    Inherits documentation from base type or interface.

    other: IdempotencyKey
  • methodCompareTo
    public int CompareTo(object? obj)

    Inherits documentation from base type or interface.

    obj: object?

    Exceptions: ArgumentException: `obj` is not of type `IdempotencyKey`

  • methodCreate
    public static IdempotencyKey Create(Guid identifier)

    Creates a new `IdempotencyKey` from the specified `Guid`.

    identifier: Guid
    The unique identifier.

    Returns: A new `IdempotencyKey` instance initialized with the hyphenless string representation of the identifier.

    Exceptions: ArgumentException: `identifier` is `Guid.Empty`

  • methodCreate
    public static IdempotencyKey Create(string value)

    Creates a new `IdempotencyKey` instance after validating input invariants.

    value: string
    The unique string key.

    Returns: A validated `IdempotencyKey` instance.

    Exceptions: ArgumentException: `value` is `null`, empty, or consists only of white-space characters; ArgumentOutOfRangeException: `value` exceeds 128 characters

  • methodNewKey
    public static IdempotencyKey NewKey()

    Generates a new random `IdempotencyKey` using a cryptographically unique identifier.

    Returns: A new `IdempotencyKey` initialized with a newly generated identifier.

  • methodToString
    public override string ToString()

    Inherits documentation from base type or interface.

  • methodTryParse
    public static bool TryParse(string? candidate, out IdempotencyKey key)

    Attempts to parse a string into an `IdempotencyKey`.

    candidate: string?
    The string candidate to parse.
    key: out IdempotencyKey
    When this method returns, contains the parsed `IdempotencyKey` if parsing succeeded; otherwise, the default uninitialized value.

    Returns: `true` if the string was successfully parsed; otherwise, `false`.

  • methodexplicit operator IdempotencyKey
    public static explicit operator IdempotencyKey(string value)

    Converts a `string` to an `IdempotencyKey` instance.

    value: string
    The string value to convert.

    Returns: A new `IdempotencyKey` initialized with the specified value.

    Exceptions: ArgumentException: `value` is `null`, empty, or consists only of white-space characters; ArgumentOutOfRangeException: `value` exceeds 128 characters

  • methodimplicit operator string
    public static implicit operator string(IdempotencyKey key)

    Converts an `IdempotencyKey` to its underlying `string` representation.

    key: IdempotencyKey
    The `IdempotencyKey` to convert.

    Returns: The underlying string representation of the key.

  • methodoperator <
    public static bool operator <(IdempotencyKey left, IdempotencyKey right)

    Determines whether a specified `IdempotencyKey` is less than another specified `IdempotencyKey`.

    left: IdempotencyKey
    The first `IdempotencyKey` to compare.
    right: IdempotencyKey
    The second `IdempotencyKey` to compare.

    Returns: `true` if `left` is less than `right`; otherwise, `false`.

  • methodoperator <=
    public static bool operator <=(IdempotencyKey left, IdempotencyKey right)

    Determines whether a specified `IdempotencyKey` is less than or equal to another specified `IdempotencyKey`.

    left: IdempotencyKey
    The first `IdempotencyKey` to compare.
    right: IdempotencyKey
    The second `IdempotencyKey` to compare.

    Returns: `true` if `left` is less than or equal to `right`; otherwise, `false`.

  • methodoperator >
    public static bool operator >(IdempotencyKey left, IdempotencyKey right)

    Determines whether a specified `IdempotencyKey` is greater than another specified `IdempotencyKey`.

    left: IdempotencyKey
    The first `IdempotencyKey` to compare.
    right: IdempotencyKey
    The second `IdempotencyKey` to compare.

    Returns: `true` if `left` is greater than `right`; otherwise, `false`.

  • methodoperator >=
    public static bool operator >=(IdempotencyKey left, IdempotencyKey right)

    Determines whether a specified `IdempotencyKey` is greater than or equal to another specified `IdempotencyKey`.

    left: IdempotencyKey
    The first `IdempotencyKey` to compare.
    right: IdempotencyKey
    The second `IdempotencyKey` to compare.

    Returns: `true` if `left` is greater than or equal to `right`; otherwise, `false`.

  • propertyIsEmpty
    public bool IsEmpty { get; }

    Gets a value indicating whether this idempotency key is empty or uninitialized.

  • propertyValue
    public string Value { get; }

    Gets the string representation of the idempotency key, or an empty string if uninitialized.

  • fieldEmpty
    public static readonly IdempotencyKey Empty

    Represents an empty or uninitialized idempotency key.

class

IdempotencyOptions

Assembly: EricksonLopez.Idempotency.Abstractions
public sealed class IdempotencyOptions

Encapsulates configuration options for the idempotency infrastructure.

Members (18)

  • methodIsHeaderCacheable
    public bool IsHeaderCacheable(string headerName)

    Determines whether the specified HTTP response header is safe to cache and replay.

    headerName: string
  • propertyAllowEmptyTenant
    public bool AllowEmptyTenant { get; set; }

    Gets or sets a value indicating whether empty/null tenant IDs are permitted.

  • propertyCacheOnlySuccessResponses
    public bool CacheOnlySuccessResponses { get; set; }

    Gets or sets a value indicating whether only successful responses (HTTP 2xx) are cached.

  • propertyCommandTimeout
    public TimeSpan CommandTimeout { get; set; }

    Gets or sets the database command timeout duration.

  • propertyDefaultLeaseDuration
    public TimeSpan DefaultLeaseDuration { get; set; }

    Gets or sets the default duration for which an acquired execution lease remains valid before another worker may steal it.

  • propertyDefaultRetentionDuration
    public TimeSpan DefaultRetentionDuration { get; set; }

    Gets or sets the default duration for which completed idempotency records are retained before becoming eligible for cleanup.

  • propertyEnableSensitiveDataLogging
    public bool EnableSensitiveDataLogging { get; set; }

    Gets or sets a value indicating whether sensitive data logging is enabled.

  • propertyEnabled
    public bool Enabled { get; set; }

    Gets or sets a value indicating whether idempotency enforcement is globally active.

  • propertyHeaderName
    public string HeaderName { get; set; }

    Gets or sets the header name used to supply the idempotency key.

  • propertyMaxRequestBodySizeBytes
    public long MaxRequestBodySizeBytes { get; set; }

    Gets or sets the maximum request payload size in bytes that will be read and buffered for fingerprint computation.

  • propertyMaxResponseBodySizeBytes
    public long MaxResponseBodySizeBytes { get; set; }

    Gets or sets the maximum response body size in bytes to buffer and persist.

  • propertyRequireIdempotencyKey
    public bool RequireIdempotencyKey { get; set; }

    Gets or sets a value indicating whether an idempotency key header is mandatory on guarded endpoints.

  • propertyResponseHeadersAllowlist
    public System.Collections.Generic.HashSet<string> ResponseHeadersAllowlist { get; }

    Gets the collection of explicitly allowed response headers to cache and replay.

  • propertyResponseHeadersBlocklist
    public System.Collections.Generic.HashSet<string> ResponseHeadersBlocklist { get; }

    Gets the collection of HTTP response header names that must be excluded from cached idempotency records.

  • propertyStoreResilience
    public StoreResilienceOptions StoreResilience { get; set; }

    Gets or sets configuration options for storage resilience policies and outage failover.

  • propertyStoreResponseBody
    public bool StoreResponseBody { get; set; }

    Gets or sets a value indicating whether response bodies are included in the cached idempotency record.

  • propertyTenantIdExtractor
    public Func<object, Guid>? TenantIdExtractor { get; set; }

    Gets or sets a delegate that extracts the tenant identifier from the ambient execution context.

  • fieldForbiddenResponseHeaders
    public static readonly System.Collections.Generic.HashSet<string> ForbiddenResponseHeaders

    Gets the collection of forbidden response headers that are never cached or replayed.

class

IdempotencyOptionsValidator

Assembly: EricksonLopez.Idempotency
public sealed class IdempotencyOptionsValidator : IValidateOptions<IdempotencyOptions>
Implements: IValidateOptions<IdempotencyOptions>

Validates domain invariants and security guardrails on `IdempotencyOptions` at startup.

Members (1)

  • methodValidate
    public ValidateOptionsResult Validate(string? name, IdempotencyOptions options)

    Inherits documentation from base type or interface.

    name: string?
    options: IdempotencyOptions
enum

IdempotencyPipelineOutcome

Assembly: EricksonLopez.Idempotency.Abstractions
public enum IdempotencyPipelineOutcome

Specifies the execution outcome of an idempotent pipeline run orchestrated by `IdempotencyEngine`.

Members (5)

  • fieldExecuted
    Executed = 0

    Indicates that the operation successfully acquired lease ownership, executed the delegate, and marked the completed response in the store.

  • fieldFingerprintMismatch
    FingerprintMismatch = 3

    Indicates that the idempotency key exists but was previously recorded with a different request fingerprint.

  • fieldInFlightConflict
    InFlightConflict = 2

    Indicates that a concurrent operation with the same idempotency key is currently executing and holds an active lease.

  • fieldReplayed
    Replayed = 1

    Indicates that the operation matched an existing completed idempotency record and replayed the previously cached response.

  • fieldUncachedFailure
    UncachedFailure = 4

    Indicates that the operation executed the delegate, but the resulting status code was not cacheable under the active policy, causing the execution lease to be marked as failed / released without response caching.

record

IdempotencyPipelineResult

Assembly: EricksonLopez.Idempotency.Abstractions
public sealed record IdempotencyPipelineResult

Represents the result of an idempotency pipeline execution, containing the pipeline outcome, status code, response headers, body payload, and contextual metadata.

Members (16)

  • constructorIdempotencyPipelineResult
    public IdempotencyPipelineResult()

    Initializes a new instance of the `IdempotencyPipelineResult` record.

  • constructorIdempotencyPipelineResult
    public IdempotencyPipelineResult(IdempotencyPipelineOutcome outcome, int statusCode = 0, IReadOnlyDictionary<string, string[]>? headers = null, ReadOnlyMemory<byte> body = default, IdempotencyKey? key = null, string? existingFingerprint = null, string? incomingFingerprint = null)

    Initializes a new instance of the `IdempotencyPipelineResult` record with the specified outcome and response components.

    outcome: IdempotencyPipelineOutcome
    The pipeline execution outcome.
    statusCode: int
    The HTTP or logical status code.
    headers: IReadOnlyDictionary<string, string[]>?
    The response headers dictionary.
    body: ReadOnlyMemory<byte>
    The serialized raw body payload.
    key: IdempotencyKey?
    The optional idempotency key.
    existingFingerprint: string?
    The existing stored fingerprint, if a mismatch occurred.
    incomingFingerprint: string?
    The incoming request fingerprint, if a mismatch occurred.
  • methodFromConflict
    public static IdempotencyPipelineResult FromConflict(IdempotencyKey key)

    Creates an `IdempotencyPipelineResult` representing an in-flight conflict.

    key: IdempotencyKey
    The conflicting idempotency key.

    Returns: A new `IdempotencyPipelineResult` with `IdempotencyPipelineOutcome.InFlightConflict`.

  • methodFromExecuted
    public static IdempotencyPipelineResult FromExecuted(ExecutionResponse response, IdempotencyKey? key = null)

    Creates a successful `IdempotencyPipelineResult` representing a newly executed operation.

    response: ExecutionResponse
    The executed response details.
    key: IdempotencyKey?
    The optional idempotency key.

    Returns: A new `IdempotencyPipelineResult` with `IdempotencyPipelineOutcome.Executed`.

  • methodFromFingerprintMismatch
    public static IdempotencyPipelineResult FromFingerprintMismatch(IdempotencyKey key, string? existingFingerprint, string incomingFingerprint)

    Creates an `IdempotencyPipelineResult` representing a fingerprint mismatch collision.

    key: IdempotencyKey
    The idempotency key that experienced the collision.
    existingFingerprint: string?
    The previously recorded fingerprint.
    incomingFingerprint: string
    The incoming request fingerprint that differed.

    Returns: A new `IdempotencyPipelineResult` with `IdempotencyPipelineOutcome.FingerprintMismatch`.

  • methodFromReplay
    public static IdempotencyPipelineResult FromReplay(CachedIdempotencyResponse? cached, IdempotencyKey? key = null)

    Creates an `IdempotencyPipelineResult` representing a replayed cached response.

    cached: CachedIdempotencyResponse?
    The cached response data, or `null` if the cached response carried no payload (e.g., HTTP 204 No Content).
    key: IdempotencyKey?
    The optional idempotency key.

    Returns: A new `IdempotencyPipelineResult` with `IdempotencyPipelineOutcome.Replayed`.

  • methodFromUncached
    public static IdempotencyPipelineResult FromUncached(ExecutionResponse response, IdempotencyKey? key = null)

    Creates an `IdempotencyPipelineResult` representing an executed operation whose response was not cached under the active policy.

    response: ExecutionResponse
    The executed response details.
    key: IdempotencyKey?
    The optional idempotency key.

    Returns: A new `IdempotencyPipelineResult` with `IdempotencyPipelineOutcome.UncachedFailure`.

  • propertyBody
    public ReadOnlyMemory<byte> Body { get; init; }

    Gets the serialized raw response body payload.

  • propertyExistingFingerprint
    public string? ExistingFingerprint { get; init; }

    Gets the existing recorded fingerprint when `Outcome` is `IdempotencyPipelineOutcome.FingerprintMismatch`.

  • propertyHeaders
    public IReadOnlyDictionary<string, string[]> Headers { get; init; }

    Gets the collection of headers associated with the response.

  • propertyIncomingFingerprint
    public string? IncomingFingerprint { get; init; }

    Gets the incoming request fingerprint when `Outcome` is `IdempotencyPipelineOutcome.FingerprintMismatch`.

  • propertyIsReplay
    public bool IsReplay { get; }

    Gets a value indicating whether this pipeline result represents a replayed cached response.

  • propertyIsSuccess
    public bool IsSuccess { get; }

    Gets a value indicating whether the pipeline execution completed successfully (either fresh execution or replay).

  • propertyKey
    public IdempotencyKey? Key { get; init; }

    Gets the idempotency key associated with this pipeline execution, if available.

  • propertyOutcome
    public required IdempotencyPipelineOutcome Outcome { get; init; }

    Gets the outcome of the pipeline execution.

  • propertyStatusCode
    public int StatusCode { get; init; }

    Gets the HTTP or logical status code associated with the response.

record

IdempotencyProblemDetails

Assembly: EricksonLopez.Idempotency.Abstractions
public sealed record IdempotencyProblemDetails(string Type, string Title, int Status, string Detail)

Represents machine-readable problem details for HTTP API error responses according to RFC 9110.

Members (5)

  • constructorIdempotencyProblemDetails
    public IdempotencyProblemDetails(string Type, string Title, int Status, string Detail)

    Initializes a new instance of IdempotencyProblemDetails.

    Type: string
    The URI reference identifying the problem type.
    Title: string
    The short, human-readable summary of the problem type.
    Status: int
    The HTTP status code generated for this occurrence.
    Detail: string
    The human-readable explanation specific to this occurrence.
  • propertyDetail
    public string Detail { get; init; }

    The human-readable explanation specific to this occurrence.

  • propertyStatus
    public int Status { get; init; }

    The HTTP status code generated for this occurrence.

  • propertyTitle
    public string Title { get; init; }

    The short, human-readable summary of the problem type.

  • propertyType
    public string Type { get; init; }

    The URI reference identifying the problem type.

record

IdempotencyScope

Assembly: EricksonLopez.Idempotency.Abstractions
public readonly record struct IdempotencyScope : IEquatable<IdempotencyScope>, IComparable<IdempotencyScope>, IComparable
Implements: IComparable, IComparable<IdempotencyScope>, IEquatable<IdempotencyScope>

Represents the logical partition or functional boundary of an idempotent operation (e.g. endpoint route or command type).

Remarks:

This type encapsulates a non-empty scope string of up to 64 characters. Comparison and value equality are both performed using `StringComparison.Ordinal` rules.

Members (14)

  • constructorIdempotencyScope
    public IdempotencyScope(string value)

    Initializes a new instance of the `IdempotencyScope` struct.

    value: string
    The scope string identifying the functional partition.

    Exceptions: ArgumentException: `value` is `null`, empty, or consists only of white-space characters; ArgumentOutOfRangeException: `value` exceeds 64 characters

  • methodCompareTo
    public int CompareTo(IdempotencyScope other)

    Inherits documentation from base type or interface.

    other: IdempotencyScope
  • methodCompareTo
    public int CompareTo(object? obj)

    Inherits documentation from base type or interface.

    obj: object?

    Exceptions: ArgumentException: `obj` is not of type `IdempotencyScope`

  • methodCreate
    public static IdempotencyScope Create(string value)

    Creates a new `IdempotencyScope` instance after validating input invariants.

    value: string
    The scope string.

    Returns: A validated `IdempotencyScope` instance.

    Exceptions: ArgumentException: `value` is `null`, empty, or consists only of white-space characters; ArgumentOutOfRangeException: `value` exceeds 64 characters

  • methodCreateNormalized
    public static IdempotencyScope CreateNormalized(string value)

    Creates a new `IdempotencyScope` instance, deterministically normalizing the input value if it exceeds 64 characters.

    value: string
    The raw scope string.

    Returns: A normalized `IdempotencyScope` whose length is guaranteed to be 64 characters or fewer.

  • methodToString
    public override string ToString()

    Inherits documentation from base type or interface.

  • methodexplicit operator IdempotencyScope
    public static explicit operator IdempotencyScope(string value)

    Converts a `string` to an `IdempotencyScope` instance.

    value: string
    The string value to convert.

    Returns: A new `IdempotencyScope` initialized with the specified value.

    Exceptions: ArgumentException: `value` is `null`, empty, or consists only of white-space characters; ArgumentOutOfRangeException: `value` exceeds 64 characters

  • methodimplicit operator string
    public static implicit operator string(IdempotencyScope scope)

    Converts an `IdempotencyScope` to its underlying `string` representation.

    scope: IdempotencyScope
    The `IdempotencyScope` to convert.

    Returns: The underlying string representation of the scope.

  • methodoperator <
    public static bool operator <(IdempotencyScope left, IdempotencyScope right)

    Determines whether a specified `IdempotencyScope` is less than another specified `IdempotencyScope`.

    left: IdempotencyScope
    The first `IdempotencyScope` to compare.
    right: IdempotencyScope
    The second `IdempotencyScope` to compare.

    Returns: `true` if `left` is less than `right`; otherwise, `false`.

  • methodoperator <=
    public static bool operator <=(IdempotencyScope left, IdempotencyScope right)

    Determines whether a specified `IdempotencyScope` is less than or equal to another specified `IdempotencyScope`.

    left: IdempotencyScope
    The first `IdempotencyScope` to compare.
    right: IdempotencyScope
    The second `IdempotencyScope` to compare.

    Returns: `true` if `left` is less than or equal to `right`; otherwise, `false`.

  • methodoperator >
    public static bool operator >(IdempotencyScope left, IdempotencyScope right)

    Determines whether a specified `IdempotencyScope` is greater than another specified `IdempotencyScope`.

    left: IdempotencyScope
    The first `IdempotencyScope` to compare.
    right: IdempotencyScope
    The second `IdempotencyScope` to compare.

    Returns: `true` if `left` is greater than `right`; otherwise, `false`.

  • methodoperator >=
    public static bool operator >=(IdempotencyScope left, IdempotencyScope right)

    Determines whether a specified `IdempotencyScope` is greater than or equal to another specified `IdempotencyScope`.

    left: IdempotencyScope
    The first `IdempotencyScope` to compare.
    right: IdempotencyScope
    The second `IdempotencyScope` to compare.

    Returns: `true` if `left` is greater than or equal to `right`; otherwise, `false`.

  • propertyValue
    public string Value { get; }

    Gets the underlying string value representing the scope.

  • fieldDefault
    public static readonly IdempotencyScope Default

    Gets the default fallback scope used when no specific scope is supplied.

enum

IdempotencyStatus

Assembly: EricksonLopez.Idempotency.Abstractions
public enum IdempotencyStatus : byte

Defines the lifecycle execution state of an idempotency record.

Members (3)

  • fieldCompleted
    Completed = 2

    Specifies that the operation was completed successfully and the result payload is immutable and cached.

  • fieldFailed
    Failed = 3

    Specifies that the operation failed during execution and may be eligible for retry depending on policy.

  • fieldProcessing
    Processing = 1

    Specifies that the operation is currently being executed under an active lease.

class

MemoryFallbackCache

Assembly: EricksonLopez.Idempotency
public sealed class MemoryFallbackCache : IFallbackCache
Implements: IFallbackCache

Provides a high-performance, thread-safe, memory-bounded fallback cache implementing `IFallbackCache` using `ConcurrentDictionary<TKey, TValue>` with TTL eviction and capacity controls.

Members (8)

  • constructorMemoryFallbackCache
    public MemoryFallbackCache(IOptions<IdempotencyOptions> options, TimeProvider? timeProvider = null)

    Initializes a new instance of the `MemoryFallbackCache` class from configured options.

    options: IOptions<IdempotencyOptions>
    The idempotency options accessor.
    timeProvider: TimeProvider?
    The optional time provider.
  • constructorMemoryFallbackCache
    public MemoryFallbackCache(TimeProvider? timeProvider = null, int maxCapacity = 10_000)

    Initializes a new instance of the `MemoryFallbackCache` class with explicit capacity and time provider.

    timeProvider: TimeProvider?
    The time provider for deterministic time computation.
    maxCapacity: int
    The maximum capacity before pruning oldest entries.
  • methodClear
    public void Clear()

    Clears all entries from the fallback cache.

  • methodRelease
    public void Release(string key, Guid ownerToken)

    Releases an acquired in-flight lease if the owner token matches.

    key: string
    The idempotency cache key.
    ownerToken: Guid
    The lease owner token.
  • methodRemove
    public void Remove(string key)

    Removes an entry from the fallback cache.

    key: string
    The idempotency cache key.
  • methodSet
    public void Set(string key, FallbackCacheEntry entry, TimeSpan retentionDuration)

    Stores or updates an idempotency response entry in the fallback cache.

    key: string
    The idempotency cache key.
    entry: FallbackCacheEntry
    The response entry to cache.
    retentionDuration: TimeSpan
    The retention duration before eviction.
  • methodTryAcquire
    public bool TryAcquire(string key, string fingerprint, TimeSpan leaseDuration, out Guid ownerToken)

    Attempts to acquire an in-flight lease in the fallback cache.

    key: string
    The idempotency cache key.
    fingerprint: string
    The cryptographic fingerprint of the request.
    leaseDuration: TimeSpan
    The lease duration.
    ownerToken: out Guid
    When successful, contains the unique token for the lease owner.

    Returns: `true` if the lease was acquired; otherwise, `false`.

  • methodTryGet
    public bool TryGet(string key, out FallbackCacheEntry? entry)

    Attempts to retrieve a completed idempotency response entry from the fallback cache.

    key: string
    The idempotency cache key.
    entry: out FallbackCacheEntry?
    When this method returns, contains the cached entry if found and unexpired; otherwise, null.

    Returns: `true` if an unexpired entry was found; otherwise, `false`.

class

ScopeHasher

Assembly: EricksonLopez.Idempotency.Abstractions
public static class ScopeHasher

Provides deterministic hashing and normalization utilities for idempotency scopes.

Members (2)

  • methodNormalize
    public static string Normalize(string rawScope)

    Normalizes a scope string, deterministically hashing it with SHA-256 into a lowercase 64-character hexadecimal representation if its length exceeds `MaxScopeLength`.

    rawScope: string
    The raw scope string to normalize.

    Returns: The original `rawScope` if its length is less than or equal to 64; otherwise, a deterministic 64-character lowercase hexadecimal SHA-256 hash.

    Exceptions: ArgumentException: `rawScope` is `null`, empty, or whitespace

  • fieldMaxScopeLength
    public const int MaxScopeLength

    Specifies the maximum allowed character length for an idempotency scope (64 characters).

class

ServiceCollectionExtensions

Assembly: EricksonLopez.Idempotency
public static class ServiceCollectionExtensions

Provides extension methods for `IServiceCollection` to configure core idempotency services.

Members (2)

  • methodAddIdempotencyCleanupService
    public static IServiceCollection AddIdempotencyCleanupService(this IServiceCollection services, Action<IdempotencyCleanupOptions>? configure = null)

    Registers a hosted background service that periodically purges expired idempotency records from the store.

    services: this IServiceCollection
    The `IServiceCollection` to add the service to.
    configure: Action<IdempotencyCleanupOptions>?
    An optional delegate to configure `IdempotencyCleanupOptions`.

    Returns: The same service collection instance for method chaining.

    This service must be registered alongside a concrete `IIdempotencyStore` implementation. Calling this method without a registered store will cause a startup exception. The cleanup service is entirely opt-in and is NOT registered by `AddIdempotencyCore`. Exceptions: ArgumentNullException: `services` is `null` Example:

    services.AddSingleton(_ => NpgsqlDataSource.Create("Host=localhost;Database=app;Username=postgres;Password=secret"));
    services.AddIdempotencyCore(options =>
    {
        options.DefaultLeaseDuration = TimeSpan.FromSeconds(30);
        options.DefaultRetentionDuration = TimeSpan.FromDays(7);
    });
    services.AddPostgreSqlIdempotencyStore();
    services.AddIdempotencyCleanupService(cleanup =>
    {
        cleanup.Interval = TimeSpan.FromHours(6);
        cleanup.BatchSize = 500;
    });
  • methodAddIdempotencyCore
    public static IServiceCollection AddIdempotencyCore(this IServiceCollection services, Action<IdempotencyOptions>? configure = null)

    Registers core idempotency abstractions, context accessors, serializers, and execution engines in the specified service collection.

    services: this IServiceCollection
    The `IServiceCollection` to add the services to.
    configure: Action<IdempotencyOptions>?
    An optional delegate to configure `IdempotencyOptions`.

    Returns: The same service collection instance for method chaining.

enum

StoreFailureMode

Assembly: EricksonLopez.Idempotency.Abstractions
public enum StoreFailureMode

Specifies the failure handling strategy when the persistent idempotency store encounters an infrastructure failure.

Members (3)

  • fieldFailClosedGraceful
    FailClosedGraceful = 0

    Strict financial mode: returns HTTP 503 Service Unavailable with RFC 7807 ProblemDetails and Retry-After. Prevents duplicate execution during database downtime. (Default)

  • fieldFailOpenWithAudit
    FailOpenWithAudit = 1

    Permissive mode for non-critical endpoints: bypasses idempotency caching and executes handler unkeyed. Emits OpenTelemetry warnings.

  • fieldFallbackCache
    FallbackCache = 2

    High-resilience fallback cache mode: utilizes an in-memory cache to replay responses and maintain idempotency during persistent storage outages.

class

StoreResilienceOptions

Assembly: EricksonLopez.Idempotency.Abstractions
public sealed class StoreResilienceOptions

Configures resilience policies and failover behaviors for storage operations.

Members (6)

  • propertyDefaultInFlightRetryAfterSeconds
    public int DefaultInFlightRetryAfterSeconds { get; set; }

    Gets or sets the base number of seconds for the Retry-After header on 409 in-flight conflicts. Defaults to 2 seconds.

  • propertyEnableFallbackCache
    public bool EnableFallbackCache { get; set; }

    Gets or sets a value indicating whether in-memory fallback cache is enabled for resilient replay during store outages. Defaults to `true`.

  • propertyFallbackCacheRetention
    public TimeSpan FallbackCacheRetention { get; set; }

    Gets or sets the retention duration for entries stored in the fallback cache. Defaults to 24 hours.

  • propertyMaxFallbackCacheEntries
    public int MaxFallbackCacheEntries { get; set; }

    Gets or sets the maximum number of entries maintained in the fallback cache. Defaults to 10,000.

  • propertyMode
    public StoreFailureMode Mode { get; set; }

    Gets or sets the failure mode when storage operations fail due to infrastructure errors. Defaults to `StoreFailureMode.FailClosedGraceful`.

  • propertyStoreUnavailableRetryAfterSeconds
    public int StoreUnavailableRetryAfterSeconds { get; set; }

    Gets or sets the base number of seconds for the Retry-After header when the store is unavailable. Defaults to 5 seconds.

class

SystemTextJsonIdempotencySerializer

Assembly: EricksonLopez.Idempotency
public sealed class SystemTextJsonIdempotencySerializer : IIdempotencySerializer
Implements: IIdempotencySerializer

Provides a Native AOT compatible implementation of `IIdempotencySerializer` using `Text.Json`.

Members (4)

  • constructorSystemTextJsonIdempotencySerializer
    public SystemTextJsonIdempotencySerializer()

    Initializes a new instance of the `SystemTextJsonIdempotencySerializer` class using default serializer options.

  • constructorSystemTextJsonIdempotencySerializer
    public SystemTextJsonIdempotencySerializer(JsonSerializerOptions options)

    Initializes a new instance of the `SystemTextJsonIdempotencySerializer` class with custom options.

    options: JsonSerializerOptions
    The custom serializer options.

    Exceptions: ArgumentNullException: `options` is `null`

  • methodDeserialize<T>
    public T? Deserialize<T>(ReadOnlyMemory<byte> bytes)

    Deserializes a raw byte payload into an instance of `T`.

    bytes: ReadOnlyMemory<byte>
    The memory buffer containing the serialized payload bytes.

    Returns: The deserialized object instance, or `null` if deserialization produces no value.

    Type parameters: T: The target deserialization type.

  • methodSerialize<T>
    public byte[] Serialize<T>(T value)

    Serializes an object value into a raw UTF-8 byte array.

    value: T
    The value to serialize.

    Returns: A byte array containing the serialized representation.

    Type parameters: T: The type of the value to serialize.

EricksonLopez.Idempotency.AspNetCore#

5
class

AspNetCoreServiceCollectionExtensions

Assembly: EricksonLopez.Idempotency.AspNetCore
public static class AspNetCoreServiceCollectionExtensions

Provides extension methods for `IServiceCollection`, `IApplicationBuilder`, and endpoint route builders to configure ASP.NET Core idempotency.

Members (4)

  • methodAddAspNetCoreIdempotency
    public static IServiceCollection AddAspNetCoreIdempotency(this IServiceCollection services, Action<IdempotencyOptions>? configure = null)

    Registers ASP.NET Core endpoint filters, middleware dependencies, and core idempotency services in the specified service collection.

    services: this IServiceCollection
    The `IServiceCollection` to add services to.
    configure: Action<IdempotencyOptions>?
    An optional delegate to configure `IdempotencyOptions`.

    Returns: The same service collection instance for method chaining.

  • methodUseIdempotency
    public static IApplicationBuilder UseIdempotency(this IApplicationBuilder app)

    Enables the idempotency middleware in the ASP.NET Core HTTP request pipeline.

    app: this IApplicationBuilder
    The `IApplicationBuilder` to configure.

    Returns: The same application builder instance for method chaining.

    Exceptions: ArgumentNullException: `app` is `null`

  • methodWithIdempotency
    public static RouteGroupBuilder WithIdempotency(this RouteGroupBuilder builder)

    Adds idempotency enforcement filter to a mapped route group.

    builder: this RouteGroupBuilder
    The `RouteGroupBuilder` to configure.

    Returns: The same route group builder instance for method chaining.

    Exceptions: ArgumentNullException: `builder` is `null`

  • methodWithIdempotency
    public static RouteHandlerBuilder WithIdempotency(this RouteHandlerBuilder builder)

    Adds idempotency enforcement filter to a mapped route endpoint.

    builder: this RouteHandlerBuilder
    The `RouteHandlerBuilder` to configure.

    Returns: The same route handler builder instance for method chaining.

    Exceptions: ArgumentNullException: `builder` is `null`

class

IdempotencyMiddleware

Assembly: EricksonLopez.Idempotency.AspNetCore
public sealed class IdempotencyMiddleware

Provides ASP.NET Core middleware that intercepts incoming HTTP requests to enforce idempotency semantics by delegating execution, state machine transitions, locking, and replay handling to `IdempotencyEngine`.

Members (2)

  • constructorIdempotencyMiddleware
    public IdempotencyMiddleware(RequestDelegate next)

    Initializes a new instance of the `IdempotencyMiddleware` class with the specified next request delegate.

    next: RequestDelegate
    The next middleware delegate in the HTTP execution pipeline.

    Exceptions: ArgumentNullException: `next` is `null`

  • methodInvokeAsync
    public async Task InvokeAsync(HttpContext context, IIdempotencyStore store, Microsoft.Extensions.Options.IOptions<IdempotencyOptions> optionsAccessor, IIdempotencyContextAccessor? contextAccessor = null, IIdempotencyFingerprintGenerator? fingerprintGenerator = null, IIdempotencyKeyProvider<HttpContext>? keyProvider = null, IdempotencyEngine? engine = null, IFallbackCache? fallbackCache = null)

    Intercepts and processes the HTTP request to ensure idempotent execution.

    context: HttpContext
    The `HttpContext` for the current request.
    store: IIdempotencyStore
    The persistence store for recording idempotency state.
    optionsAccessor: Microsoft.Extensions.Options.IOptions<IdempotencyOptions>
    The idempotency configuration options accessor.
    contextAccessor: IIdempotencyContextAccessor?
    The optional idempotency ambient execution context accessor.
    fingerprintGenerator: IIdempotencyFingerprintGenerator?
    The optional SPI fingerprint generator.
    keyProvider: IIdempotencyKeyProvider<HttpContext>?
    The optional SPI idempotency key provider.
    engine: IdempotencyEngine?
    The optional idempotency execution engine.
    fallbackCache: IFallbackCache?
    The optional fallback cache for store failure resilience.

    Returns: A task representing the asynchronous operation.

class

IdempotencyOptionsAspNetCoreExtensions

Assembly: EricksonLopez.Idempotency.AspNetCore
public static class IdempotencyOptionsAspNetCoreExtensions

Provides ASP.NET Core specific extension methods for configuring `IdempotencyOptions`.

Members (1)

  • methodUseTenantIdExtractor
    public static IdempotencyOptions UseTenantIdExtractor(this IdempotencyOptions options, Func<HttpContext, Guid> extractor)

    Configures a typed `HttpContext` extractor delegate for resolving tenant identifiers.

    options: this IdempotencyOptions
    The idempotency options instance.
    extractor: Func<HttpContext, Guid>
    The delegate that resolves a `Guid` tenant identifier from the current `HttpContext`.

    Returns: The same `IdempotencyOptions` instance for chaining.

    Exceptions: ArgumentNullException: `options` or `extractor` is `null`

class

IdempotentAttribute

Assembly: EricksonLopez.Idempotency.AspNetCore
public sealed class IdempotentAttribute : Attribute
Inherits: Attribute

Specifies that an endpoint or controller action requires idempotency enforcement.

Members (5)

  • propertyEnabled
    public bool Enabled { get; set; }

    Gets or sets a value indicating whether idempotency enforcement is active for this endpoint.

    Set to `false` to opt a specific endpoint out of idempotency enforcement even when the middleware or filter is globally registered. This is useful for endpoints that are individually decorated with `IdempotentAttribute` but belong to a group with idempotency configured at the group level.

  • propertyLeaseDurationSeconds
    public int LeaseDurationSeconds { get; set; }

    Gets or sets the duration in seconds for which the in-flight execution lease is held before it may be reclaimed.

  • propertyRequired
    public bool Required { get; set; }

    Gets or sets a value indicating whether the idempotency key header is strictly required.

    When `true` (the default), requests without the idempotency key header will receive an HTTP 400 Bad Request response. When `false`, requests without the header are processed normally without idempotency enforcement.

  • propertyRetentionDurationDays
    public int RetentionDurationDays { get; set; }

    Gets or sets the number of days for which completed idempotency records are retained before becoming eligible for cleanup.

  • propertyScope
    public string? Scope { get; set; }

    Gets or sets a custom scope identifier that overrides the default request path scope for idempotency key isolation.

    When `null`, the request path is used as the scope.

class

IdempotentEndpointFilter

Assembly: EricksonLopez.Idempotency.AspNetCore
public sealed class IdempotentEndpointFilter : IEndpointFilter
Implements: IEndpointFilter

Provides an endpoint filter that guards ASP.NET Core Minimal API endpoints with idempotency guarantees by delegating execution, state machine transitions, locking, and replay handling to `IdempotencyEngine`.

Members (3)

  • constructorIdempotentEndpointFilter
    public IdempotentEndpointFilter(IIdempotencyStore store, IdempotencyOptions options, IIdempotencyContextAccessor? contextAccessor = null, IIdempotencyFingerprintGenerator? fingerprintGenerator = null, IIdempotencyKeyProvider<HttpContext>? keyProvider = null, IdempotencyEngine? engine = null)

    Initializes a new instance of the `IdempotentEndpointFilter` class with the specified store, options, and optional dependencies.

    store: IIdempotencyStore
    The persistence store for recording idempotency state.
    options: IdempotencyOptions
    The idempotency configuration options.
    contextAccessor: IIdempotencyContextAccessor?
    The optional ambient execution context accessor.
    fingerprintGenerator: IIdempotencyFingerprintGenerator?
    The optional fingerprint generator SPI.
    keyProvider: IIdempotencyKeyProvider<HttpContext>?
    The optional idempotency key provider SPI.
    engine: IdempotencyEngine?
    The optional idempotency execution engine.

    Exceptions: ArgumentNullException: `store` or `options` is `null`

  • constructorIdempotentEndpointFilter
    public IdempotentEndpointFilter(IdempotencyEngine engine, IdempotencyOptions options, IIdempotencyFingerprintGenerator fingerprintGenerator, IIdempotencyKeyProvider<HttpContext>? keyProvider = null)

    Initializes a new instance of the `IdempotentEndpointFilter` class with the specified engine, options, fingerprint generator, and optional key provider.

    engine: IdempotencyEngine
    The idempotency execution engine.
    options: IdempotencyOptions
    The idempotency configuration options.
    fingerprintGenerator: IIdempotencyFingerprintGenerator
    The fingerprint generator SPI.
    keyProvider: IIdempotencyKeyProvider<HttpContext>?
    The optional idempotency key provider SPI.
  • methodInvokeAsync
    public async ValueTask<object?> InvokeAsync(EndpointFilterInvocationContext context, EndpointFilterDelegate next)

    Inherits documentation from base type or interface.

    context: EndpointFilterInvocationContext
    next: EndpointFilterDelegate

EricksonLopez.Idempotency.Exceptions#

5
class

IdempotencyConflictException

Assembly: EricksonLopez.Idempotency.Abstractions
public sealed class IdempotencyConflictException : IdempotencyException
Inherits: IdempotencyException

Represents an exception thrown when an in-flight execution conflict occurs because an identical operation is actively executing.

Members (2)

  • constructorIdempotencyConflictException
    public IdempotencyConflictException(string key)

    Initializes a new instance of the `IdempotencyConflictException` class with the specified conflicting idempotency key.

    key: string
    The conflicting idempotency key.
  • propertyKey
    public string Key { get; }

    Gets the conflicting idempotency key.

class

IdempotencyException

Assembly: EricksonLopez.Idempotency.Abstractions
public class IdempotencyException : Exception
Inherits: Exception

Represents the base exception for errors originating within the idempotency framework.

Members (3)

  • constructorIdempotencyException
    public IdempotencyException()

    Initializes a new instance of the `IdempotencyException` class.

  • constructorIdempotencyException
    public IdempotencyException(string message)

    Initializes a new instance of the `IdempotencyException` class with a specified error message.

    message: string
    The message that describes the error.
  • constructorIdempotencyException
    public IdempotencyException(string message, Exception innerException)

    Initializes a new instance of the `IdempotencyException` class with a specified error message and inner exception.

    message: string
    The message that describes the error.
    innerException: Exception
    The exception that is the cause of the current exception.
class

IdempotencyFingerprintMismatchException

Assembly: EricksonLopez.Idempotency.Abstractions
public sealed class IdempotencyFingerprintMismatchException : IdempotencyException
Inherits: IdempotencyException

Represents an exception thrown when an idempotency key is reused with a different request payload or cryptographic fingerprint.

Members (4)

  • constructorIdempotencyFingerprintMismatchException
    public IdempotencyFingerprintMismatchException(string key, string? expectedFingerprint, string? actualFingerprint)

    Initializes a new instance of the `IdempotencyFingerprintMismatchException` class with the specified key, expected fingerprint, and actual fingerprint.

    key: string
    The idempotency key.
    expectedFingerprint: string?
    The recorded fingerprint.
    actualFingerprint: string?
    The current request fingerprint.
  • propertyActualFingerprint
    public string? ActualFingerprint { get; }

    Gets the fingerprint generated for the incoming request.

  • propertyExpectedFingerprint
    public string? ExpectedFingerprint { get; }

    Gets the original recorded fingerprint.

  • propertyKey
    public string Key { get; }

    Gets the reused idempotency key.

class

IdempotencyLeaseExpiredException

Assembly: EricksonLopez.Idempotency.Abstractions
public sealed class IdempotencyLeaseExpiredException : IdempotencyException
Inherits: IdempotencyException

Represents an exception thrown when an operation discovers its ownership lease has expired and could not be finalized.

Remarks:

In the default execution pipeline, `IdempotencyEngine` logs lease expiration without throwing to avoid masking domain operation success. Custom stores, distributed locking wrappers, or manual lease coordinators may throw this exception when strict lease fencing is enforced.

Members (2)

  • constructorIdempotencyLeaseExpiredException
    public IdempotencyLeaseExpiredException(string key)

    Initializes a new instance of the `IdempotencyLeaseExpiredException` class with the specified idempotency key.

    key: string
    The idempotency key.
  • propertyKey
    public string Key { get; }

    Gets the idempotency key whose lease expired.

class

IdempotencyTransientException

Assembly: EricksonLopez.Idempotency.Abstractions
public class IdempotencyTransientException : IdempotencyException
Inherits: IdempotencyException

Exception thrown when a transient, retriable error (such as a database deadlock or timeout) occurs during idempotency operations.

Members (3)

  • constructorIdempotencyTransientException
    public IdempotencyTransientException()

    Initializes a new instance of the `IdempotencyTransientException` class.

  • constructorIdempotencyTransientException
    public IdempotencyTransientException(string message)

    Initializes a new instance of the `IdempotencyTransientException` class with a specified message.

    message: string
    The message that describes the error.
  • constructorIdempotencyTransientException
    public IdempotencyTransientException(string message, Exception innerException)

    Initializes a new instance of the `IdempotencyTransientException` class with a specified message and inner exception.

    message: string
    The message that describes the error.
    innerException: Exception
    The inner exception that caused this exception.

EricksonLopez.Idempotency.MariaDb#

3
class

MariaDbIdempotencyStore

Assembly: EricksonLopez.Idempotency.MariaDb
public sealed class MariaDbIdempotencyStore : ITransactionalIdempotencyStore
Implements: ITransactionalIdempotencyStore

Provides a MariaDB persistence store implementation for `IIdempotencyStore` and `ITransactionalIdempotencyStore` using `MySqlDataSource` and pure ADO.NET.

Members (9)

  • constructorMariaDbIdempotencyStore
    public MariaDbIdempotencyStore(MySqlDataSource dataSource, IdempotencyOptions? options)

    Initializes a new instance of the `MariaDbIdempotencyStore` class with the specified data source and options.

    dataSource: MySqlDataSource
    The configured MySQL/MariaDB data source.
    options: IdempotencyOptions?
    The idempotency options.
  • constructorMariaDbIdempotencyStore
    public MariaDbIdempotencyStore(MySqlDataSource dataSource, TimeSpan? commandTimeout = null)

    Initializes a new instance of the `MariaDbIdempotencyStore` class with the specified MySQL or MariaDB data source and optional command timeout.

    dataSource: MySqlDataSource
    The configured MySQL/MariaDB data source.
    commandTimeout: TimeSpan?
    Optional command timeout for database commands. Defaults to 10 seconds.

    Exceptions: ArgumentNullException: `dataSource` is `null`

  • methodCleanupExpiredRecordsAsync
    public async Task<int> CleanupExpiredRecordsAsync(DateTimeOffset utcNow, int batchSize, CancellationToken cancellationToken = default)

    Inherits documentation from base type or interface.

    utcNow: DateTimeOffset
    batchSize: int
    cancellationToken: CancellationToken
  • methodMarkCompletedAsync
    public async Task<bool> MarkCompletedAsync(Guid tenantId, string scope, IdempotencyKey key, Guid ownerToken, int concurrencyVersion, int statusCode, IReadOnlyDictionary<string, string[]> headers, ReadOnlyMemory<byte> responseBody, TimeSpan retentionDuration, CancellationToken cancellationToken = default)

    Inherits documentation from base type or interface.

    tenantId: Guid
    scope: string
    key: IdempotencyKey
    ownerToken: Guid
    concurrencyVersion: int
    statusCode: int
    headers: IReadOnlyDictionary<string, string[]>
    responseBody: ReadOnlyMemory<byte>
    retentionDuration: TimeSpan
    cancellationToken: CancellationToken
  • methodMarkCompletedAsync
    public Task<bool> MarkCompletedAsync(Guid tenantId, string scope, IdempotencyKey key, Guid ownerToken, int concurrencyVersion, int statusCode, IReadOnlyDictionary<string, string[]> headers, ReadOnlyMemory<byte> responseBody, TimeSpan retentionDuration, IDbConnection connection, IDbTransaction? transaction, CancellationToken cancellationToken = default)

    Atomically marks an in-flight idempotency record as completed within the provided database transaction, storing the produced response payload.

    tenantId: Guid
    The unique identifier of the tenant.
    scope: string
    The functional scope of the operation.
    key: IdempotencyKey
    The idempotency key.
    ownerToken: Guid
    The ownership token issued during key acquisition.
    concurrencyVersion: int
    The concurrency version issued during key acquisition.
    statusCode: int
    The HTTP or logical status code to cache.
    headers: IReadOnlyDictionary<string, string[]>
    The response headers to cache.
    responseBody: ReadOnlyMemory<byte>
    The serialized response body bytes to cache.
    retentionDuration: TimeSpan
    The retention duration for the completed record.
    connection: IDbConnection
    An existing open `IDbConnection` to use. Must not be `null`. The store will use this connection without opening a new one.
    transaction: IDbTransaction?
    An optional active `IDbTransaction` the operation should participate in. If `null`, the operation runs without a transaction but still uses the provided connection.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A task representing the asynchronous operation. The task result contains `true` if the record was successfully updated; otherwise, `false` (fencing token mismatch or owner mismatch).

  • methodMarkFailedAsync
    public async Task<bool> MarkFailedAsync(Guid tenantId, string scope, IdempotencyKey key, Guid ownerToken, int concurrencyVersion, CancellationToken cancellationToken = default)

    Inherits documentation from base type or interface.

    tenantId: Guid
    scope: string
    key: IdempotencyKey
    ownerToken: Guid
    concurrencyVersion: int
    cancellationToken: CancellationToken
  • methodMarkFailedAsync
    public Task<bool> MarkFailedAsync(Guid tenantId, string scope, IdempotencyKey key, Guid ownerToken, int concurrencyVersion, IDbConnection connection, IDbTransaction? transaction, CancellationToken cancellationToken = default)

    Atomically marks an in-flight idempotency record as failed within the provided database transaction, enabling subsequent retries depending on policy.

    tenantId: Guid
    The unique identifier of the tenant.
    scope: string
    The functional scope of the operation.
    key: IdempotencyKey
    The idempotency key.
    ownerToken: Guid
    The ownership token issued during key acquisition.
    concurrencyVersion: int
    The concurrency version issued during key acquisition.
    connection: IDbConnection
    An existing open `IDbConnection` to use. Must not be `null`.
    transaction: IDbTransaction?
    An optional active `IDbTransaction` the operation should participate in. If `null`, the operation runs without a transaction but still uses the provided connection.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A task representing the asynchronous operation. The task result contains `true` if the record was successfully marked as failed; otherwise, `false`.

  • methodTryAcquireAsync
    public async Task<IdempotencyClaimResult> TryAcquireAsync(Guid tenantId, string scope, IdempotencyKey key, string fingerprint, TimeSpan leaseDuration, TimeSpan retentionDuration, CancellationToken cancellationToken = default)

    Inherits documentation from base type or interface.

    tenantId: Guid
    scope: string
    key: IdempotencyKey
    fingerprint: string
    leaseDuration: TimeSpan
    retentionDuration: TimeSpan
    cancellationToken: CancellationToken
  • methodTryAcquireAsync
    public Task<IdempotencyClaimResult> TryAcquireAsync(Guid tenantId, string scope, IdempotencyKey key, string fingerprint, TimeSpan leaseDuration, TimeSpan retentionDuration, IDbConnection connection, IDbTransaction? transaction, CancellationToken cancellationToken = default)

    Attempts to acquire exclusive execution ownership for an idempotency key within the specified database transaction.

    tenantId: Guid
    The unique identifier of the tenant.
    scope: string
    The functional scope or partition of the operation.
    key: IdempotencyKey
    The unique idempotency key.
    fingerprint: string
    The cryptographic fingerprint representing the canonical request.
    leaseDuration: TimeSpan
    The duration for which the ownership lease remains valid before considering it stale.
    retentionDuration: TimeSpan
    The retention period for retaining completed records.
    connection: IDbConnection
    An existing open database connection to use.
    transaction: IDbTransaction?
    An optional active database transaction to participate in.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A task representing the asynchronous operation. The task result contains the `IdempotencyClaimResult` indicating whether ownership was acquired, if a cached response is available for replay, or if a conflict occurred.

class

MariaDbScripts

Assembly: EricksonLopez.Idempotency.MariaDb
public static class MariaDbScripts

Provides raw SQL script definitions for MariaDB schema generation and indexes.

Members (1)

  • fieldCreateTableScript
    public const string CreateTableScript

    Gets the DDL script for creating the idempotency records table and associated indexes in MariaDB.

class

MariaDbServiceCollectionExtensions

Assembly: EricksonLopez.Idempotency.MariaDb
public static class MariaDbServiceCollectionExtensions

Provides extension methods for `IServiceCollection` to register MariaDB idempotency persistence store.

Members (1)

  • methodAddMariaDbIdempotencyStore
    public static IServiceCollection AddMariaDbIdempotencyStore(this IServiceCollection services)

    Registers the MariaDB implementation of `IIdempotencyStore` and `ITransactionalIdempotencyStore` in the specified service collection.

    services: this IServiceCollection
    The `IServiceCollection` to add the store to.

    Returns: The same service collection instance for method chaining.

    Exceptions: ArgumentNullException: `services` is `null`

EricksonLopez.Idempotency.Mediator#

3
interface

IIdempotentRequest

Assembly: EricksonLopez.Idempotency.Mediator
public interface IIdempotentRequest

Defines a contract for requests in the Mediator pipeline that require deterministic idempotency enforcement.

Members (4)

  • propertyAuthenticatedSubject
    string? AuthenticatedSubject { get; }

    Gets the authenticated subject or user identifier for this request, if any. Enables strict user-level cryptographic partitioning and cross-user replay prevention.

  • propertyIdempotencyKey
    IdempotencyKey IdempotencyKey { get; }

    Gets the unique idempotency key associated with this request.

  • propertyScope
    string? Scope { get; }

    Gets the optional custom functional scope identifying this request partition. If `null` or unassigned, the scope defaults to the command type's full name.

  • propertyTenantId
    Guid TenantId { get; }

    Gets the tenant identifier for this request.

    In multi-tenant systems, this returns the current tenant's `Guid`. In single-tenant systems, returns `Guid.Empty`. The tenant identifier is included in the idempotency composite key `(TenantId, Scope, Key)` to guarantee per-tenant isolation of idempotency records.

class

IdempotencyPipelineBehavior<TRequest, TResponse>

Assembly: EricksonLopez.Idempotency.Mediator
public sealed class IdempotencyPipelineBehavior<TRequest, TResponse> : IPipelineBehavior<TRequest, TResponse>
Implements: IPipelineBehavior<TRequest, TResponse>

Provides a pipeline behavior for `EricksonLopez.Mediator` that enforces idempotency semantics on commands implementing `IIdempotentRequest` by delegating execution, state machine transitions, locking, and replay handling to `IdempotencyEngine`.

Remarks:

Type parameters: TRequest: The type of request being handled.; TResponse: The type of response yielded by the pipeline.

Members (3)

  • constructorIdempotencyPipelineBehavior
    public IdempotencyPipelineBehavior(IIdempotencyStore store, IIdempotencySerializer serializer, IIdempotencyPolicy policy, IIdempotencyContextAccessor? contextAccessor = null)

    Initializes a new instance of the `IdempotencyPipelineBehavior<TRequest, TResponse>` class with the specified store, serializer, policy, and optional context accessor.

    store: IIdempotencyStore
    The persistence store for recording idempotency state.
    serializer: IIdempotencySerializer
    The serializer used for response caching.
    policy: IIdempotencyPolicy
    The evaluation policy determining lease and retention rules.
    contextAccessor: IIdempotencyContextAccessor?
    The optional idempotency ambient execution context accessor.

    Exceptions: ArgumentNullException: `store`, `serializer`, or `policy` is `null`

  • constructorIdempotencyPipelineBehavior
    public IdempotencyPipelineBehavior(IdempotencyEngine engine, IIdempotencySerializer serializer, IIdempotencyFingerprintGenerator? fingerprintGenerator = null, IIdempotencyStore? store = null, IIdempotencyPolicy? policy = null, IIdempotencyContextAccessor? contextAccessor = null)

    Initializes a new instance of the `IdempotencyPipelineBehavior<TRequest, TResponse>` class with the specified engine, serializer, and fingerprint generator.

    engine: IdempotencyEngine
    The core idempotency engine.
    serializer: IIdempotencySerializer
    The serializer used for payload and response serialization.
    fingerprintGenerator: IIdempotencyFingerprintGenerator?
    The optional fingerprint generator SPI.
    store: IIdempotencyStore?
    The optional persistence store.
    policy: IIdempotencyPolicy?
    The optional evaluation policy.
    contextAccessor: IIdempotencyContextAccessor?
    The optional context accessor.

    Exceptions: ArgumentNullException: `engine` or `serializer` is `null`

  • methodHandle<TNext>
    public async ValueTask<TResponse> Handle<TNext>(TRequest request, TNext next, CancellationToken cancellationToken) where TNext : struct, INext<TResponse>

    Inherits documentation from base type or interface.

    request: TRequest
    next: TNext
    cancellationToken: CancellationToken
class

MediatorServiceCollectionExtensions

Assembly: EricksonLopez.Idempotency.Mediator
public static class MediatorServiceCollectionExtensions

Provides extension methods for `IServiceCollection` to register Mediator idempotency pipeline behaviors.

Members (1)

  • methodAddMediatorIdempotency
    public static IServiceCollection AddMediatorIdempotency(this IServiceCollection services)

    Registers the open generic `IdempotencyPipelineBehavior<TRequest, TResponse>` and core idempotency dependencies in the specified service collection.

    services: this IServiceCollection
    The `IServiceCollection` to add services to.

    Returns: The same service collection instance for method chaining.

    Exceptions: ArgumentNullException: `services` is `null`

EricksonLopez.Idempotency.MySql#

3
class

MySqlIdempotencyStore

Assembly: EricksonLopez.Idempotency.MySql
public sealed class MySqlIdempotencyStore : ITransactionalIdempotencyStore
Implements: ITransactionalIdempotencyStore

Provides a MySQL persistence store implementation for `IIdempotencyStore` and `ITransactionalIdempotencyStore` using `MySqlDataSource` and pure ADO.NET.

Members (9)

  • constructorMySqlIdempotencyStore
    public MySqlIdempotencyStore(MySqlDataSource dataSource, IdempotencyOptions? options)

    Initializes a new instance of the `MySqlIdempotencyStore` class from configured options.

    dataSource: MySqlDataSource
    The MySQL data source.
    options: IdempotencyOptions?
    The idempotency options.
  • constructorMySqlIdempotencyStore
    public MySqlIdempotencyStore(MySqlDataSource dataSource, TimeSpan? commandTimeout = null)

    Initializes a new instance of the `MySqlIdempotencyStore` class with the specified data source and optional command timeout.

    dataSource: MySqlDataSource
    The MySQL data source.
    commandTimeout: TimeSpan?
    The optional command timeout. Defaults to 10 seconds.
  • methodCleanupExpiredRecordsAsync
    public async Task<int> CleanupExpiredRecordsAsync(DateTimeOffset utcNow, int batchSize, CancellationToken cancellationToken = default)

    Inherits documentation from base type or interface.

    utcNow: DateTimeOffset
    batchSize: int
    cancellationToken: CancellationToken
  • methodMarkCompletedAsync
    public async Task<bool> MarkCompletedAsync(Guid tenantId, string scope, IdempotencyKey key, Guid ownerToken, int concurrencyVersion, int statusCode, IReadOnlyDictionary<string, string[]> headers, ReadOnlyMemory<byte> responseBody, TimeSpan retentionDuration, CancellationToken cancellationToken = default)

    Inherits documentation from base type or interface.

    tenantId: Guid
    scope: string
    key: IdempotencyKey
    ownerToken: Guid
    concurrencyVersion: int
    statusCode: int
    headers: IReadOnlyDictionary<string, string[]>
    responseBody: ReadOnlyMemory<byte>
    retentionDuration: TimeSpan
    cancellationToken: CancellationToken
  • methodMarkCompletedAsync
    public Task<bool> MarkCompletedAsync(Guid tenantId, string scope, IdempotencyKey key, Guid ownerToken, int concurrencyVersion, int statusCode, IReadOnlyDictionary<string, string[]> headers, ReadOnlyMemory<byte> responseBody, TimeSpan retentionDuration, IDbConnection connection, IDbTransaction? transaction, CancellationToken cancellationToken = default)

    Atomically marks an in-flight idempotency record as completed within the provided database transaction, storing the produced response payload.

    tenantId: Guid
    The unique identifier of the tenant.
    scope: string
    The functional scope of the operation.
    key: IdempotencyKey
    The idempotency key.
    ownerToken: Guid
    The ownership token issued during key acquisition.
    concurrencyVersion: int
    The concurrency version issued during key acquisition.
    statusCode: int
    The HTTP or logical status code to cache.
    headers: IReadOnlyDictionary<string, string[]>
    The response headers to cache.
    responseBody: ReadOnlyMemory<byte>
    The serialized response body bytes to cache.
    retentionDuration: TimeSpan
    The retention duration for the completed record.
    connection: IDbConnection
    An existing open `IDbConnection` to use. Must not be `null`. The store will use this connection without opening a new one.
    transaction: IDbTransaction?
    An optional active `IDbTransaction` the operation should participate in. If `null`, the operation runs without a transaction but still uses the provided connection.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A task representing the asynchronous operation. The task result contains `true` if the record was successfully updated; otherwise, `false` (fencing token mismatch or owner mismatch).

  • methodMarkFailedAsync
    public async Task<bool> MarkFailedAsync(Guid tenantId, string scope, IdempotencyKey key, Guid ownerToken, int concurrencyVersion, CancellationToken cancellationToken = default)

    Inherits documentation from base type or interface.

    tenantId: Guid
    scope: string
    key: IdempotencyKey
    ownerToken: Guid
    concurrencyVersion: int
    cancellationToken: CancellationToken
  • methodMarkFailedAsync
    public Task<bool> MarkFailedAsync(Guid tenantId, string scope, IdempotencyKey key, Guid ownerToken, int concurrencyVersion, IDbConnection connection, IDbTransaction? transaction, CancellationToken cancellationToken = default)

    Atomically marks an in-flight idempotency record as failed within the provided database transaction, enabling subsequent retries depending on policy.

    tenantId: Guid
    The unique identifier of the tenant.
    scope: string
    The functional scope of the operation.
    key: IdempotencyKey
    The idempotency key.
    ownerToken: Guid
    The ownership token issued during key acquisition.
    concurrencyVersion: int
    The concurrency version issued during key acquisition.
    connection: IDbConnection
    An existing open `IDbConnection` to use. Must not be `null`.
    transaction: IDbTransaction?
    An optional active `IDbTransaction` the operation should participate in. If `null`, the operation runs without a transaction but still uses the provided connection.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A task representing the asynchronous operation. The task result contains `true` if the record was successfully marked as failed; otherwise, `false`.

  • methodTryAcquireAsync
    public async Task<IdempotencyClaimResult> TryAcquireAsync(Guid tenantId, string scope, IdempotencyKey key, string fingerprint, TimeSpan leaseDuration, TimeSpan retentionDuration, CancellationToken cancellationToken = default)

    Inherits documentation from base type or interface.

    tenantId: Guid
    scope: string
    key: IdempotencyKey
    fingerprint: string
    leaseDuration: TimeSpan
    retentionDuration: TimeSpan
    cancellationToken: CancellationToken
  • methodTryAcquireAsync
    public Task<IdempotencyClaimResult> TryAcquireAsync(Guid tenantId, string scope, IdempotencyKey key, string fingerprint, TimeSpan leaseDuration, TimeSpan retentionDuration, IDbConnection connection, IDbTransaction? transaction, CancellationToken cancellationToken = default)

    Attempts to acquire exclusive execution ownership for an idempotency key within the specified database transaction.

    tenantId: Guid
    The unique identifier of the tenant.
    scope: string
    The functional scope or partition of the operation.
    key: IdempotencyKey
    The unique idempotency key.
    fingerprint: string
    The cryptographic fingerprint representing the canonical request.
    leaseDuration: TimeSpan
    The duration for which the ownership lease remains valid before considering it stale.
    retentionDuration: TimeSpan
    The retention period for retaining completed records.
    connection: IDbConnection
    An existing open database connection to use.
    transaction: IDbTransaction?
    An optional active database transaction to participate in.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A task representing the asynchronous operation. The task result contains the `IdempotencyClaimResult` indicating whether ownership was acquired, if a cached response is available for replay, or if a conflict occurred.

class

MySqlScripts

Assembly: EricksonLopez.Idempotency.MySql
public static class MySqlScripts

Provides raw SQL script definitions for MySQL schema generation and indexes.

Members (1)

  • fieldCreateTableScript
    public const string CreateTableScript

    Gets the DDL script for creating the idempotency records table and associated indexes in MySQL.

class

MySqlServiceCollectionExtensions

Assembly: EricksonLopez.Idempotency.MySql
public static class MySqlServiceCollectionExtensions

Provides extension methods for `IServiceCollection` to register MySQL idempotency persistence store.

Members (1)

  • methodAddMySqlIdempotencyStore
    public static IServiceCollection AddMySqlIdempotencyStore(this IServiceCollection services)

    Registers the MySQL implementation of `IIdempotencyStore` and `ITransactionalIdempotencyStore` in the specified service collection.

    services: this IServiceCollection
    The `IServiceCollection` to add the store to.

    Returns: The same service collection instance for method chaining.

    Exceptions: ArgumentNullException: `services` is `null`

EricksonLopez.Idempotency.Oracle#

3
class

OracleIdempotencyStore

Assembly: EricksonLopez.Idempotency.Oracle
public sealed class OracleIdempotencyStore : ITransactionalIdempotencyStore
Implements: ITransactionalIdempotencyStore

Provides an Oracle Database persistence store implementation for `IIdempotencyStore` and `ITransactionalIdempotencyStore` using pure ADO.NET and `OracleConnection`.

Members (9)

  • constructorOracleIdempotencyStore
    public OracleIdempotencyStore(string connectionString, IdempotencyOptions? options)

    Initializes a new instance of the `OracleIdempotencyStore` class with the specified connection string and options.

    connectionString: string
    The Oracle database connection string.
    options: IdempotencyOptions?
    The idempotency options.
  • constructorOracleIdempotencyStore
    public OracleIdempotencyStore(string connectionString, TimeSpan? commandTimeout = null)

    Initializes a new instance of the `OracleIdempotencyStore` class with the specified connection string and optional command timeout.

    connectionString: string
    The Oracle database connection string.
    commandTimeout: TimeSpan?
    Optional command timeout for database commands. Defaults to 10 seconds.

    Exceptions: ArgumentException: `connectionString` is `null`, empty, or consists only of white-space characters

  • methodCleanupExpiredRecordsAsync
    public async Task<int> CleanupExpiredRecordsAsync(DateTimeOffset utcNow, int batchSize, CancellationToken cancellationToken = default)

    Inherits documentation from base type or interface.

    utcNow: DateTimeOffset
    batchSize: int
    cancellationToken: CancellationToken
  • methodMarkCompletedAsync
    public async Task<bool> MarkCompletedAsync(Guid tenantId, string scope, IdempotencyKey key, Guid ownerToken, int concurrencyVersion, int statusCode, IReadOnlyDictionary<string, string[]> headers, ReadOnlyMemory<byte> responseBody, TimeSpan retentionDuration, CancellationToken cancellationToken = default)

    Inherits documentation from base type or interface.

    tenantId: Guid
    scope: string
    key: IdempotencyKey
    ownerToken: Guid
    concurrencyVersion: int
    statusCode: int
    headers: IReadOnlyDictionary<string, string[]>
    responseBody: ReadOnlyMemory<byte>
    retentionDuration: TimeSpan
    cancellationToken: CancellationToken
  • methodMarkCompletedAsync
    public Task<bool> MarkCompletedAsync(Guid tenantId, string scope, IdempotencyKey key, Guid ownerToken, int concurrencyVersion, int statusCode, IReadOnlyDictionary<string, string[]> headers, ReadOnlyMemory<byte> responseBody, TimeSpan retentionDuration, IDbConnection connection, IDbTransaction? transaction, CancellationToken cancellationToken = default)

    Atomically marks an in-flight idempotency record as completed within the provided database transaction, storing the produced response payload.

    tenantId: Guid
    The unique identifier of the tenant.
    scope: string
    The functional scope of the operation.
    key: IdempotencyKey
    The idempotency key.
    ownerToken: Guid
    The ownership token issued during key acquisition.
    concurrencyVersion: int
    The concurrency version issued during key acquisition.
    statusCode: int
    The HTTP or logical status code to cache.
    headers: IReadOnlyDictionary<string, string[]>
    The response headers to cache.
    responseBody: ReadOnlyMemory<byte>
    The serialized response body bytes to cache.
    retentionDuration: TimeSpan
    The retention duration for the completed record.
    connection: IDbConnection
    An existing open `IDbConnection` to use. Must not be `null`. The store will use this connection without opening a new one.
    transaction: IDbTransaction?
    An optional active `IDbTransaction` the operation should participate in. If `null`, the operation runs without a transaction but still uses the provided connection.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A task representing the asynchronous operation. The task result contains `true` if the record was successfully updated; otherwise, `false` (fencing token mismatch or owner mismatch).

  • methodMarkFailedAsync
    public async Task<bool> MarkFailedAsync(Guid tenantId, string scope, IdempotencyKey key, Guid ownerToken, int concurrencyVersion, CancellationToken cancellationToken = default)

    Inherits documentation from base type or interface.

    tenantId: Guid
    scope: string
    key: IdempotencyKey
    ownerToken: Guid
    concurrencyVersion: int
    cancellationToken: CancellationToken
  • methodMarkFailedAsync
    public Task<bool> MarkFailedAsync(Guid tenantId, string scope, IdempotencyKey key, Guid ownerToken, int concurrencyVersion, IDbConnection connection, IDbTransaction? transaction, CancellationToken cancellationToken = default)

    Atomically marks an in-flight idempotency record as failed within the provided database transaction, enabling subsequent retries depending on policy.

    tenantId: Guid
    The unique identifier of the tenant.
    scope: string
    The functional scope of the operation.
    key: IdempotencyKey
    The idempotency key.
    ownerToken: Guid
    The ownership token issued during key acquisition.
    concurrencyVersion: int
    The concurrency version issued during key acquisition.
    connection: IDbConnection
    An existing open `IDbConnection` to use. Must not be `null`.
    transaction: IDbTransaction?
    An optional active `IDbTransaction` the operation should participate in. If `null`, the operation runs without a transaction but still uses the provided connection.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A task representing the asynchronous operation. The task result contains `true` if the record was successfully marked as failed; otherwise, `false`.

  • methodTryAcquireAsync
    public async Task<IdempotencyClaimResult> TryAcquireAsync(Guid tenantId, string scope, IdempotencyKey key, string fingerprint, TimeSpan leaseDuration, TimeSpan retentionDuration, CancellationToken cancellationToken = default)

    Inherits documentation from base type or interface.

    tenantId: Guid
    scope: string
    key: IdempotencyKey
    fingerprint: string
    leaseDuration: TimeSpan
    retentionDuration: TimeSpan
    cancellationToken: CancellationToken
  • methodTryAcquireAsync
    public Task<IdempotencyClaimResult> TryAcquireAsync(Guid tenantId, string scope, IdempotencyKey key, string fingerprint, TimeSpan leaseDuration, TimeSpan retentionDuration, IDbConnection connection, IDbTransaction? transaction, CancellationToken cancellationToken = default)

    Attempts to acquire exclusive execution ownership for an idempotency key within the specified database transaction.

    tenantId: Guid
    The unique identifier of the tenant.
    scope: string
    The functional scope or partition of the operation.
    key: IdempotencyKey
    The unique idempotency key.
    fingerprint: string
    The cryptographic fingerprint representing the canonical request.
    leaseDuration: TimeSpan
    The duration for which the ownership lease remains valid before considering it stale.
    retentionDuration: TimeSpan
    The retention period for retaining completed records.
    connection: IDbConnection
    An existing open database connection to use.
    transaction: IDbTransaction?
    An optional active database transaction to participate in.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A task representing the asynchronous operation. The task result contains the `IdempotencyClaimResult` indicating whether ownership was acquired, if a cached response is available for replay, or if a conflict occurred.

class

OracleScripts

Assembly: EricksonLopez.Idempotency.Oracle
public static class OracleScripts

Provides raw SQL script definitions for Oracle schema generation and indexes.

Members (1)

  • fieldCreateTableScript
    public const string CreateTableScript

    Gets the DDL script for creating the idempotency records table and associated indexes in Oracle Database.

class

OracleServiceCollectionExtensions

Assembly: EricksonLopez.Idempotency.Oracle
public static class OracleServiceCollectionExtensions

Provides extension methods for `IServiceCollection` to register Oracle Database idempotency persistence store.

Members (1)

  • methodAddOracleIdempotencyStore
    public static IServiceCollection AddOracleIdempotencyStore(this IServiceCollection services, string connectionString)

    Registers the Oracle Database implementation of `IIdempotencyStore` in the specified service collection.

    services: this IServiceCollection
    The `IServiceCollection` to add the store to.
    connectionString: string
    The Oracle database connection string.

    Returns: The same service collection instance for method chaining.

    Exceptions: ArgumentNullException: `services` is `null`; ArgumentException: `connectionString` is `null`, empty, or consists only of white-space characters

EricksonLopez.Idempotency.PostgreSql#

10
interface

IPostgreSqlSessionContext

Assembly: EricksonLopez.Idempotency.PostgreSql
public interface IPostgreSqlSessionContext

Defines the contract for propagating transaction-local PostgreSQL session context variables (such as RLS plane, tenant, and company identifiers) onto active database transactions.

Members (2)

  • methodSetSessionContextAsync
    ValueTask SetSessionContextAsync(NpgsqlConnection connection, string tenantId, bool? isLocal = null, NpgsqlTransaction? transaction = null, CancellationToken cancellationToken = default)

    Sets the PostgreSQL transaction-local configuration variable for the specified tenant identifier.

    connection: NpgsqlConnection
    The open PostgreSQL connection.
    tenantId: string
    The tenant identifier value to set.
    isLocal: bool?
    Optional flag indicating whether the setting is local to the transaction. Must be `true` or `null`; passing `false` fails closed with `InvalidOperationException`.
    transaction: NpgsqlTransaction?
    The active PostgreSQL transaction to bind the `set_config(..., true)` command to.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A value task representing the asynchronous operation.

  • methodSetSessionVariablesAsync
    ValueTask SetSessionVariablesAsync(DbConnection connection, DbTransaction transaction, PostgreSqlSessionVariables variables, CancellationToken cancellationToken = default)

    Propagates multiple transaction-local PostgreSQL GUC variables (`app.current_plane`, `app.current_tenant_id`, `app.current_company_id`, and any additional variables) inside the active `transaction` using `set_config(..., true)`.

    connection: DbConnection
    The open database connection.
    transaction: DbTransaction
    The active database transaction whose completion resets all local GUCs.
    variables: PostgreSqlSessionVariables
    The resolved session variables to apply.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A value task representing the asynchronous operation.

interface

IPostgreSqlSessionVariablesProvider

Assembly: EricksonLopez.Idempotency.PostgreSql
public interface IPostgreSqlSessionVariablesProvider

Defines a service provider interface (SPI) for resolving ambient multi-plane, tenant, and company PostgreSQL session variables when opening autonomous idempotency persistence transactions.

Members (1)

  • methodResolveSessionVariables
    PostgreSqlSessionVariables ResolveSessionVariables(Guid tenantId)

    Resolves the transaction-local PostgreSQL session variables for the current execution context.

    tenantId: Guid
    The tenant identifier passed to the idempotency store operation.

    Returns: The resolved `PostgreSqlSessionVariables` to propagate via `set_config(..., true)`.

class

IdempotencyTransientException

Assembly: EricksonLopez.Idempotency.PostgreSql
public class IdempotencyTransientException : EricksonLopez.Idempotency.Exceptions.IdempotencyTransientException
Inherits: EricksonLopez.Idempotency.Exceptions.IdempotencyTransientException

Exception thrown when a transient, retriable PostgreSQL error (such as a 40P01 deadlock) occurs.

Members (3)

  • constructorIdempotencyTransientException
    public IdempotencyTransientException()

    Initializes a new instance of the `IdempotencyTransientException` class.

  • constructorIdempotencyTransientException
    public IdempotencyTransientException(string message)

    Initializes a new instance of the `IdempotencyTransientException` class with a specified message.

    message: string
    The message that describes the error.
  • constructorIdempotencyTransientException
    public IdempotencyTransientException(string message, Exception innerException)

    Initializes a new instance of the `IdempotencyTransientException` class with a specified message and inner exception.

    message: string
    The message that describes the error.
    innerException: Exception
    The inner exception that caused this exception.
class

PostgreSqlIdempotencyStore

Assembly: EricksonLopez.Idempotency.PostgreSql
public sealed class PostgreSqlIdempotencyStore : ITransactionalIdempotencyStore
Implements: ITransactionalIdempotencyStore

Provides a PostgreSQL persistence store implementation for `IIdempotencyStore` and `ITransactionalIdempotencyStore` using `NpgsqlDataSource` and pure ADO.NET.

Members (11)

  • constructorPostgreSqlIdempotencyStore
    public PostgreSqlIdempotencyStore(NpgsqlDataSource dataSource, IdempotencyOptions? options)

    Initializes a new instance of the `PostgreSqlIdempotencyStore` class from configured options.

    dataSource: NpgsqlDataSource
    The PostgreSQL data source.
    options: IdempotencyOptions?
    The idempotency options.
  • constructorPostgreSqlIdempotencyStore
    public PostgreSqlIdempotencyStore(NpgsqlDataSource dataSource, Microsoft.Extensions.Options.IOptions<PostgreSqlStorageOptions>? optionsAccessor, IPostgreSqlSessionContext? sessionContext = null, IPostgreSqlSessionVariablesProvider? sessionVariablesProvider = null)

    Initializes a new instance of the `PostgreSqlIdempotencyStore` class with configured options accessor and optional session context.

    dataSource: NpgsqlDataSource
    The PostgreSQL data source.
    optionsAccessor: Microsoft.Extensions.Options.IOptions<PostgreSqlStorageOptions>?
    The PostgreSQL storage options accessor.
    sessionContext: IPostgreSqlSessionContext?
    The optional PostgreSQL session context for RLS propagation.
    sessionVariablesProvider: IPostgreSqlSessionVariablesProvider?
    The optional provider resolving multi-plane and multi-company session variables.
  • constructorPostgreSqlIdempotencyStore
    public PostgreSqlIdempotencyStore(NpgsqlDataSource dataSource, PostgreSqlStorageOptions? storageOptions, IPostgreSqlSessionContext? sessionContext = null, IPostgreSqlSessionVariablesProvider? sessionVariablesProvider = null)

    Initializes a new instance of the `PostgreSqlIdempotencyStore` class with PostgreSQL options and optional session context.

    dataSource: NpgsqlDataSource
    The PostgreSQL data source.
    storageOptions: PostgreSqlStorageOptions?
    The PostgreSQL storage options.
    sessionContext: IPostgreSqlSessionContext?
    The optional PostgreSQL session context for RLS propagation.
    sessionVariablesProvider: IPostgreSqlSessionVariablesProvider?
    The optional provider resolving multi-plane and multi-company session variables.
  • constructorPostgreSqlIdempotencyStore
    public PostgreSqlIdempotencyStore(NpgsqlDataSource dataSource, TimeSpan? commandTimeout = null)

    Initializes a new instance of the `PostgreSqlIdempotencyStore` class with the specified data source and optional command timeout.

    dataSource: NpgsqlDataSource
    The PostgreSQL data source.
    commandTimeout: TimeSpan?
    The optional command timeout. Defaults to 10 seconds.
  • methodCleanupExpiredRecordsAsync
    public Task<int> CleanupExpiredRecordsAsync(DateTimeOffset utcNow, int batchSize, CancellationToken cancellationToken = default)

    Inherits documentation from base type or interface.

    utcNow: DateTimeOffset
    batchSize: int
    cancellationToken: CancellationToken
  • methodMarkCompletedAsync
    public Task<bool> MarkCompletedAsync(Guid tenantId, string scope, IdempotencyKey key, Guid ownerToken, int concurrencyVersion, int statusCode, IReadOnlyDictionary<string, string[]> headers, ReadOnlyMemory<byte> responseBody, TimeSpan retentionDuration, CancellationToken cancellationToken = default)

    Inherits documentation from base type or interface.

    tenantId: Guid
    scope: string
    key: IdempotencyKey
    ownerToken: Guid
    concurrencyVersion: int
    statusCode: int
    headers: IReadOnlyDictionary<string, string[]>
    responseBody: ReadOnlyMemory<byte>
    retentionDuration: TimeSpan
    cancellationToken: CancellationToken
  • methodMarkCompletedAsync
    public Task<bool> MarkCompletedAsync(Guid tenantId, string scope, IdempotencyKey key, Guid ownerToken, int concurrencyVersion, int statusCode, IReadOnlyDictionary<string, string[]> headers, ReadOnlyMemory<byte> responseBody, TimeSpan retentionDuration, IDbConnection connection, IDbTransaction? transaction, CancellationToken cancellationToken = default)

    Atomically marks an in-flight idempotency record as completed within the provided database transaction, storing the produced response payload.

    tenantId: Guid
    The unique identifier of the tenant.
    scope: string
    The functional scope of the operation.
    key: IdempotencyKey
    The idempotency key.
    ownerToken: Guid
    The ownership token issued during key acquisition.
    concurrencyVersion: int
    The concurrency version issued during key acquisition.
    statusCode: int
    The HTTP or logical status code to cache.
    headers: IReadOnlyDictionary<string, string[]>
    The response headers to cache.
    responseBody: ReadOnlyMemory<byte>
    The serialized response body bytes to cache.
    retentionDuration: TimeSpan
    The retention duration for the completed record.
    connection: IDbConnection
    An existing open `IDbConnection` to use. Must not be `null`. The store will use this connection without opening a new one.
    transaction: IDbTransaction?
    An optional active `IDbTransaction` the operation should participate in. If `null`, the operation runs without a transaction but still uses the provided connection.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A task representing the asynchronous operation. The task result contains `true` if the record was successfully updated; otherwise, `false` (fencing token mismatch or owner mismatch).

  • methodMarkFailedAsync
    public Task<bool> MarkFailedAsync(Guid tenantId, string scope, IdempotencyKey key, Guid ownerToken, int concurrencyVersion, CancellationToken cancellationToken = default)

    Inherits documentation from base type or interface.

    tenantId: Guid
    scope: string
    key: IdempotencyKey
    ownerToken: Guid
    concurrencyVersion: int
    cancellationToken: CancellationToken
  • methodMarkFailedAsync
    public Task<bool> MarkFailedAsync(Guid tenantId, string scope, IdempotencyKey key, Guid ownerToken, int concurrencyVersion, IDbConnection connection, IDbTransaction? transaction, CancellationToken cancellationToken = default)

    Atomically marks an in-flight idempotency record as failed within the provided database transaction, enabling subsequent retries depending on policy.

    tenantId: Guid
    The unique identifier of the tenant.
    scope: string
    The functional scope of the operation.
    key: IdempotencyKey
    The idempotency key.
    ownerToken: Guid
    The ownership token issued during key acquisition.
    concurrencyVersion: int
    The concurrency version issued during key acquisition.
    connection: IDbConnection
    An existing open `IDbConnection` to use. Must not be `null`.
    transaction: IDbTransaction?
    An optional active `IDbTransaction` the operation should participate in. If `null`, the operation runs without a transaction but still uses the provided connection.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A task representing the asynchronous operation. The task result contains `true` if the record was successfully marked as failed; otherwise, `false`.

  • methodTryAcquireAsync
    public Task<IdempotencyClaimResult> TryAcquireAsync(Guid tenantId, string scope, IdempotencyKey key, string fingerprint, TimeSpan leaseDuration, TimeSpan retentionDuration, CancellationToken cancellationToken = default)

    Inherits documentation from base type or interface.

    tenantId: Guid
    scope: string
    key: IdempotencyKey
    fingerprint: string
    leaseDuration: TimeSpan
    retentionDuration: TimeSpan
    cancellationToken: CancellationToken
  • methodTryAcquireAsync
    public Task<IdempotencyClaimResult> TryAcquireAsync(Guid tenantId, string scope, IdempotencyKey key, string fingerprint, TimeSpan leaseDuration, TimeSpan retentionDuration, IDbConnection connection, IDbTransaction? transaction, CancellationToken cancellationToken = default)

    Attempts to acquire exclusive execution ownership for an idempotency key within the specified database transaction.

    tenantId: Guid
    The unique identifier of the tenant.
    scope: string
    The functional scope or partition of the operation.
    key: IdempotencyKey
    The unique idempotency key.
    fingerprint: string
    The cryptographic fingerprint representing the canonical request.
    leaseDuration: TimeSpan
    The duration for which the ownership lease remains valid before considering it stale.
    retentionDuration: TimeSpan
    The retention period for retaining completed records.
    connection: IDbConnection
    An existing open database connection to use.
    transaction: IDbTransaction?
    An optional active database transaction to participate in.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A task representing the asynchronous operation. The task result contains the `IdempotencyClaimResult` indicating whether ownership was acquired, if a cached response is available for replay, or if a conflict occurred.

class

PostgreSqlScripts

Assembly: EricksonLopez.Idempotency.PostgreSql
public static class PostgreSqlScripts

Provides raw SQL script definitions for PostgreSQL schema generation and indexes.

Members (1)

  • fieldCreateTableScript
    public const string CreateTableScript

    Gets the DDL script for creating the idempotency records table and associated indexes in PostgreSQL.

class

PostgreSqlServiceCollectionExtensions

Assembly: EricksonLopez.Idempotency.PostgreSql
public static class PostgreSqlServiceCollectionExtensions

Provides extension methods for `IServiceCollection` to register PostgreSQL idempotency persistence store.

Members (1)

  • methodAddPostgreSqlIdempotencyStore
    public static IServiceCollection AddPostgreSqlIdempotencyStore(this IServiceCollection services, Action<PostgreSqlStorageOptions>? configure = null)

    Registers the PostgreSQL implementation of `IIdempotencyStore` in the specified service collection.

    services: this IServiceCollection
    The `IServiceCollection` to add the store to.
    configure: Action<PostgreSqlStorageOptions>?
    Optional configuration callback for `PostgreSqlStorageOptions`.

    Returns: The same service collection instance for method chaining.

    Exceptions: ArgumentNullException: `services` is `null`

class

PostgreSqlSessionContext

Assembly: EricksonLopez.Idempotency.PostgreSql
public sealed class PostgreSqlSessionContext : IPostgreSqlSessionContext
Implements: IPostgreSqlSessionContext

Executes strictly transaction-local PostgreSQL `set_config(..., true)` statements to establish Row Level Security (RLS) context variables without contaminating pooled connections.

Members (4)

  • constructorPostgreSqlSessionContext
    public PostgreSqlSessionContext(IOptions<PostgreSqlStorageOptions> optionsAccessor)

    Initializes a new instance of the `PostgreSqlSessionContext` class from configured options.

    optionsAccessor: IOptions<PostgreSqlStorageOptions>
    The options accessor.
  • constructorPostgreSqlSessionContext
    public PostgreSqlSessionContext(PostgreSqlStorageOptions? options = null)

    Initializes a new instance of the `PostgreSqlSessionContext` class with explicit options.

    options: PostgreSqlStorageOptions?
    The storage options.

    Exceptions: InvalidOperationException: `options` specifies `SessionContextIsLocal = false`.

  • methodSetSessionContextAsync
    public ValueTask SetSessionContextAsync(NpgsqlConnection connection, string tenantId, bool? isLocal = null, NpgsqlTransaction? transaction = null, CancellationToken cancellationToken = default)

    Sets the PostgreSQL transaction-local configuration variable for the specified tenant identifier.

    connection: NpgsqlConnection
    The open PostgreSQL connection.
    tenantId: string
    The tenant identifier value to set.
    isLocal: bool?
    Optional flag indicating whether the setting is local to the transaction. Must be `true` or `null`; passing `false` fails closed with `InvalidOperationException`.
    transaction: NpgsqlTransaction?
    The active PostgreSQL transaction to bind the `set_config(..., true)` command to.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A value task representing the asynchronous operation.

  • methodSetSessionVariablesAsync
    public async ValueTask SetSessionVariablesAsync(DbConnection connection, DbTransaction transaction, PostgreSqlSessionVariables variables, CancellationToken cancellationToken = default)

    Propagates multiple transaction-local PostgreSQL GUC variables (`app.current_plane`, `app.current_tenant_id`, `app.current_company_id`, and any additional variables) inside the active `transaction` using `set_config(..., true)`.

    connection: DbConnection
    The open database connection.
    transaction: DbTransaction
    The active database transaction whose completion resets all local GUCs.
    variables: PostgreSqlSessionVariables
    The resolved session variables to apply.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A value task representing the asynchronous operation.

record

PostgreSqlSessionVariables

Assembly: EricksonLopez.Idempotency.PostgreSql
public readonly record struct PostgreSqlSessionVariables(string? TenantId, string? CompanyId, string? Plane, IReadOnlyDictionary<string, string?>? AdditionalSettings)

Represents the transaction-scoped PostgreSQL session configuration variables (GUCs) propagated before executing idempotency store operations under Row Level Security (RLS).

Members (6)

  • constructorPostgreSqlSessionVariables
    public PostgreSqlSessionVariables(string? TenantId = null, string? CompanyId = null, string? Plane = null, IReadOnlyDictionary<string, string?>? AdditionalSettings = null)

    Initializes a new instance of PostgreSqlSessionVariables.

    TenantId: string?
    The optional tenant identifier value (`app.current_tenant_id`).
    CompanyId: string?
    The optional company identifier value (`app.current_company_id`).
    Plane: string?
    The optional execution plane identifier (`app.current_plane`, e.g., `TENANT` or `CONTROL`).
    AdditionalSettings: IReadOnlyDictionary<string, string?>?
    Optional additional custom PostgreSQL GUC variable name/value pairs to set transaction-locally.
  • propertyAdditionalSettings
    public IReadOnlyDictionary<string, string?>? AdditionalSettings { get; init; }

    Optional additional custom PostgreSQL GUC variable name/value pairs to set transaction-locally.

  • propertyCompanyId
    public string? CompanyId { get; init; }

    The optional company identifier value (`app.current_company_id`).

  • propertyHasAnyValue
    public bool HasAnyValue { get; }

    Gets a value indicating whether at least one non-whitespace session variable is populated.

  • propertyPlane
    public string? Plane { get; init; }

    The optional execution plane identifier (`app.current_plane`, e.g., `TENANT` or `CONTROL`).

  • propertyTenantId
    public string? TenantId { get; init; }

    The optional tenant identifier value (`app.current_tenant_id`).

class

PostgreSqlStorageOptions

Assembly: EricksonLopez.Idempotency.PostgreSql
public sealed class PostgreSqlStorageOptions

Configuration options specific to the PostgreSQL idempotency persistence store.

Members (8)

  • methodEnsureValid
    public void EnsureValid()

    Validates fail-closed security invariants on the configured PostgreSQL storage options.

    Exceptions: InvalidOperationException: Thrown when `SessionContextIsLocal` is `false` or when required GUC variable names are empty.

  • propertyCommandTimeout
    public TimeSpan CommandTimeout { get; set; }

    Gets or sets the database command timeout for PostgreSQL storage operations. Defaults to 10 seconds.

  • propertyCompanyContextSettingName
    public string CompanyContextSettingName { get; set; }

    Gets or sets the PostgreSQL GUC configuration variable name used to propagate the company identifier. Defaults to `"app.current_company_id"`.

  • propertyEnableSessionContextPropagation
    public bool EnableSessionContextPropagation { get; set; }

    Gets or sets a value indicating whether PostgreSQL session context (such as RLS plane/tenant/company GUCs) is automatically propagated inside an explicit transaction when opening autonomous database connections. Defaults to `true`.

  • propertyPlaneContextSettingName
    public string PlaneContextSettingName { get; set; }

    Gets or sets the PostgreSQL GUC configuration variable name used to propagate the security/execution plane. Defaults to `"app.current_plane"`.

  • propertySessionContextIsLocal
    public bool SessionContextIsLocal { get; set; }

    Gets or sets a value indicating whether the session configuration is local to the transaction (`is_local = true`). Defaults to `true`. Setting this property to `false` is strictly prohibited on pooled connections and will fail closed during validation and initialization to prevent cross-tenant pool poisoning.

  • propertySessionContextSettingName
    public string SessionContextSettingName { get; set; }

    Gets or sets the PostgreSQL GUC configuration variable name used to propagate the tenant identifier. Defaults to `"app.current_tenant_id"`.

  • propertySessionVariablesResolver
    public Func<Guid, PostgreSqlSessionVariables>? SessionVariablesResolver { get; set; }

    Gets or sets an optional delegate used to resolve multi-plane and multi-company session variables (`app.current_plane`, `app.current_tenant_id`, `app.current_company_id`) per autonomous operation.

class

PostgreSqlStorageOptionsValidator

Assembly: EricksonLopez.Idempotency.PostgreSql
public sealed class PostgreSqlStorageOptionsValidator : IValidateOptions<PostgreSqlStorageOptions>
Implements: IValidateOptions<PostgreSqlStorageOptions>

Enforces fail-closed validation invariants on `PostgreSqlStorageOptions` at host startup.

Members (1)

  • methodValidate
    public ValidateOptionsResult Validate(string? name, PostgreSqlStorageOptions options)

    Inherits documentation from base type or interface.

    name: string?
    options: PostgreSqlStorageOptions

EricksonLopez.Idempotency.Redis#

3
class

RedisIdempotencyOptions

Assembly: EricksonLopez.Idempotency.Redis
public sealed class RedisIdempotencyOptions

Encapsulates configuration options for the Redis idempotency store.

Members (1)

  • propertyKeyPrefix
    public string KeyPrefix { get; set; }

    Gets or sets the key prefix applied to all Redis keys managed by this store.

    All idempotency record keys are namespaced under this prefix to avoid collisions with other Redis data. Defaults to `"idempotency:"`.

class

RedisIdempotencyStore

Assembly: EricksonLopez.Idempotency.Redis
public sealed class RedisIdempotencyStore : IIdempotencyStore
Implements: IIdempotencyStore

Provides a Redis-backed persistence store implementation for `IIdempotencyStore` using `IConnectionMultiplexer`.

Remarks:

Correctness guarantee note: This provider offers strong exactly-once guarantees for the common case but cannot provide the same fencing token guarantees as SQL providers. Specifically: - Concurrent acquisition is prevented by a Lua atomic script. - In-flight conflict detection works correctly for typical latency ranges. - Zombie worker protection via `concurrency_version` is best-effort; a zombie worker that completes after TTL expiry may not be detected. For critical financial operations, prefer the SQL providers (PostgreSQL, SQL Server) which implement true fencing tokens via conditional SQL UPDATE statements. See `docs/adr/adr-013-no-idistributedcache-abstraction.md` for the design rationale.

Members (5)

  • constructorRedisIdempotencyStore
    public RedisIdempotencyStore(IConnectionMultiplexer redis, RedisIdempotencyOptions options)

    Initializes a new instance of the `RedisIdempotencyStore` class with the specified Redis connection and options.

    redis: IConnectionMultiplexer
    The Redis connection multiplexer.
    options: RedisIdempotencyOptions
    The Redis store configuration options.

    Exceptions: ArgumentNullException: `redis` or `options` is `null`

  • methodCleanupExpiredRecordsAsync
    public Task<int> CleanupExpiredRecordsAsync(DateTimeOffset utcNow, int batchSize, CancellationToken cancellationToken = default)

    Deletes expired completed idempotency records in batches to reclaim storage.

    utcNow: DateTimeOffset
    The current UTC timestamp threshold for expiration.
    batchSize: int
    The maximum number of records to purge per execution batch.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A task representing the asynchronous operation. The task result contains the number of expired records permanently purged.

    Redis stores use TTL-based eviction rather than explicit cleanup. This method returns 0 and performs no operation because Redis keys expire automatically.

  • methodMarkCompletedAsync
    public async Task<bool> MarkCompletedAsync(Guid tenantId, string scope, IdempotencyKey key, Guid ownerToken, int concurrencyVersion, int statusCode, IReadOnlyDictionary<string, string[]> headers, ReadOnlyMemory<byte> responseBody, TimeSpan retentionDuration, CancellationToken cancellationToken = default)

    Atomically marks an in-flight idempotency record as completed, storing the produced response payload.

    tenantId: Guid
    The unique identifier of the tenant.
    scope: string
    The functional scope of the operation.
    key: IdempotencyKey
    The idempotency key.
    ownerToken: Guid
    The ownership token issued during key acquisition.
    concurrencyVersion: int
    The concurrency version issued during key acquisition.
    statusCode: int
    The HTTP or logical status code to cache.
    headers: IReadOnlyDictionary<string, string[]>
    The response headers to cache.
    responseBody: ReadOnlyMemory<byte>
    The serialized response body bytes to cache.
    retentionDuration: TimeSpan
    The retention duration for the completed record.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A task representing the asynchronous operation. The task result contains `true` if the record was successfully updated with matching fencing tokens; otherwise, `false`.

  • methodMarkFailedAsync
    public async Task<bool> MarkFailedAsync(Guid tenantId, string scope, IdempotencyKey key, Guid ownerToken, int concurrencyVersion, CancellationToken cancellationToken = default)

    Atomically marks an in-flight idempotency record as failed, enabling subsequent retries depending on policy.

    tenantId: Guid
    The unique identifier of the tenant.
    scope: string
    The functional scope of the operation.
    key: IdempotencyKey
    The idempotency key.
    ownerToken: Guid
    The ownership token issued during key acquisition.
    concurrencyVersion: int
    The concurrency version issued during key acquisition.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A task representing the asynchronous operation. The task result contains `true` if the record was successfully marked as failed; otherwise, `false`.

  • methodTryAcquireAsync
    public async Task<IdempotencyClaimResult> TryAcquireAsync(Guid tenantId, string scope, IdempotencyKey key, string fingerprint, TimeSpan leaseDuration, TimeSpan retentionDuration, CancellationToken cancellationToken = default)

    Attempts to acquire exclusive execution ownership for an idempotency key within the specified tenant and scope.

    tenantId: Guid
    The unique identifier of the tenant.
    scope: string
    The functional scope or partition of the operation.
    key: IdempotencyKey
    The unique idempotency key.
    fingerprint: string
    The cryptographic fingerprint representing the canonical request.
    leaseDuration: TimeSpan
    The duration for which the ownership lease remains valid before considering it stale.
    retentionDuration: TimeSpan
    The retention period for retaining completed records.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A task representing the asynchronous operation. The task result contains the `IdempotencyClaimResult` describing the acquisition outcome.

class

RedisServiceCollectionExtensions

Assembly: EricksonLopez.Idempotency.Redis
public static class RedisServiceCollectionExtensions

Provides extension methods for `IServiceCollection` to register the Redis idempotency store.

Members (2)

  • methodAddRedisIdempotency
    public static IServiceCollection AddRedisIdempotency(this IServiceCollection services, Action<RedisIdempotencyOptions>? configure = null)

    Registers `RedisIdempotencyStore` as the `IIdempotencyStore` implementation, using an existing `IConnectionMultiplexer` registered in the DI container.

    services: this IServiceCollection
    The `IServiceCollection` to add the services to.
    configure: Action<RedisIdempotencyOptions>?
    An optional delegate to configure `RedisIdempotencyOptions`.

    Returns: The same service collection instance for method chaining.

    Ensure that `IConnectionMultiplexer` is already registered before calling this method. If using `StackExchange.Redis.Extensions` or similar, this is typically handled by the respective package. For manual registration:

    services.AddSingleton<IConnectionMultiplexer>(_ =>
        ConnectionMultiplexer.Connect("localhost:6379"));
    services.AddIdempotencyCore();
    services.AddRedisIdempotency();

    Important: The Redis provider offers slightly weaker correctness guarantees than the SQL providers due to the absence of true fencing tokens. For critical financial operations, prefer the SQL providers (PostgreSQL, SQL Server). See ADR-013 for the full analysis. Exceptions: ArgumentNullException: `services` is `null`

  • methodAddRedisIdempotency
    public static IServiceCollection AddRedisIdempotency(this IServiceCollection services, string connectionString, Action<RedisIdempotencyOptions>? configure = null)

    Registers `RedisIdempotencyStore` as the `IIdempotencyStore` implementation, using a connection string to create and register a new `IConnectionMultiplexer`.

    services: this IServiceCollection
    The `IServiceCollection` to add services to.
    connectionString: string
    The Redis connection string (e.g., `"localhost:6379"`).
    configure: Action<RedisIdempotencyOptions>?
    An optional delegate to configure `RedisIdempotencyOptions`.

    Returns: The same service collection instance for method chaining.

    Exceptions: ArgumentNullException: `services` or `connectionString` is `null`

EricksonLopez.Idempotency.Result#

2
class

IdempotencyErrors

Assembly: EricksonLopez.Idempotency.Result
public static class IdempotencyErrors

Provides domain error factory methods for idempotency failures when utilizing the Result pattern.

Members (3)

  • methodFingerprintMismatch
    public static Error FingerprintMismatch(string key)

    Creates a validation error indicating that a key was reused with conflicting payload parameters.

    key: string
    The mismatched idempotency key.

    Returns: A standardized `Error` representing the validation mismatch.

  • methodInFlightConflict
    public static Error InFlightConflict(string key)

    Creates a conflict error indicating that an operation with the same key is actively executing.

    key: string
    The conflicting idempotency key.

    Returns: A standardized `Error` representing the conflict.

  • methodLeaseLost
    public static Error LeaseLost(string key)

    Creates a failure error indicating that an ownership lease was lost or expired before completion.

    key: string
    The idempotency key.

    Returns: A standardized `Error` representing the lost lease.

class

IdempotencyResultExtensions

Assembly: EricksonLopez.Idempotency.Result
public static class IdempotencyResultExtensions

Provides extension methods for `IdempotencyClaimResult` to convert claim outcomes into functional `Result<T>` instances.

Members (1)

  • methodAsErrorResult<T>
    public static Result<T>? AsErrorResult<T>(this IdempotencyClaimResult claimResult, string key)

    Converts a conflicted or mismatched claim result into a corresponding failure `Result<T>`.

    claimResult: this IdempotencyClaimResult
    The claim outcome to evaluate.
    key: string
    The idempotency key string.

    Returns: A failure `Result<T>` if the claim encountered a conflict or mismatch; otherwise, `null`.

    Type parameters: T: The result payload type.

EricksonLopez.Idempotency.SqlServer#

4
class

IdempotencyTransientException

Assembly: EricksonLopez.Idempotency.SqlServer
public class IdempotencyTransientException : IdempotencyException
Inherits: IdempotencyException

Exception thrown when a transient, retriable database error (such as a deadlock) occurs.

Members (3)

  • constructorIdempotencyTransientException
    public IdempotencyTransientException()

    Initializes a new instance of the `IdempotencyTransientException` class.

  • constructorIdempotencyTransientException
    public IdempotencyTransientException(string message)

    Initializes a new instance of the `IdempotencyTransientException` class with a specified message.

    message: string
    The message that describes the error.
  • constructorIdempotencyTransientException
    public IdempotencyTransientException(string message, Exception innerException)

    Initializes a new instance of the `IdempotencyTransientException` class with a specified message and inner exception.

    message: string
    The message that describes the error.
    innerException: Exception
    The inner exception that caused this exception.
class

SqlServerIdempotencyStore

Assembly: EricksonLopez.Idempotency.SqlServer
public sealed class SqlServerIdempotencyStore : ITransactionalIdempotencyStore
Implements: ITransactionalIdempotencyStore

Provides a Microsoft SQL Server persistence store implementation for `IIdempotencyStore` and `ITransactionalIdempotencyStore` using pure reflection-free ADO.NET.

Members (9)

  • constructorSqlServerIdempotencyStore
    public SqlServerIdempotencyStore(string connectionString, IdempotencyOptions? options)

    Initializes a new instance of the `SqlServerIdempotencyStore` class from configured options.

    connectionString: string
    The SQL Server connection string.
    options: IdempotencyOptions?
    The idempotency options.
  • constructorSqlServerIdempotencyStore
    public SqlServerIdempotencyStore(string connectionString, TimeSpan? commandTimeout = null)

    Initializes a new instance of the `SqlServerIdempotencyStore` class with the specified connection string and optional command timeout.

    connectionString: string
    The SQL Server connection string.
    commandTimeout: TimeSpan?
    The optional command timeout. Defaults to 10 seconds.

    Exceptions: ArgumentException: `connectionString` is `null`, empty, or consists only of white-space characters

  • methodCleanupExpiredRecordsAsync
    public async Task<int> CleanupExpiredRecordsAsync(DateTimeOffset utcNow, int batchSize, CancellationToken cancellationToken = default)

    Inherits documentation from base type or interface.

    utcNow: DateTimeOffset
    batchSize: int
    cancellationToken: CancellationToken
  • methodMarkCompletedAsync
    public async Task<bool> MarkCompletedAsync(Guid tenantId, string scope, IdempotencyKey key, Guid ownerToken, int concurrencyVersion, int statusCode, IReadOnlyDictionary<string, string[]> headers, ReadOnlyMemory<byte> responseBody, TimeSpan retentionDuration, CancellationToken cancellationToken = default)

    Inherits documentation from base type or interface.

    tenantId: Guid
    scope: string
    key: IdempotencyKey
    ownerToken: Guid
    concurrencyVersion: int
    statusCode: int
    headers: IReadOnlyDictionary<string, string[]>
    responseBody: ReadOnlyMemory<byte>
    retentionDuration: TimeSpan
    cancellationToken: CancellationToken
  • methodMarkCompletedAsync
    public Task<bool> MarkCompletedAsync(Guid tenantId, string scope, IdempotencyKey key, Guid ownerToken, int concurrencyVersion, int statusCode, IReadOnlyDictionary<string, string[]> headers, ReadOnlyMemory<byte> responseBody, TimeSpan retentionDuration, IDbConnection connection, IDbTransaction? transaction, CancellationToken cancellationToken = default)

    Atomically marks an in-flight idempotency record as completed within the provided database transaction, storing the produced response payload.

    tenantId: Guid
    The unique identifier of the tenant.
    scope: string
    The functional scope of the operation.
    key: IdempotencyKey
    The idempotency key.
    ownerToken: Guid
    The ownership token issued during key acquisition.
    concurrencyVersion: int
    The concurrency version issued during key acquisition.
    statusCode: int
    The HTTP or logical status code to cache.
    headers: IReadOnlyDictionary<string, string[]>
    The response headers to cache.
    responseBody: ReadOnlyMemory<byte>
    The serialized response body bytes to cache.
    retentionDuration: TimeSpan
    The retention duration for the completed record.
    connection: IDbConnection
    An existing open `IDbConnection` to use. Must not be `null`. The store will use this connection without opening a new one.
    transaction: IDbTransaction?
    An optional active `IDbTransaction` the operation should participate in. If `null`, the operation runs without a transaction but still uses the provided connection.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A task representing the asynchronous operation. The task result contains `true` if the record was successfully updated; otherwise, `false` (fencing token mismatch or owner mismatch).

  • methodMarkFailedAsync
    public async Task<bool> MarkFailedAsync(Guid tenantId, string scope, IdempotencyKey key, Guid ownerToken, int concurrencyVersion, CancellationToken cancellationToken = default)

    Inherits documentation from base type or interface.

    tenantId: Guid
    scope: string
    key: IdempotencyKey
    ownerToken: Guid
    concurrencyVersion: int
    cancellationToken: CancellationToken
  • methodMarkFailedAsync
    public Task<bool> MarkFailedAsync(Guid tenantId, string scope, IdempotencyKey key, Guid ownerToken, int concurrencyVersion, IDbConnection connection, IDbTransaction? transaction, CancellationToken cancellationToken = default)

    Atomically marks an in-flight idempotency record as failed within the provided database transaction, enabling subsequent retries depending on policy.

    tenantId: Guid
    The unique identifier of the tenant.
    scope: string
    The functional scope of the operation.
    key: IdempotencyKey
    The idempotency key.
    ownerToken: Guid
    The ownership token issued during key acquisition.
    concurrencyVersion: int
    The concurrency version issued during key acquisition.
    connection: IDbConnection
    An existing open `IDbConnection` to use. Must not be `null`.
    transaction: IDbTransaction?
    An optional active `IDbTransaction` the operation should participate in. If `null`, the operation runs without a transaction but still uses the provided connection.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A task representing the asynchronous operation. The task result contains `true` if the record was successfully marked as failed; otherwise, `false`.

  • methodTryAcquireAsync
    public async Task<IdempotencyClaimResult> TryAcquireAsync(Guid tenantId, string scope, IdempotencyKey key, string fingerprint, TimeSpan leaseDuration, TimeSpan retentionDuration, CancellationToken cancellationToken = default)

    Inherits documentation from base type or interface.

    tenantId: Guid
    scope: string
    key: IdempotencyKey
    fingerprint: string
    leaseDuration: TimeSpan
    retentionDuration: TimeSpan
    cancellationToken: CancellationToken

    Exceptions: IdempotencyTransientException: A SQL Server deadlock (error 1205) occurred while acquiring the idempotency lease.

  • methodTryAcquireAsync
    public Task<IdempotencyClaimResult> TryAcquireAsync(Guid tenantId, string scope, IdempotencyKey key, string fingerprint, TimeSpan leaseDuration, TimeSpan retentionDuration, IDbConnection connection, IDbTransaction? transaction, CancellationToken cancellationToken = default)

    Attempts to acquire exclusive execution ownership for an idempotency key within the specified database transaction.

    tenantId: Guid
    The unique identifier of the tenant.
    scope: string
    The functional scope or partition of the operation.
    key: IdempotencyKey
    The unique idempotency key.
    fingerprint: string
    The cryptographic fingerprint representing the canonical request.
    leaseDuration: TimeSpan
    The duration for which the ownership lease remains valid before considering it stale.
    retentionDuration: TimeSpan
    The retention period for retaining completed records.
    connection: IDbConnection
    An existing open database connection to use.
    transaction: IDbTransaction?
    An optional active database transaction to participate in.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A task representing the asynchronous operation. The task result contains the `IdempotencyClaimResult` indicating whether ownership was acquired, if a cached response is available for replay, or if a conflict occurred.

    Exceptions: IdempotencyTransientException: A SQL Server deadlock (error 1205) occurred while acquiring the idempotency lease.

class

SqlServerScripts

Assembly: EricksonLopez.Idempotency.SqlServer
public static class SqlServerScripts

Provides raw SQL script definitions for SQL Server schema generation and indexes.

Members (1)

  • fieldCreateTableScript
    public const string CreateTableScript

    Gets the DDL script for creating the idempotency records table and associated indexes in Microsoft SQL Server.

class

SqlServerServiceCollectionExtensions

Assembly: EricksonLopez.Idempotency.SqlServer
public static class SqlServerServiceCollectionExtensions

Provides extension methods for `IServiceCollection` to register SQL Server idempotency persistence store.

Members (1)

  • methodAddSqlServerIdempotencyStore
    public static IServiceCollection AddSqlServerIdempotencyStore(this IServiceCollection services, string connectionString)

    Registers the SQL Server implementation of `IIdempotencyStore` in the specified service collection.

    services: this IServiceCollection
    The `IServiceCollection` to add the store to.
    connectionString: string
    The SQL Server database connection string.

    Returns: The same service collection instance for method chaining.

    Exceptions: ArgumentNullException: `services` is `null`; ArgumentException: `connectionString` is `null`, empty, or consists only of white-space characters

EricksonLopez.Idempotency.Sqlite#

3
class

SqliteIdempotencyStore

Assembly: EricksonLopez.Idempotency.Sqlite
public sealed class SqliteIdempotencyStore : ITransactionalIdempotencyStore
Implements: ITransactionalIdempotencyStore

Provides an SQLite persistence store implementation for `IIdempotencyStore` and `ITransactionalIdempotencyStore` using pure ADO.NET and `SqliteConnection`.

Members (9)

  • constructorSqliteIdempotencyStore
    public SqliteIdempotencyStore(string connectionString, IdempotencyOptions? options)

    Initializes a new instance of the `SqliteIdempotencyStore` class with the specified connection string and options.

    connectionString: string
    The SQLite database connection string.
    options: IdempotencyOptions?
    The idempotency options.
  • constructorSqliteIdempotencyStore
    public SqliteIdempotencyStore(string connectionString, TimeSpan? commandTimeout = null)

    Initializes a new instance of the `SqliteIdempotencyStore` class with the specified connection string and optional command timeout.

    connectionString: string
    The SQLite database connection string.
    commandTimeout: TimeSpan?
    Optional command timeout for database commands. Defaults to 10 seconds.

    Exceptions: ArgumentException: `connectionString` is `null`, empty, or consists only of white-space characters

  • methodCleanupExpiredRecordsAsync
    public async Task<int> CleanupExpiredRecordsAsync(DateTimeOffset utcNow, int batchSize, CancellationToken cancellationToken = default)

    Inherits documentation from base type or interface.

    utcNow: DateTimeOffset
    batchSize: int
    cancellationToken: CancellationToken
  • methodMarkCompletedAsync
    public async Task<bool> MarkCompletedAsync(Guid tenantId, string scope, IdempotencyKey key, Guid ownerToken, int concurrencyVersion, int statusCode, IReadOnlyDictionary<string, string[]> headers, ReadOnlyMemory<byte> responseBody, TimeSpan retentionDuration, CancellationToken cancellationToken = default)

    Inherits documentation from base type or interface.

    tenantId: Guid
    scope: string
    key: IdempotencyKey
    ownerToken: Guid
    concurrencyVersion: int
    statusCode: int
    headers: IReadOnlyDictionary<string, string[]>
    responseBody: ReadOnlyMemory<byte>
    retentionDuration: TimeSpan
    cancellationToken: CancellationToken
  • methodMarkCompletedAsync
    public Task<bool> MarkCompletedAsync(Guid tenantId, string scope, IdempotencyKey key, Guid ownerToken, int concurrencyVersion, int statusCode, IReadOnlyDictionary<string, string[]> headers, ReadOnlyMemory<byte> responseBody, TimeSpan retentionDuration, IDbConnection connection, IDbTransaction? transaction, CancellationToken cancellationToken = default)

    Atomically marks an in-flight idempotency record as completed within the provided database transaction, storing the produced response payload.

    tenantId: Guid
    The unique identifier of the tenant.
    scope: string
    The functional scope of the operation.
    key: IdempotencyKey
    The idempotency key.
    ownerToken: Guid
    The ownership token issued during key acquisition.
    concurrencyVersion: int
    The concurrency version issued during key acquisition.
    statusCode: int
    The HTTP or logical status code to cache.
    headers: IReadOnlyDictionary<string, string[]>
    The response headers to cache.
    responseBody: ReadOnlyMemory<byte>
    The serialized response body bytes to cache.
    retentionDuration: TimeSpan
    The retention duration for the completed record.
    connection: IDbConnection
    An existing open `IDbConnection` to use. Must not be `null`. The store will use this connection without opening a new one.
    transaction: IDbTransaction?
    An optional active `IDbTransaction` the operation should participate in. If `null`, the operation runs without a transaction but still uses the provided connection.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A task representing the asynchronous operation. The task result contains `true` if the record was successfully updated; otherwise, `false` (fencing token mismatch or owner mismatch).

  • methodMarkFailedAsync
    public async Task<bool> MarkFailedAsync(Guid tenantId, string scope, IdempotencyKey key, Guid ownerToken, int concurrencyVersion, CancellationToken cancellationToken = default)

    Inherits documentation from base type or interface.

    tenantId: Guid
    scope: string
    key: IdempotencyKey
    ownerToken: Guid
    concurrencyVersion: int
    cancellationToken: CancellationToken
  • methodMarkFailedAsync
    public Task<bool> MarkFailedAsync(Guid tenantId, string scope, IdempotencyKey key, Guid ownerToken, int concurrencyVersion, IDbConnection connection, IDbTransaction? transaction, CancellationToken cancellationToken = default)

    Atomically marks an in-flight idempotency record as failed within the provided database transaction, enabling subsequent retries depending on policy.

    tenantId: Guid
    The unique identifier of the tenant.
    scope: string
    The functional scope of the operation.
    key: IdempotencyKey
    The idempotency key.
    ownerToken: Guid
    The ownership token issued during key acquisition.
    concurrencyVersion: int
    The concurrency version issued during key acquisition.
    connection: IDbConnection
    An existing open `IDbConnection` to use. Must not be `null`.
    transaction: IDbTransaction?
    An optional active `IDbTransaction` the operation should participate in. If `null`, the operation runs without a transaction but still uses the provided connection.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A task representing the asynchronous operation. The task result contains `true` if the record was successfully marked as failed; otherwise, `false`.

  • methodTryAcquireAsync
    public async Task<IdempotencyClaimResult> TryAcquireAsync(Guid tenantId, string scope, IdempotencyKey key, string fingerprint, TimeSpan leaseDuration, TimeSpan retentionDuration, CancellationToken cancellationToken = default)

    Inherits documentation from base type or interface.

    tenantId: Guid
    scope: string
    key: IdempotencyKey
    fingerprint: string
    leaseDuration: TimeSpan
    retentionDuration: TimeSpan
    cancellationToken: CancellationToken
  • methodTryAcquireAsync
    public Task<IdempotencyClaimResult> TryAcquireAsync(Guid tenantId, string scope, IdempotencyKey key, string fingerprint, TimeSpan leaseDuration, TimeSpan retentionDuration, IDbConnection connection, IDbTransaction? transaction, CancellationToken cancellationToken = default)

    Attempts to acquire exclusive execution ownership for an idempotency key within the specified database transaction.

    tenantId: Guid
    The unique identifier of the tenant.
    scope: string
    The functional scope or partition of the operation.
    key: IdempotencyKey
    The unique idempotency key.
    fingerprint: string
    The cryptographic fingerprint representing the canonical request.
    leaseDuration: TimeSpan
    The duration for which the ownership lease remains valid before considering it stale.
    retentionDuration: TimeSpan
    The retention period for retaining completed records.
    connection: IDbConnection
    An existing open database connection to use.
    transaction: IDbTransaction?
    An optional active database transaction to participate in.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A task representing the asynchronous operation. The task result contains the `IdempotencyClaimResult` indicating whether ownership was acquired, if a cached response is available for replay, or if a conflict occurred.

class

SqliteScripts

Assembly: EricksonLopez.Idempotency.Sqlite
public static class SqliteScripts

Provides raw SQL script definitions for SQLite schema generation and indexes.

Members (1)

  • fieldCreateTableScript
    public const string CreateTableScript

    Gets the DDL script for creating the idempotency records table and associated indexes in SQLite.

class

SqliteServiceCollectionExtensions

Assembly: EricksonLopez.Idempotency.Sqlite
public static class SqliteServiceCollectionExtensions

Provides extension methods for `IServiceCollection` to register SQLite idempotency persistence store.

Members (1)

  • methodAddSqliteIdempotencyStore
    public static IServiceCollection AddSqliteIdempotencyStore(this IServiceCollection services, string connectionString)

    Registers the SQLite implementation of `IIdempotencyStore` and `ITransactionalIdempotencyStore` in the specified service collection.

    services: this IServiceCollection
    The `IServiceCollection` to add the store to.
    connectionString: string
    The SQLite database connection string.

    Returns: The same service collection instance for method chaining.

    Exceptions: ArgumentNullException: `services` is `null`; ArgumentException: `connectionString` is `null`, empty, or consists only of white-space characters

EricksonLopez.Idempotency.Testing#

1
class

InMemoryIdempotencyStore

Assembly: EricksonLopez.Idempotency.Testing
public sealed class InMemoryIdempotencyStore : IIdempotencyStore
Implements: IIdempotencyStore

Provides a thread-safe in-memory implementation of `IIdempotencyStore` for unit testing and local development.

Remarks:

This store maintains records in a thread-safe in-memory collection and supports deterministic time control via `TimeProvider`. It is intended for testing and development environments only.

Members (6)

  • constructorInMemoryIdempotencyStore
    public InMemoryIdempotencyStore(TimeProvider? timeProvider = null)

    Initializes a new instance of the `InMemoryIdempotencyStore` class.

    timeProvider: TimeProvider?
    Optional time provider for deterministic time manipulation in unit tests.
  • methodCleanupExpiredRecordsAsync
    public Task<int> CleanupExpiredRecordsAsync(DateTimeOffset utcNow, int batchSize, CancellationToken cancellationToken = default)

    Deletes expired completed idempotency records in batches to reclaim storage.

    utcNow: DateTimeOffset
    The current UTC timestamp threshold for expiration.
    batchSize: int
    The maximum number of records to purge per execution batch.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A task representing the asynchronous operation. The task result contains the number of expired records permanently purged.

  • methodClear
    public void Clear()

    Removes all stored idempotency records from memory.

  • methodMarkCompletedAsync
    public Task<bool> MarkCompletedAsync(Guid tenantId, string scope, IdempotencyKey key, Guid ownerToken, int concurrencyVersion, int statusCode, IReadOnlyDictionary<string, string[]> headers, ReadOnlyMemory<byte> responseBody, TimeSpan retentionDuration, CancellationToken cancellationToken = default)

    Atomically marks an in-flight idempotency record as completed, storing the produced response payload.

    tenantId: Guid
    The unique identifier of the tenant.
    scope: string
    The functional scope of the operation.
    key: IdempotencyKey
    The idempotency key.
    ownerToken: Guid
    The ownership token issued during key acquisition.
    concurrencyVersion: int
    The concurrency version issued during key acquisition.
    statusCode: int
    The HTTP or logical status code to cache.
    headers: IReadOnlyDictionary<string, string[]>
    The response headers to cache.
    responseBody: ReadOnlyMemory<byte>
    The serialized response body bytes to cache.
    retentionDuration: TimeSpan
    The retention duration for the completed record.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A task representing the asynchronous operation. The task result contains `true` if the record was successfully updated with matching fencing tokens; otherwise, `false`.

  • methodMarkFailedAsync
    public Task<bool> MarkFailedAsync(Guid tenantId, string scope, IdempotencyKey key, Guid ownerToken, int concurrencyVersion, CancellationToken cancellationToken = default)

    Atomically marks an in-flight idempotency record as failed, enabling subsequent retries depending on policy.

    tenantId: Guid
    The unique identifier of the tenant.
    scope: string
    The functional scope of the operation.
    key: IdempotencyKey
    The idempotency key.
    ownerToken: Guid
    The ownership token issued during key acquisition.
    concurrencyVersion: int
    The concurrency version issued during key acquisition.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A task representing the asynchronous operation. The task result contains `true` if the record was successfully marked as failed; otherwise, `false`.

  • methodTryAcquireAsync
    public Task<IdempotencyClaimResult> TryAcquireAsync(Guid tenantId, string scope, IdempotencyKey key, string fingerprint, TimeSpan leaseDuration, TimeSpan retentionDuration, CancellationToken cancellationToken = default)

    Attempts to acquire exclusive execution ownership for an idempotency key within the specified tenant and scope.

    tenantId: Guid
    The unique identifier of the tenant.
    scope: string
    The functional scope or partition of the operation.
    key: IdempotencyKey
    The unique idempotency key.
    fingerprint: string
    The cryptographic fingerprint representing the canonical request.
    leaseDuration: TimeSpan
    The duration for which the ownership lease remains valid before considering it stale.
    retentionDuration: TimeSpan
    The retention period for retaining completed records.
    cancellationToken: CancellationToken
    A token that can be used to cancel the asynchronous operation.

    Returns: A task representing the asynchronous operation. The task result contains the `IdempotencyClaimResult` describing the acquisition outcome.

Search EricksonLopez.* Ecosystem

Type a library name, NuGet package ID, .NET type, or architectural concept to search across the portal.