Documentation
¶
Overview ¶
Package idempotency stores and replays responses to unsafe requests keyed by a client-supplied Idempotency-Key, so retries do not duplicate side effects. The key is written in the same transaction as the state change it guards (see the widget module), which makes concurrent retries safe as well as sequential ones. This package owns lookup, hashing, and the time-to-live.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrConflict = errors.New("idempotency key reused with a different request")
ErrConflict is returned when a key is reused with a different request body, which the caller should surface as HTTP 409.
Functions ¶
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func (*Store) Lookup ¶
Lookup returns the stored response for key. If the key exists but was stored for a different request fingerprint, it returns ErrConflict.
func (*Store) PurgeExpired ¶
PurgeExpired deletes keys whose TTL has passed and returns how many were removed. Run it periodically so the table does not grow without bound.