Documentation
¶
Overview ¶
Package idempotencyhttp provides buffered net/http middleware backed by an idempotency.Service. Applications must supply semantic key and canonical fingerprint policies; the package does not infer business identity from unstable transport details.
Index ¶
Constants ¶
View Source
const ( // HeaderKey carries the caller's idempotency key. HeaderKey = "Idempotency-Key" // HeaderOutcome reports the semantic result of the request. HeaderOutcome = "Idempotency-Outcome" // HeaderReplayed is true when the response came from a durable record. HeaderReplayed = "Idempotency-Replayed" // MaxReplayResponseBytes is the largest handler body accepted for replay. MaxReplayResponseBytes = 700 * 1024 )
Variables ¶
View Source
var ErrResponseTooLarge = errors.New("idempotencyhttp: response exceeds replay limit")
ErrResponseTooLarge is returned to a handler whose body crosses its limit.
Functions ¶
This section is empty.
Types ¶
type FingerprintFunc ¶
type FingerprintFunc func(*http.Request) (idempotency.Fingerprint, error)
FingerprintFunc computes the application's canonical request fingerprint.
type Middleware ¶
type Middleware struct {
// contains filtered or unexported fields
}
Middleware durably elects a handler and replays its bounded response.
func New ¶
func New(options Options) (*Middleware, error)
New validates options and constructs middleware.
type Options ¶
type Options struct {
// Service owns the durable state machine.
Service *idempotency.Service
// Lease bounds one handler owner's authority.
Lease time.Duration
// MaxResponseBytes bounds the buffered handler body. Zero defaults to 64 KiB.
MaxResponseBytes int
// ReplayHeaders names response headers to persist and replay.
ReplayHeaders []string
// TransitionTimeout bounds detached panic cleanup. Zero defaults to five seconds.
TransitionTimeout time.Duration
// Key constructs the fully scoped semantic key.
Key KeyFunc
// Fingerprint supplies canonical business-request identity.
Fingerprint FingerprintFunc
}
Options configures durable HTTP handler ownership and replay.
Click to show internal directories.
Click to hide internal directories.