Expand description
Idempotency-Key layer — safe client retries for mutating endpoints.
Stripe-style semantics for #[Idempotent(ttl = "24h")] routes:
- Client sends
Idempotency-Key: <opaque>; the key is scoped totenant + principal + route, so keys can never collide across users. - First arrival claims the key atomically and runs the handler; the
final response (status < 500) is stored for
ttl. - A retry with the same key gets the stored response replayed
(
Idempotency-Replayed: true) — no second order, no double charge. - A concurrent duplicate while the first is still running gets
409 Conflict(retry after the original completes). - Handler failures ≥ 500 release the claim so the client may retry.
- Requests without the header pass through untouched.
Pairs deliberately with #[Timeout]: deadlines make clients retry; this
layer makes those retries safe.
Enums§
Traits§
- Idempotency
Store - App-provided storage (Redis
SET NX PXin production).