Skip to main content

IdempotencyStore

Trait IdempotencyStore 

Source
pub trait IdempotencyStore:
    Send
    + Sync
    + 'static {
    // Required methods
    fn acquire<'a>(
        &'a self,
        key: &'a str,
        fingerprint: u64,
        in_flight_ttl_ms: u64,
    ) -> IdempotencyFuture<'a, IdempotencyLookup>;
    fn complete<'a>(
        &'a self,
        key: String,
        fingerprint: u64,
        response: Arc<StoredIdempotentResponse>,
        ttl_ms: u64,
    ) -> IdempotencyFuture<'a, ()>;
    fn release<'a>(&'a self, key: &'a str) -> IdempotencyFuture<'a, ()>;

    // Provided methods
    fn release_on_drop(&self, _key: &str) { ... }
    fn purge_expired(&self) -> usize { ... }
}
Expand description

Pluggable asynchronous storage contract backing IdempotencyPlugin.

Required Methods§

Source

fn acquire<'a>( &'a self, key: &'a str, fingerprint: u64, in_flight_ttl_ms: u64, ) -> IdempotencyFuture<'a, IdempotencyLookup>

Atomically checks an existing entry or acquires an exclusive InFlight lock for key.

§Arguments
  • &'a self - Store reference.
  • &'a str - Scoped idempotency storage key.
  • u64 - Request (method, path, body) XxHash3_64 fingerprint.
  • u64 - Maximum InFlight lock TTL in milliseconds.
§Returns
  • IdempotencyFuture<'a, IdempotencyLookup> - Acquisition, conflict, mismatch, or cached replay result.
Source

fn complete<'a>( &'a self, key: String, fingerprint: u64, response: Arc<StoredIdempotentResponse>, ttl_ms: u64, ) -> IdempotencyFuture<'a, ()>

Commits a completed response for key with the given ttl_ms.

§Arguments
  • &'a self - Store reference.
  • String - Scoped idempotency storage key.
  • u64 - Request (method, path, body) fingerprint.
  • Arc<StoredIdempotentResponse> - Cached response and prebuilt replay wire buffer.
  • u64 - Replay cache TTL in milliseconds.
§Returns
  • IdempotencyFuture<'a, ()> - Completion future.
Source

fn release<'a>(&'a self, key: &'a str) -> IdempotencyFuture<'a, ()>

Releases an InFlight entry without caching (for example on uncacheable 5xx responses).

§Arguments
  • &'a self - Store reference.
  • &'a str - Scoped idempotency storage key.
§Returns
  • IdempotencyFuture<'a, ()> - Completion future.

Provided Methods§

Source

fn release_on_drop(&self, _key: &str)

Synchronous best-effort cleanup hook invoked when IdempotencyInFlightGuard drops early.

§Arguments
  • &str - Scoped idempotency storage key.
Source

fn purge_expired(&self) -> usize

Evicts expired entries and returns the count removed.

§Returns
  • usize - Number of expired entries evicted.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§