(primary string, health map[string]bool)
| 625 | } |
| 626 | |
| 627 | func (s *Server) buildFallback(primary string, health map[string]bool) []types.RouteDecision { |
| 628 | out := make([]types.RouteDecision, 0) |
| 629 | for _, rule := range s.cfg.Reliability.FallbackRules { |
| 630 | if rule.FromBackend != primary { |
| 631 | continue |
| 632 | } |
| 633 | backendCfg, ok := s.cfg.BackendByName(rule.FallbackTo) |
| 634 | if !ok { |
| 635 | continue |
| 636 | } |
| 637 | if !router.BackendHealthOK(health, backendCfg.Name) { |
| 638 | continue |
| 639 | } |
| 640 | out = append(out, types.RouteDecision{ |
| 641 | BackendName: backendCfg.Name, |
| 642 | Reason: "fallback-from-" + primary, |
| 643 | EstimatedCost: backendCfg.Cost.Unit, |
| 644 | }) |
| 645 | } |
| 646 | return out |
| 647 | } |
| 648 | |
| 649 | func fallbackReason(triggered bool) string { |
| 650 | if triggered { |
nothing calls this directly
no test coverage detected