+act #20936 add CompletionStage API to CircuitBreaker (#20937)

This commit is contained in:
Konrad Malawski 2016-07-14 14:03:04 +02:00 committed by GitHub
parent 08e4ee0e6f
commit 400402f76c
4 changed files with 70 additions and 21 deletions

View file

@ -51,27 +51,16 @@ public class DangerousJavaActor extends UntypedActor {
if (message instanceof String) {
String m = (String) message;
if ("is my middle name".equals(m)) {
pipe(breaker.callWithCircuitBreaker(
new Callable<Future<String>>() {
public Future<String> call() throws Exception {
return future(
new Callable<String>() {
public String call() {
return dangerousCall();
}
}, getContext().dispatcher());
}
}), getContext().dispatcher()).to(getSender());
pipe(
breaker.callWithCircuitBreaker(() ->
future(() -> dangerousCall(), getContext().dispatcher())
), getContext().dispatcher()
).to(getSender());
}
if ("block for me".equals(m)) {
getSender().tell(breaker
.callWithSyncCircuitBreaker(
new Callable<String>() {
@Override
public String call() throws Exception {
return dangerousCall();
}
}), getSelf());
() -> dangerousCall()), getSelf());
}
}
}