Documentation
¶
Index ¶
Constants ¶
const ( // RetryAfterSeconds is the Retry-After header value for decode admission 429 responses. RetryAfterSeconds = "1" // AdmissionRejectedWireMessage is the stable client-safe message for decode admission saturation. AdmissionRejectedWireMessage = "decode admission capacity exceeded" )
Variables ¶
var ( // ErrOverweight is returned when weight exceeds the limiter's max inflight byte budget. ErrOverweight = errors.New("decodeqos: weight exceeds inflight byte budget") // ErrInvalidWeight is returned when weight is negative. ErrInvalidWeight = errors.New("decodeqos: negative weight") )
Functions ¶
func Guard ¶
Guard runs fn while holding an admission release and always releases exactly once (including when fn panics). Use around protocol adapter Decode only.
func HTTPStatus ¶
HTTPStatus maps TryAcquire outcome to an HTTP status code. Zero means admission succeeded.
Types ¶
type Admission ¶
type Admission interface {
TryAcquire(ctx context.Context, weight int64) (release func(), ok bool, err error)
Acquire(ctx context.Context, weight int64) (release func(), err error)
}
Admission bounds concurrent frontend protocol decode/materialization work and weighted in-flight decode bytes while decode is active.
type Decision ¶
Decision is the shared admission-reject outcome for frontend handlers. Status 0 means admission succeeded (no reject response).
type Limiter ¶
type Limiter struct {
// contains filtered or unexported fields
}
Limiter bounds concurrent frontend protocol decode/materialization and weighted in-flight decode bytes while decode is active. Body ReadAll and JSON preflight run before admission.
func New ¶
New returns nil when maxConcurrent <= 0 or maxInflightBytes <= 0 so callers can keep zero-value behavior unlimited. Standard distribution wiring always passes positive finite values.