NewOneForOneStrategy 创建一对一策略
(maxRestarts int, within time.Duration, decider Decider)
| 71 | |
| 72 | // NewOneForOneStrategy 创建一对一策略 |
| 73 | func NewOneForOneStrategy(maxRestarts int, within time.Duration, decider Decider) *OneForOneStrategy { |
| 74 | if decider == nil { |
| 75 | decider = DefaultDecider |
| 76 | } |
| 77 | return &OneForOneStrategy{ |
| 78 | MaxRestarts: maxRestarts, |
| 79 | WithinDuration: within, |
| 80 | Decider: decider, |
| 81 | restartWindow: make([]time.Time, 0), |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | // HandleFailure 实现 SupervisorStrategy |
| 86 | func (s *OneForOneStrategy) HandleFailure(system *System, child *PID, msg Message, err any) any { |
no outgoing calls