feat(registry): share the discovery breaker through Redis

A provider whose discovery fails often enough now reads as unhealthy on every pod when redis.sharedState is on. The shared breaker uses the same threshold and open times as the local one. The discovered model sets stay local. With the switch off, the provider state runs its local code only and makes no store call.
This commit is contained in:
2026-11-26 03:29:09 +00:00
parent a6c2821a29
commit 0c2445cb1a
3 changed files with 122 additions and 2 deletions
+8
View File
@@ -15,6 +15,14 @@ func (g *Gateway) wireSharedState(cfg *Config) {
if g.concurrency != nil {
g.concurrency.share(newSharedInflight(g.sharedState, ids, maxProviderTimeout(cfg)))
}
if g.registry != nil {
brk, err := validateBreakerConfig(cfg.Breaker)
if err != nil {
brk = breakerConfig{failureThreshold: defaultBreakerFailureThreshold, openBase: defaultBreakerOpenDuration, openMax: defaultBreakerMaxOpenDuration}
}
g.registry.shareBreaker(newSharedBreaker(g.sharedState, sharedKindDiscovery, ids,
brk.failureThreshold, brk.openBase, brk.openMax, 2*brk.openMax))
}
}
// maxProviderTimeout is the longest request timeout any provider can run, which bounds how long an in-flight count stays live.