@@ -22,12 +22,15 @@ public interface ISupervisor
22
22
{
23
23
IReadOnlyCollection < PID > Children { get ; }
24
24
void EscalateFailure ( PID who , Exception reason ) ;
25
+ void RestartChildren ( params PID [ ] pids ) ;
26
+ void StopChildren ( params PID [ ] pids ) ;
27
+ void ResumeChildren ( params PID [ ] pids ) ;
25
28
}
26
29
27
30
public static class Supervision
28
31
{
29
32
public static ISupervisorStrategy DefaultStrategy { get ; } =
30
- new OneForOneStrategy ( ( who , reason ) => SupervisorDirective . Restart , 10 , TimeSpan . FromSeconds ( 10 ) ) ;
33
+ new OneForOneStrategy ( ( who , reason ) => SupervisorDirective . Restart , 10 , TimeSpan . FromSeconds ( 10 ) ) ;
31
34
}
32
35
33
36
public interface ISupervisorStrategy
@@ -83,25 +86,25 @@ public void HandleFailure(ISupervisor supervisor, PID child, RestartStatistics c
83
86
{
84
87
case SupervisorDirective . Resume :
85
88
//resume the failing child
86
- child . SendSystemMessage ( ResumeMailbox . Instance ) ;
89
+ supervisor . ResumeChildren ( child ) ;
87
90
break ;
88
91
case SupervisorDirective . Restart :
89
92
//restart the failing child
90
93
if ( crs . RequestRestartPermission ( _maxNrOfRetries , _withinTimeSpan ) )
91
94
{
92
95
Console . WriteLine ( $ "Restarting { child . ToShortString ( ) } Reason { reason } ") ;
93
- child . SendSystemMessage ( Restart . Instance ) ;
96
+ supervisor . RestartChildren ( child ) ;
94
97
}
95
98
else
96
99
{
97
100
Console . WriteLine ( $ "Stopping { child . ToShortString ( ) } Reason { reason } ") ;
98
- child . Stop ( ) ;
101
+ supervisor . StopChildren ( child ) ;
99
102
}
100
103
break ;
101
104
case SupervisorDirective . Stop :
102
105
//stop the failing child
103
106
Console . WriteLine ( $ "Stopping { child . ToShortString ( ) } Reason { reason } ") ;
104
- child . Stop ( ) ;
107
+ supervisor . StopChildren ( child ) ;
105
108
break ;
106
109
case SupervisorDirective . Escalate :
107
110
supervisor . EscalateFailure ( child , reason ) ;
0 commit comments