Versions in this module Expand all Collapse all v0 v0.1.0 Oct 2, 2026 Changes in this version + const DefaultLease + const DefaultTTL + var ErrFingerprintMismatch = errors.New("idem: key was already used with a different request") + var ErrInProgress = errors.New("idem: an operation with this key is already in progress") + var ErrInvalidKey = errors.New("idem: invalid key") + var ErrLeaseLost = errors.New("idem: lease lost") + var ErrNotRecorded = errors.New("idem: operation finished but its result was not recorded") + func Do[T any](ctx context.Context, e *Engine, key string, ...) (v T, replayed bool, err error) + func Fingerprint(parts ...[]byte) string + func Provisional(ctx context.Context) context.Context + type Attempt struct + func (a *Attempt) Complete(ctx context.Context, result []byte) error + func (a *Attempt) Context() context.Context + func (a *Attempt) Key() string + func (a *Attempt) Release(ctx context.Context) error + func (a *Attempt) Token() string + type Claim struct + Fingerprint string + Result []byte + State State + type Codec interface + Marshal func(v any) ([]byte, error) + Unmarshal func(data []byte, v any) error + type Engine struct + func New(store Store, opts ...Option) *Engine + func (e *Engine) Begin(ctx context.Context, key string, opts ...Option) (*Attempt, []byte, error) + func (e *Engine) Codec() Codec + func (e *Engine) Store() Store + type Option func(*config) + func WithCodec(codec Codec) Option + func WithFingerprint(fp string) Option + func WithHeartbeat(d time.Duration) Option + func WithLease(d time.Duration) Option + func WithNamespace(ns string) Option + func WithTTL(d time.Duration) Option + func WithWait(d time.Duration) Option + type State int + const StateAcquired + const StateCompleted + const StateInProgress + func (s State) String() string + type Store interface + Acquire func(ctx context.Context, key, token, fingerprint string, lease time.Duration) (Claim, error) + Complete func(ctx context.Context, key, token string, result []byte, ttl time.Duration) error + Extend func(ctx context.Context, key, token string, lease time.Duration) error + Release func(ctx context.Context, key, token string) error