mirror of
https://github.com/lukaszraczylo/traefik-llmgateway.git
synced 2026-11-26 10:06:31 +00:00
feat(router): share the decision breaker through Redis
The decision-model breaker now also reads and writes the fleet breaker when redis.sharedState is on. Routers that use the same decision provider share one key. A client cancel is still not a failure. With the switch off, the decider runs its local code only and makes no store call.
This commit is contained in:
@@ -23,6 +23,7 @@ func (g *Gateway) wireSharedState(cfg *Config) {
|
||||
g.registry.shareBreaker(newSharedBreaker(g.sharedState, sharedKindDiscovery, ids,
|
||||
brk.failureThreshold, brk.openBase, brk.openMax, 2*brk.openMax))
|
||||
}
|
||||
g.shareDecisionBreakers(ids)
|
||||
}
|
||||
|
||||
// maxProviderTimeout is the longest request timeout any provider can run, which bounds how long an in-flight count stays live.
|
||||
@@ -42,3 +43,21 @@ func maxProviderTimeout(cfg *Config) time.Duration {
|
||||
}
|
||||
return longest
|
||||
}
|
||||
|
||||
// shareDecisionBreakers gives every router's decider one fleet breaker. Routers on the same decision provider share a key on purpose.
|
||||
func (g *Gateway) shareDecisionBreakers(ids []string) {
|
||||
if g.registry == nil {
|
||||
return
|
||||
}
|
||||
var brk *sharedBreaker
|
||||
for _, rt := range g.registry.routers {
|
||||
if rt == nil || rt.decision == nil || rt.decision.dec == nil {
|
||||
continue
|
||||
}
|
||||
if brk == nil {
|
||||
brk = newSharedBreaker(g.sharedState, sharedKindDecision, ids,
|
||||
decisionBreakerFails, decisionBreakerOpen, decisionBreakerOpen, 2*decisionBreakerOpen)
|
||||
}
|
||||
rt.decision.dec.share(brk, rt.decision.provider)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user