Doc example of Streams watch operator, #25468 (#28752)

This commit is contained in:
Patrik Nordwall 2020-03-26 18:00:58 +01:00 committed by GitHub
parent 5605f04cb7
commit 37d87811b5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 53 additions and 1 deletions

View file

@ -4,6 +4,7 @@
package jdocs.stream.operators;
import akka.actor.ActorRef;
import akka.actor.ActorSystem;
import akka.japi.pf.PFBuilder;
import akka.stream.javadsl.Flow;
@ -41,7 +42,6 @@ import akka.stream.Attributes;
// #log
import java.time.Duration;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.concurrent.CompletableFuture;
@ -426,4 +426,18 @@ class SourceOrFlow {
// -1
// #dropWhile
}
void watchExample() {
// #watch
final ActorRef ref = someActor();
Flow<String, String, NotUsed> flow =
Flow.of(String.class)
.watch(ref)
.recover(akka.stream.WatchedActorTerminatedException.class, () -> ref + " terminated");
// #watch
}
private ActorRef someActor() {
return null;
}
}