pub struct Idempotency { /* private fields */ }Expand description
Idempotency-key middleware, see the module documentation
Implementations§
Source§impl Idempotency
impl Idempotency
pub fn with_store(store: impl IdempotencyStore) -> Self
Secret that makes the hashes behind scopes and payload fingerprints identical on every instance. Required with a store shared between processes (Redis): by default each process hashes with its own random seed, and instances would disagree about whose key is whose. Keep it secret and at least 16 bytes: it keeps clients from crafting colliding scopes.
Sourcepub fn methods<I: IntoIterator<Item = Method>>(self, methods: I) -> Self
pub fn methods<I: IntoIterator<Item = Method>>(self, methods: I) -> Self
Methods the key applies to (default POST and PATCH; PUT and DELETE
are idempotent by definition)
Sourcepub fn ttl(self, ttl: Duration) -> Self
pub fn ttl(self, ttl: Duration) -> Self
How long a finished response can be replayed (default 24 hours)
Sourcepub fn lock_ttl(self, lock_ttl: Duration) -> Self
pub fn lock_ttl(self, lock_ttl: Duration) -> Self
How long a running request blocks retries if it never finishes (default 60 seconds)
Sourcepub fn max_response_bytes(self, max: usize) -> Self
pub fn max_response_bytes(self, max: usize) -> Self
Largest response body that is kept for replay (default 256 KiB). Larger responses are sent normally but not stored, so a retry runs the handler again.