Documentation
¶
Overview ¶
Package idempotencyredis provides Redis-backed idempotency storage.
Index ¶
- type LegacyInFlightRecoveryEvent
- type LegacyInFlightRecoveryHandler
- type LegacyInFlightRecoveryHandlerFunc
- type LegacyInFlightRecoveryOutcome
- type Options
- type Store
- func (s *Store) Get(ctx context.Context, key string) (ports.IdempotencyRecord, bool, error)
- func (s *Store) Release(ctx context.Context, key string) error
- func (s *Store) ReleaseReservation(ctx context.Context, key, token string) error
- func (s *Store) Save(ctx context.Context, key string, record ports.IdempotencyRecord, ...) error
- func (s *Store) TryBegin(ctx context.Context, key string, record ports.IdempotencyRecord, ...) (bool, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LegacyInFlightRecoveryEvent ¶ added in v2.1.0
type LegacyInFlightRecoveryEvent struct {
// Key is hashed by default. It contains the raw key only when
// Options.LegacyInFlightRecoveryRawKey is explicitly enabled.
Key string
// KeyHash always contains the hashed key value when a key is available.
KeyHash string
// RawKey is populated only when LegacyInFlightRecoveryRawKey is explicitly enabled.
RawKey string
Outcome LegacyInFlightRecoveryOutcome
}
LegacyInFlightRecoveryEvent carries structured context for legacy token recovery.
type LegacyInFlightRecoveryHandler ¶ added in v2.1.0
type LegacyInFlightRecoveryHandler interface {
HandleLegacyInFlightRecovery(context.Context, LegacyInFlightRecoveryEvent)
}
LegacyInFlightRecoveryHandler is invoked when a tokenless legacy recovery branch is encountered. Keep handlers fast and non-blocking.
type LegacyInFlightRecoveryHandlerFunc ¶ added in v2.1.0
type LegacyInFlightRecoveryHandlerFunc func(context.Context, LegacyInFlightRecoveryEvent)
LegacyInFlightRecoveryHandlerFunc adapts a function into a LegacyInFlightRecoveryHandler.
func (LegacyInFlightRecoveryHandlerFunc) HandleLegacyInFlightRecovery ¶ added in v2.1.0
func (f LegacyInFlightRecoveryHandlerFunc) HandleLegacyInFlightRecovery(ctx context.Context, event LegacyInFlightRecoveryEvent)
HandleLegacyInFlightRecovery calls f when f is not nil.
type LegacyInFlightRecoveryOutcome ¶ added in v2.1.0
type LegacyInFlightRecoveryOutcome string
LegacyInFlightRecoveryOutcome captures whether a legacy tokenless recovery path was exercised in the adapter.
const ( // LegacyInFlightRecoveryRecovered indicates tokenless legacy in-flight state // was intentionally migrated away. LegacyInFlightRecoveryRecovered LegacyInFlightRecoveryOutcome = "legacy_in_flight_recovered" // LegacyInFlightRecoveryTokenMismatch indicates a token was supplied for a // tokenless legacy in-flight record and release was rejected. LegacyInFlightRecoveryTokenMismatch LegacyInFlightRecoveryOutcome = "legacy_in_flight_token_mismatch" )
type Options ¶
type Options struct {
KeyPrefix string
// OnLegacyInFlightRecovery receives structured recovery telemetry.
OnLegacyInFlightRecovery LegacyInFlightRecoveryHandler
// LegacyInFlightRecoveryRawKey exposes raw idempotency keys in recovery events.
// Defaults to false so adapter telemetry receives hashed keys.
LegacyInFlightRecoveryRawKey bool
}
Options configures Redis-backed idempotency storage.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store implements ports.IdempotencyStore using Redis.
func New ¶
func New(client redis.UniversalClient, opts Options) *Store
New constructs a Redis-backed idempotency store.
func (*Store) Release ¶ added in v2.1.0
Release removes an in-flight idempotency reservation by key.
This method preserves the v2 compatibility contract. New middleware uses ReleaseReservation when available so tokened reservations are not released by unrelated requests.
func (*Store) ReleaseReservation ¶ added in v2.1.0
ReleaseReservation removes a stored idempotency reservation when token matches.