
s3api
Package server implements the S3-compatible HTTP API, routing requests to the storage backend manager with authentication, rate limiting, and tracing.
Index
- func ExtractClientIP(r *http.Request, trustedProxies []*net.IPNet) string
- func ParseTrustedProxies(cidrs []string) []*net.IPNet
- func WriteS3Error(w http.ResponseWriter, code int, errCode, message string)
- type AdmissionController
- func NewAdmissionController(maxConcurrent int) *AdmissionController
- func NewAdmissionControllerFromSem(sem chan struct{}) *AdmissionController
- func NewSplitAdmissionController(maxReads, maxWrites int) *AdmissionController
- func NewSplitAdmissionControllerFromSem(readSem, writeSem chan struct{}) *AdmissionController
- func (ac *AdmissionController) Middleware(next http.Handler) http.Handler
- func (ac *AdmissionController) SetAdmissionWait(d time.Duration)
- func (ac *AdmissionController) SetShedThreshold(t float64)
- type RateLimiter
- type Server
func ExtractClientIP
ExtractClientIP delegates to httputil.ExtractClientIP.
func ParseTrustedProxies
ParseTrustedProxies delegates to httputil.ParseTrustedProxies.
func WriteS3Error
WriteS3Error is the exported form of writeS3Error so other transport packages (notably the panic-recovery middleware in httputil) can emit a route-appropriate S3-XML 500 without re-implementing the envelope. Matches the httputil.ErrorWriter signature exactly so it slots in as a direct argument.
type AdmissionController
AdmissionController limits the number of concurrent in-flight requests. When readSem and writeSem are set, reads and writes are tracked in separate pools; otherwise the global sem is used for all requests.
func NewAdmissionController
NewAdmissionController creates an admission controller with a single global concurrency limit. The limit must be positive.
func NewAdmissionControllerFromSem
NewAdmissionControllerFromSem creates an admission controller backed by an externally owned semaphore. Use this when background services should share the same concurrency budget as HTTP requests.
func NewSplitAdmissionController
NewSplitAdmissionController creates an admission controller with separate concurrency limits for reads and writes. Both limits must be positive.
func NewSplitAdmissionControllerFromSem
NewSplitAdmissionControllerFromSem creates an admission controller backed by externally owned read and write semaphores.
func (*AdmissionController) Middleware
Middleware wraps an http.Handler with admission control. Requests that exceed the concurrency limit receive 503 SlowDown with Retry-After. When a shed threshold is configured, requests may be probabilistically rejected before the hard limit based on current pool pressure.
func (*AdmissionController) SetAdmissionWait
SetAdmissionWait configures a brief wait duration before rejecting when the semaphore is full. Zero means instant rejection (default).
func (*AdmissionController) SetShedThreshold
SetShedThreshold configures the pressure threshold at which active load shedding begins. Value is a fraction of pool capacity (0.0-1.0). Zero disables shedding (default).
type RateLimiter
RateLimiter provides per-IP token-bucket rate limiting.
func NewRateLimiter
NewRateLimiter creates a rate limiter with the given configuration.
func (*RateLimiter) Allow
Allow checks whether a request from the given IP is allowed.
func (*RateLimiter) Close
Close stops the background cleanup goroutine. Safe to call multiple times.
func (*RateLimiter) Middleware
Middleware wraps an http.Handler with per-IP rate limiting.
func (*RateLimiter) UpdateLimits
UpdateLimits changes the rate and burst and resets all existing per-IP limiters so the new limits take effect immediately.
type Server
Server handles HTTP requests and routes them to the backend manager.
func NewServer
NewServer creates a Server with a stable start timestamp.
func (*Server) GetBucketAuth
GetBucketAuth returns the current bucket authentication registry.
func (*Server) ServeHTTP
ServeHTTP implements http.Handler.
func (*Server) SetBucketAuth
SetBucketAuth atomically replaces the bucket authentication registry. Safe to call concurrently with request handling.
Generated by gomarkdoc