Documentation
¶
Overview ¶
Package limit is the ingress-protection middleware (ADR-0112, F75): it refuses abusive traffic on the data-plane chain BEFORE dataplane.Handler — and therefore before the activator can wake a scaled-to-zero sandbox (the reject returns without ever calling activator.ServeHTTP). Three composable net/http middlewares: a token-bucket rate limit (429), a Content-Length body-size cap (413), and an in-flight concurrency ceiling (503), all RFC 9457 problem+json. It is inserted as the innermost middleware (Recover → RequestID → limit → handler) so rejects stay panic-guarded and X-Request-Id-correlated while still preceding the activator.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
RatePerMin int // token-bucket refill (requests per minute); 0 ⇒ rate limit off
Burst int // bucket depth; 0 ⇒ = RatePerMin
Key Key // clientIP (default) | function
MaxBodyBytes int64 // 413 over this (Content-Length, or a chunked body unless the upstream already answered); 0 ⇒ size cap off
MaxInFlight int // 503 over this many concurrent; 0 ⇒ concurrency cap off
MaxKeys int // LRU cap on the rate-limiter key map; 0 ⇒ defaultMaxKeys
}
Config configures the three limiters. A zero Config is a pass-through.