Skip to main content

HttpIdempotencyRepository

Trait HttpIdempotencyRepository 

Source
pub trait HttpIdempotencyRepository: Send + Sync {
    // Required methods
    fn get(
        &self,
        tenant: &str,
        key: &str,
        expired_before: DateTime<Utc>,
    ) -> Result<Option<HttpIdempotencyRecord>, CommerceError>;
    fn put(&self, record: &HttpIdempotencyRecord) -> Result<bool, CommerceError>;
    fn purge_expired(
        &self,
        expired_before: DateTime<Utc>,
    ) -> Result<u64, CommerceError>;
}
Expand description

Repository over the http_idempotency_keys table.

Required Methods§

Source

fn get( &self, tenant: &str, key: &str, expired_before: DateTime<Utc>, ) -> Result<Option<HttpIdempotencyRecord>, CommerceError>

Fetch the entry for (tenant, key).

Rows created strictly before expired_before are treated as expired: they are deleted (lazy cleanup) and None is returned.

Source

fn put(&self, record: &HttpIdempotencyRecord) -> Result<bool, CommerceError>

Insert a new entry. Returns false (without overwriting) when an entry for (tenant, key) already exists — first write wins across replicas.

Source

fn purge_expired( &self, expired_before: DateTime<Utc>, ) -> Result<u64, CommerceError>

Delete all entries created strictly before expired_before, returning the number of rows removed.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§