Versions in this module Expand all Collapse all v4 v4.0.0 Jul 11, 2026 Changes in this version + var ErrLegacyInFlightClockSkewPreflightRisk = errors.New("idempotency legacy in-flight clock preflight risk") + var ErrLegacyInFlightReservationMissingToken = errors.New("idempotency reservation token is missing from legacy in-flight record") + var ErrLegacyInFlightTTLMismatch = errors.New("idempotency in-flight ttl mismatch in rollout contract") + var ErrLegacyInFlightTokenMismatch = errors.New("idempotency reservation token mismatch") + func DefaultHash(r *http.Request, body []byte) (string, error) + type HashFunc func(*http.Request, []byte) (string, error) + type KeyFunc func(*http.Request) string + type LegacyInFlightCompatibilityEvent struct + Error string + Key string + Method string + Outcome LegacyInFlightCompatibilityEventName + Path string + StoreType string + func (event LegacyInFlightCompatibilityEvent) MetricLabels() map[string]string + type LegacyInFlightCompatibilityEventName string + const LegacyInFlightCompatibilityEntered + const LegacyInFlightCompatibilityRecovered + const LegacyInFlightCompatibilityRejected + const LegacyInFlightCompatibilityUnknown + type LegacyInFlightCompatibilityEventSink interface + Emit func(context.Context, LegacyInFlightCompatibilityEvent) + type LegacyInFlightCompatibilityHandler func(context.Context, LegacyInFlightCompatibilityEvent) + type LegacyInFlightCompatibilityMetricLabels map[string]string + type LegacyInFlightCompatibilityMetricSink interface + Emit func(context.Context, LegacyInFlightCompatibilityMetricLabels) + type LegacyInFlightCompatibilityMetricSinkFunc func(context.Context, LegacyInFlightCompatibilityMetricLabels) + func (f LegacyInFlightCompatibilityMetricSinkFunc) Emit(ctx context.Context, labels LegacyInFlightCompatibilityMetricLabels) + type LegacyInFlightCompatibilitySinkFunc func(context.Context, LegacyInFlightCompatibilityEvent) + func (f LegacyInFlightCompatibilitySinkFunc) Emit(ctx context.Context, event LegacyInFlightCompatibilityEvent) + type Middleware struct + func New(opts Options) (*Middleware, error) + func (m *Middleware) Handler(next http.Handler) http.Handler + func (m *Middleware) Middleware() func(http.Handler) http.Handler + type Options struct + Clock ports.Clock + FailOnInFlightClockSkewPreflight bool + FailOnInFlightTTLMismatch bool + FailOpen bool + HashFunc HashFunc + HeaderName string + InFlightTTL time.Duration + KeyFunc KeyFunc + KnownInFlightTTLs map[string]time.Duration + LegacyInFlightCompatibilityAsync bool + LegacyInFlightCompatibilityMetricSink LegacyInFlightCompatibilityMetricSink + LegacyInFlightCompatibilityRawKey bool + LegacyInFlightCompatibilitySampleEvery int + LegacyInFlightCompatibilitySink LegacyInFlightCompatibilityEventSink + Logger ports.Logger + MaxBodyBytes int64 + MaxResponseBytes int64 + OnError func(error) + OnLegacyInFlightCompatibility LegacyInFlightCompatibilityHandler + OnOutcome OutcomeHandler + ReplayHeaderName string + RequireKey bool + ResponseHeaderAllow []string + ResponseHeaderDeny []string + ShouldHandle func(*http.Request) bool + ShouldStore func(status int) bool + StorageKeyFunc StorageKeyFunc + Store Store + TTL time.Duration + type OutcomeEvent struct + FailOpen bool + Method string + Outcome OutcomeEventName + Status int + StoreType string + func (event OutcomeEvent) MetricLabels() map[string]string + type OutcomeEventName string + const IdempotencyOutcomeAmbiguous + const IdempotencyOutcomeCompletedReleased + const IdempotencyOutcomeCompletedStored + const IdempotencyOutcomeConflict + const IdempotencyOutcomeFailOpen + const IdempotencyOutcomeInFlight + const IdempotencyOutcomeInvalidRequest + const IdempotencyOutcomeLookupFailed + const IdempotencyOutcomeMissingKey + const IdempotencyOutcomePersistenceFailed + const IdempotencyOutcomeReplayed + const IdempotencyOutcomeReservationFailed + const IdempotencyOutcomeReservationUnavailable + const IdempotencyOutcomeResponseTooLarge + type OutcomeHandler func(context.Context, OutcomeEvent) + type Record struct + Body []byte + CreatedAt time.Time + Header http.Header + RequestHash string + ReservationToken string + State State + Status int + type ReleasableStore interface + type ReservationReleaser interface + ReleaseReservation func(ctx context.Context, key string, token string) error + type State int + const StateAmbiguous + const StateCompleted + const StateInFlight + const StateUnknown + type StorageKeyFunc func(*http.Request, string) string + func TenantScopedStorageKeyFunc() StorageKeyFunc + type Store interface + Get func(ctx context.Context, key string) (Record, bool, error) + Save func(ctx context.Context, key string, record Record, ttl time.Duration) error + TryBegin func(ctx context.Context, key string, record Record, ttl time.Duration) (bool, error) Other modules containing this package github.com/aatuh/api-toolkit/v2 github.com/aatuh/api-toolkit/v3