Merge pull request #19281 from RayRoestenburg/wip-RayRoestenburg/#19246
#19246 Auto and manual reset and `BackoffOptions`.
This commit is contained in:
commit
7229bb66dd
12 changed files with 808 additions and 441 deletions
|
|
@ -4,6 +4,7 @@
|
|||
package docs.pattern;
|
||||
|
||||
import akka.actor.*;
|
||||
import akka.pattern.Backoff;
|
||||
import akka.pattern.BackoffSupervisor;
|
||||
import akka.testkit.TestActors.EchoActor;
|
||||
//#backoff-imports
|
||||
|
|
@ -14,19 +15,35 @@ import java.util.concurrent.TimeUnit;
|
|||
|
||||
public class BackoffSupervisorDocTest {
|
||||
|
||||
void example (ActorSystem system) {
|
||||
//#backoff
|
||||
void exampleStop (ActorSystem system) {
|
||||
//#backoff-stop
|
||||
final Props childProps = Props.create(EchoActor.class);
|
||||
|
||||
final Props supervisorProps = BackoffSupervisor.props(
|
||||
childProps,
|
||||
"myEcho",
|
||||
Duration.create(3, TimeUnit.SECONDS),
|
||||
Duration.create(30, TimeUnit.SECONDS),
|
||||
0.2); // adds 20% "noise" to vary the intervals slightly
|
||||
Backoff.onStop(
|
||||
childProps,
|
||||
"myEcho",
|
||||
Duration.create(3, TimeUnit.SECONDS),
|
||||
Duration.create(30, TimeUnit.SECONDS),
|
||||
0.2)); // adds 20% "noise" to vary the intervals slightly
|
||||
|
||||
system.actorOf(supervisorProps, "echoSupervisor");
|
||||
//#backoff
|
||||
//#backoff-stop
|
||||
}
|
||||
|
||||
void exampleFailure (ActorSystem system) {
|
||||
//#backoff-fail
|
||||
final Props childProps = Props.create(EchoActor.class);
|
||||
|
||||
final Props supervisorProps = BackoffSupervisor.props(
|
||||
Backoff.onFailure(
|
||||
childProps,
|
||||
"myEcho",
|
||||
Duration.create(3, TimeUnit.SECONDS),
|
||||
Duration.create(30, TimeUnit.SECONDS),
|
||||
0.2)); // adds 20% "noise" to vary the intervals slightly
|
||||
|
||||
system.actorOf(supervisorProps, "echoSupervisor");
|
||||
//#backoff-fail
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue