HandleFailure 实现 SupervisorStrategy
(system *System, child *PID, msg Message, err any)
| 310 | |
| 311 | // HandleFailure 实现 SupervisorStrategy |
| 312 | func (s *CompositeStrategy) HandleFailure(system *System, child *PID, msg Message, err any) any { |
| 313 | // 尝试匹配错误类型 |
| 314 | if e, ok := err.(error); ok { |
| 315 | errType := e.Error() |
| 316 | if strategy, found := s.strategies[errType]; found { |
| 317 | return strategy.HandleFailure(system, child, msg, err) |
| 318 | } |
| 319 | } |
| 320 | |
| 321 | // 使用回退策略 |
| 322 | return s.fallback.HandleFailure(system, child, msg, err) |
| 323 | } |
| 324 | |
| 325 | // ============== 监督树辅助 ============== |
| 326 |
nothing calls this directly
no test coverage detected