Versions in this module Expand all Collapse all v0 v0.1.0 Jul 29, 2026 Changes in this version + var ErrCodec = errors.New("idempotency codec failure") + var ErrFingerprintMismatch = errors.New("idempotency fingerprint mismatch") + var ErrInProgress = errors.New("operation already in progress") + var ErrInvalidKey = errors.New("invalid idempotency key") + var ErrOwnershipLost = errors.New("idempotency ownership lost") + var ErrRecordExpired = errors.New("idempotency record expired") + var ErrResultTooLarge = errors.New("idempotency result too large") + var ErrStoreUnavailable = errors.New("idempotency store unavailable") + var ErrWaitTimeout = errors.New("timed out waiting for operation") + func FingerprintBytes(data []byte) string + func FingerprintJSON(value any) string + func FingerprintString(value string) string + func ValidateKey(key Key) error + type AcquireRequest struct + Fingerprint string + Key Key + LeaseDuration time.Duration + Metadata map[string]string + Now time.Time + TTL time.Duration + type AcquireResult struct + Acquired bool + Reclaimed bool + Record Record[T] + type CallOption func(*callConfig) + func WithFingerprint(value string) CallOption + func WithMetadata(value map[string]string) CallOption + type CompleteRequest struct + Fence Fence + Key Key + Now time.Time + OwnerToken OwnerToken + TTL time.Duration + Value []byte + type ConflictError struct + ExistingFingerprint string + IncomingFingerprint string + Key Key + func (e *ConflictError) Error() string + func (e *ConflictError) Unwrap() error + type ErrorClass string + const ErrorPermanent + const ErrorRetryable + const ErrorUnknown + type ErrorClassifier interface + Classify func(error) ErrorClass + type Event struct + Attempt int + Duration time.Duration + KeyHash string + Namespace string + Owner bool + Replayed bool + State State + Store string + type Executor struct + func New[T any](options ...Option[T]) *Executor[T] + func (e *Executor[T]) Do(ctx context.Context, key Key, operation func(context.Context) (T, error)) (Result[T], error) + func (e *Executor[T]) DoWithOptions(ctx context.Context, key Key, operation func(context.Context) (T, error), ...) (Result[T], error) + func (e *Executor[T]) Renew(ctx context.Context, key Key, token OwnerToken, fence Fence) error + type FailRequest struct + Delete bool + Error string + Fence Fence + Key Key + Now time.Time + OwnerToken OwnerToken + TTL time.Duration + type FailurePolicy string + const CacheAllFailures + const CachePermanentFailures + const CacheSelectedFailures + const NeverCacheFailures + type Fence uint64 + type FingerprintPolicy string + const FingerprintDisabled + const FingerprintOptional + const FingerprintRequired + type Hooks struct + OnAcquire func(Event) + OnComplete func(Event, T) + OnConflict func(Event) + OnFailure func(Event, error) + OnOwnershipLost func(Event) + OnReplay func(Event) + OnStaleReclaimed func(Event) + OnWait func(Event) + type Key string + func JoinKey(parts ...string) Key + type KeyHasher func(Key) Key + type Option func(*config[T]) + func WithCodec[T any](value codec.Codec[T]) Option[T] + func WithErrorClassifier[T any](value ErrorClassifier) Option[T] + func WithFailurePolicy[T any](value FailurePolicy) Option[T] + func WithFailureTTL[T any](value time.Duration) Option[T] + func WithFingerprintPolicy[T any](value FingerprintPolicy) Option[T] + func WithHeartbeatInterval[T any](value time.Duration) Option[T] + func WithHooks[T any](value Hooks[T]) Option[T] + func WithKeyHasher[T any](value KeyHasher) Option[T] + func WithLeaseDuration[T any](value time.Duration) Option[T] + func WithMaxKeyLength[T any](value int) Option[T] + func WithMaxResultSize[T any](value int) Option[T] + func WithMinKeyLength[T any](value int) Option[T] + func WithNamespace[T any](value string) Option[T] + func WithPanicPolicy[T any](value PanicPolicy) Option[T] + func WithPendingPolicy[T any](value PendingPolicy) Option[T] + func WithStore[T any](store Store[T]) Option[T] + func WithSuccessTTL[T any](value time.Duration) Option[T] + func WithTTL[T any](value time.Duration) Option[T] + func WithWaitTimeout[T any](value time.Duration) Option[T] + type OwnerToken string + type Ownership interface + Lost func() <-chan struct{} + func OwnershipFromContext(ctx context.Context) (context.Context, Ownership) + type PanicPolicy string + const PanicAsFailure + const PanicPropagate + type PendingPolicy string + const PendingPoll + const PendingReject + const PendingReturn + const PendingWait + type Record struct + Attempt int + CompletedAt time.Time + CreatedAt time.Time + Error string + ExpiresAt time.Time + Fence Fence + Fingerprint string + Key Key + LeaseExpiresAt time.Time + Metadata map[string]string + OwnerToken OwnerToken + State State + UpdatedAt time.Time + Value []byte + func (r Record[T]) Expired(now time.Time) bool + func (r Record[T]) LeaseExpired(now time.Time) bool + type RenewRequest struct + Fence Fence + Key Key + LeaseDuration time.Duration + Now time.Time + OwnerToken OwnerToken + type Result struct + Attempt int + CompletedAt time.Time + CreatedAt time.Time + ExpiresAt time.Time + Owner bool + Replayed bool + State State + Value T + func Do[T any](ctx context.Context, executor *Executor[T], key Key, ...) (Result[T], error) + func (r Result[T]) Terminal() bool + type State string + const StateCompleted + const StateExpired + const StateFailed + const StatePending + type Store interface + Acquire func(ctx context.Context, request AcquireRequest) (AcquireResult[T], error) + Cleanup func(ctx context.Context, now time.Time, limit int) (int, error) + Complete func(ctx context.Context, request CompleteRequest[T]) error + Delete func(ctx context.Context, key Key) error + Fail func(ctx context.Context, request FailRequest) error + Get func(ctx context.Context, key Key) (Record[T], error) + Renew func(ctx context.Context, request RenewRequest) error + type StoredError struct + Message string + func (e *StoredError) Error() string