feat(multiplayer): add degraded admission mode

This commit is contained in:
Josh Creek
2026-09-01 19:14:28 +01:00
parent d04523accd
commit 6366b5e1f6
6 changed files with 196 additions and 1 deletions
+11
View File
@@ -127,6 +127,7 @@ type Service struct {
RankedProfileProvider RankedProfileProvider
TierPolicy domain.TierPolicy
RateLimiter *RateLimiter
Admission AdmissionController
// Log receives a credential-safe structured event for lifecycle-relevant
// reads and mutations. Nil
// is a valid, silent no-op -- every call site must stay optional so
@@ -213,6 +214,16 @@ func (s *Service) Handler() http.Handler {
mux.ServeHTTP(w, r)
})
}
if s.Admission != nil {
admissionHandler := handler
handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if operation := admissionOperation(r.URL.Path, r.Method); operation != "" && !s.Admission.Allow(operation) {
writeError(w, http.StatusServiceUnavailable, "service_degraded")
return
}
admissionHandler.ServeHTTP(w, r)
})
}
if s.Metrics == nil {
return handler
}