javafmtAll
This commit is contained in:
parent
22a78ee22f
commit
ebd181e037
1 changed files with 33 additions and 33 deletions
|
|
@ -18,50 +18,50 @@ import java.time.Duration;
|
||||||
|
|
||||||
public class ActorFlowCompileTest {
|
public class ActorFlowCompileTest {
|
||||||
|
|
||||||
final ActorSystem<String> system = null;
|
final ActorSystem<String> system = null;
|
||||||
|
|
||||||
static
|
static
|
||||||
// #ask-actor
|
// #ask-actor
|
||||||
class Asking {
|
class Asking {
|
||||||
final String payload;
|
final String payload;
|
||||||
final ActorRef<Reply> replyTo;
|
final ActorRef<Reply> replyTo;
|
||||||
|
|
||||||
public Asking(String payload, ActorRef<Reply> replyTo) {
|
public Asking(String payload, ActorRef<Reply> replyTo) {
|
||||||
this.payload = payload;
|
this.payload = payload;
|
||||||
this.replyTo = replyTo;
|
this.replyTo = replyTo;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// #ask-actor
|
// #ask-actor
|
||||||
static
|
static
|
||||||
// #ask-actor
|
// #ask-actor
|
||||||
class Reply {
|
class Reply {
|
||||||
public final String msg;
|
public final String msg;
|
||||||
|
|
||||||
public Reply(String msg) {
|
public Reply(String msg) {
|
||||||
this.msg = msg;
|
this.msg = msg;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// #ask-actor
|
// #ask-actor
|
||||||
|
|
||||||
{
|
{
|
||||||
|
// #ask
|
||||||
|
final ActorRef<Asking> actorRef = // ???
|
||||||
// #ask
|
// #ask
|
||||||
final ActorRef<Asking> actorRef = // ???
|
null;
|
||||||
// #ask
|
|
||||||
null;
|
|
||||||
|
|
||||||
// #ask
|
// #ask
|
||||||
Duration timeout = Duration.ofSeconds(1);
|
Duration timeout = Duration.ofSeconds(1);
|
||||||
|
|
||||||
// method reference notation
|
// method reference notation
|
||||||
Flow<String, Reply, NotUsed> askFlow = ActorFlow.ask(actorRef, timeout, Asking::new);
|
Flow<String, Reply, NotUsed> askFlow = ActorFlow.ask(actorRef, timeout, Asking::new);
|
||||||
|
|
||||||
// explicit creation of the sent message
|
// explicit creation of the sent message
|
||||||
Flow<String, Reply, NotUsed> askFlowExplicit =
|
Flow<String, Reply, NotUsed> askFlowExplicit =
|
||||||
ActorFlow.ask(actorRef, timeout, (msg, replyTo) -> new Asking(msg, replyTo));
|
ActorFlow.ask(actorRef, timeout, (msg, replyTo) -> new Asking(msg, replyTo));
|
||||||
|
|
||||||
Source.repeat("hello").via(askFlow).map(reply -> reply.msg).runWith(Sink.seq(), system);
|
Source.repeat("hello").via(askFlow).map(reply -> reply.msg).runWith(Sink.seq(), system);
|
||||||
// #ask
|
// #ask
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue