Versions in this module Expand all Collapse all v1 v1.12.3 Oct 8, 2026 v1.12.2 Oct 8, 2026 Changes in this version + const DefaultLease + const DefaultMaxEntries + const HeaderName + const ReplayedHeader + const SkippedHeader + const TruncatedHeader + var ErrNotHolder = errors.New("idempotency: caller does not hold the key") + func DefaultPrincipal(ctx router.Context) string + func Middleware(store Store, opts ...Option) router.Middleware + type Begun struct + Done <-chan struct{} + Fingerprint string + Response *Response + State State + Token Token + type ConflictMode int + const ConflictReject + const ConflictWait + type Key struct + Principal string + Scope string + Value string + type MemoryOption func(*MemoryStore) + func WithClock(now func() time.Time) MemoryOption + func WithMaxEntries(n int) MemoryOption + type MemoryStore struct + func Default() *MemoryStore + func NewMemoryStore(opts ...MemoryOption) *MemoryStore + func (s *MemoryStore) Begin(_ context.Context, key Key, fingerprint string, lease time.Duration) (Begun, error) + func (s *MemoryStore) Complete(_ context.Context, key Key, token Token, resp Response) error + func (s *MemoryStore) Release(_ context.Context, key Key, token Token) error + type Option func(*config) + func AllowAnonymous() Option + func Clock(now func() time.Time) Option + func Lease(d time.Duration) Option + func Logger(l logger.Logger) Option + func MaxBody(n int64) Option + func MaxResponse(n int) Option + func OnConflict(m ConflictMode) Option + func Principal(fn PrincipalFunc) Option + func RequireKey() Option + func TTL(d time.Duration) Option + func WaitTimeout(d time.Duration) Option + func WithStore(s Store) Option + type PrincipalFunc func(ctx router.Context) string + type Response struct + Body []byte + ExpiresAt time.Time + Fingerprint string + Header http.Header + Status int + StoredAt time.Time + type State int + const Acquired + const InFlight + const Replay + type Store interface + Begin func(ctx context.Context, key Key, fingerprint string, lease time.Duration) (Begun, error) + Complete func(ctx context.Context, key Key, token Token, resp Response) error + Release func(ctx context.Context, key Key, token Token) error + type Token uint64