#19440 replace Scala Future usage with CompletionStage in javadsl
This entails:
* adding akka.pattern.PatternCS.* to enable ask etc. with
CompletionStage
* changing RequestContext to offer an ExecutionContextExecutor for the
CompletionStage.*Async combinators
* splitting up akka.stream.Queue for JavaDSL consistency
This commit is contained in:
parent
396f4370e9
commit
4c72495581
118 changed files with 1646 additions and 1379 deletions
|
|
@ -3,10 +3,9 @@
|
|||
*/
|
||||
package docs.stream.io;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.CompletionStage;
|
||||
|
||||
import akka.Done;
|
||||
import akka.actor.ActorSystem;
|
||||
|
|
@ -15,7 +14,6 @@ import akka.stream.io.IOResult;
|
|||
import akka.stream.javadsl.Sink;
|
||||
import akka.stream.javadsl.FileIO;
|
||||
import docs.stream.SilenceSystemOut;
|
||||
import docs.stream.cookbook.RecipeParseLines;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
|
@ -56,10 +54,10 @@ public class StreamFileDocTest {
|
|||
|
||||
try {
|
||||
//#file-source
|
||||
Sink<ByteString, Future<Done>> printlnSink =
|
||||
Sink.foreach(chunk -> System.out.println(chunk.utf8String()));
|
||||
Sink<ByteString, CompletionStage<Done>> printlnSink =
|
||||
Sink.<ByteString> foreach(chunk -> System.out.println(chunk.utf8String()));
|
||||
|
||||
Future<IOResult> ioResult =
|
||||
CompletionStage<IOResult> ioResult =
|
||||
FileIO.fromFile(file)
|
||||
.to(printlnSink)
|
||||
.run(mat);
|
||||
|
|
@ -74,7 +72,7 @@ public class StreamFileDocTest {
|
|||
final File file = File.createTempFile(getClass().getName(), ".tmp");
|
||||
|
||||
try {
|
||||
Sink<ByteString, Future<IOResult>> fileSink =
|
||||
Sink<ByteString, CompletionStage<IOResult>> fileSink =
|
||||
//#custom-dispatcher-code
|
||||
FileIO.toFile(file)
|
||||
.withAttributes(ActorAttributes.dispatcher("custom-blocking-io-dispatcher"));
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
*/
|
||||
package docs.stream.io;
|
||||
|
||||
import java.util.concurrent.CompletionStage;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
import akka.NotUsed;
|
||||
|
|
@ -60,14 +61,14 @@ public class StreamTcpDocTest {
|
|||
{
|
||||
//#echo-server-simple-bind
|
||||
// IncomingConnection and ServerBinding imported from Tcp
|
||||
final Source<IncomingConnection, Future<ServerBinding>> connections =
|
||||
final Source<IncomingConnection, CompletionStage<ServerBinding>> connections =
|
||||
Tcp.get(system).bind("127.0.0.1", 8889);
|
||||
//#echo-server-simple-bind
|
||||
}
|
||||
{
|
||||
|
||||
final InetSocketAddress localhost = SocketUtils.temporaryServerAddress();
|
||||
final Source<IncomingConnection, Future<ServerBinding>> connections =
|
||||
final Source<IncomingConnection, CompletionStage<ServerBinding>> connections =
|
||||
Tcp.get(system).bind(localhost.getHostName(), localhost.getPort()); // TODO getHostString in Java7
|
||||
|
||||
//#echo-server-simple-handle
|
||||
|
|
@ -93,7 +94,7 @@ public class StreamTcpDocTest {
|
|||
|
||||
final TestProbe serverProbe = new TestProbe(system);
|
||||
|
||||
final Source<IncomingConnection,Future<ServerBinding>> connections =
|
||||
final Source<IncomingConnection,CompletionStage<ServerBinding>> connections =
|
||||
Tcp.get(system).bind(localhost.getHostName(), localhost.getPort()); // TODO getHostString in Java7
|
||||
//#welcome-banner-chat-server
|
||||
connections.runForeach(connection -> {
|
||||
|
|
@ -146,14 +147,14 @@ public class StreamTcpDocTest {
|
|||
|
||||
{
|
||||
//#repl-client
|
||||
final Flow<ByteString, ByteString, Future<OutgoingConnection>> connection =
|
||||
final Flow<ByteString, ByteString, CompletionStage<OutgoingConnection>> connection =
|
||||
Tcp.get(system).outgoingConnection("127.0.0.1", 8889);
|
||||
//#repl-client
|
||||
}
|
||||
|
||||
{
|
||||
final Flow<ByteString, ByteString, Future<OutgoingConnection>> connection =
|
||||
Tcp.get(system).outgoingConnection(localhost.getHostName(), localhost.getPort()); // TODO getHostString in Java7
|
||||
final Flow<ByteString, ByteString, CompletionStage<OutgoingConnection>> connection =
|
||||
Tcp.get(system).outgoingConnection(localhost.getHostString(), localhost.getPort());
|
||||
//#repl-client
|
||||
|
||||
final PushStage<String, ByteString> replParser = new PushStage<String, ByteString>() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue