rename akka-docs dir to docs (#62)

This commit is contained in:
PJ Fanning 2022-12-02 10:49:40 +01:00 committed by GitHub
parent 13dce0ec69
commit 708da8caec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
1029 changed files with 2033 additions and 2039 deletions

View file

@ -0,0 +1,35 @@
/*
* Copyright (C) 2018-2022 Lightbend Inc. <https://www.lightbend.com>
*/
package jdocs.pattern;
import org.apache.pekko.actor.ActorRef;
import org.apache.pekko.actor.ActorRefFactory;
import org.apache.pekko.actor.Props;
import org.apache.pekko.actor.AbstractActor;
import java.time.Duration;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.TimeUnit;
public class SupervisedAskSpec {
public Object execute(
Class<? extends AbstractActor> someActor,
Object message,
Duration timeout,
ActorRefFactory actorSystem)
throws Exception {
// example usage
try {
ActorRef supervisorCreator = SupervisedAsk.createSupervisorCreator(actorSystem);
CompletionStage<Object> finished =
SupervisedAsk.askOf(supervisorCreator, Props.create(someActor), message, timeout);
return finished.toCompletableFuture().get(timeout.toMillis(), TimeUnit.MILLISECONDS);
} catch (Exception e) {
// exception propagated by supervision
throw e;
}
}
}