System wide materializer (#27491)

Introduces a materializer started through an extension and then an implicit
conversion for Scala turning an implicitly available ActorSystem into a
materializer. The Java APIs has been ammended with run-methods accepting
an ActorSystem.
This commit is contained in:
Johan Andrén 2019-08-23 18:19:27 +02:00 committed by GitHub
parent 77d1d33dbc
commit 45c826a218
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
196 changed files with 1148 additions and 1129 deletions

View file

@ -28,19 +28,16 @@ import static org.junit.Assert.assertEquals;
public class StreamPartialGraphDSLDocTest extends AbstractJavaTest {
static ActorSystem system;
static Materializer mat;
@BeforeClass
public static void setup() {
system = ActorSystem.create("StreamPartialGraphDSLDocTest");
mat = ActorMaterializer.create(system);
}
@AfterClass
public static void tearDown() {
TestKit.shutdownActorSystem(system);
system = null;
mat = null;
}
@Test
@ -78,7 +75,7 @@ public class StreamPartialGraphDSLDocTest extends AbstractJavaTest {
return ClosedShape.getInstance();
}));
final CompletionStage<Integer> max = g.run(mat);
final CompletionStage<Integer> max = g.run(system);
// #simple-partial-graph-dsl
assertEquals(Integer.valueOf(3), max.toCompletableFuture().get(3, TimeUnit.SECONDS));
}
@ -119,7 +116,7 @@ public class StreamPartialGraphDSLDocTest extends AbstractJavaTest {
}));
final CompletionStage<Pair<Integer, Integer>> firstPair =
pairs.runWith(Sink.<Pair<Integer, Integer>>head(), mat);
pairs.runWith(Sink.<Pair<Integer, Integer>>head(), system);
// #source-from-partial-graph-dsl
assertEquals(new Pair<>(0, 1), firstPair.toCompletableFuture().get(3, TimeUnit.SECONDS));
}
@ -146,7 +143,7 @@ public class StreamPartialGraphDSLDocTest extends AbstractJavaTest {
// #flow-from-partial-graph-dsl
final CompletionStage<Pair<Integer, String>> matSink =
// #flow-from-partial-graph-dsl
Source.single(1).via(pairs).runWith(Sink.<Pair<Integer, String>>head(), mat);
Source.single(1).via(pairs).runWith(Sink.<Pair<Integer, String>>head(), system);
// #flow-from-partial-graph-dsl
assertEquals(new Pair<>(1, "1"), matSink.toCompletableFuture().get(3, TimeUnit.SECONDS));
@ -163,7 +160,7 @@ public class StreamPartialGraphDSLDocTest extends AbstractJavaTest {
// #source-combine
final CompletionStage<Integer> result =
// #source-combine
sources.runWith(Sink.<Integer, Integer>fold(0, (a, b) -> a + b), mat);
sources.runWith(Sink.<Integer, Integer>fold(0, (a, b) -> a + b), system);
// #source-combine
assertEquals(Integer.valueOf(3), result.toCompletableFuture().get(3, TimeUnit.SECONDS));
@ -184,7 +181,7 @@ public class StreamPartialGraphDSLDocTest extends AbstractJavaTest {
Sink<Integer, NotUsed> sinks =
Sink.combine(sendRemotely, localProcessing, new ArrayList<>(), a -> Broadcast.create(a));
Source.<Integer>from(Arrays.asList(new Integer[] {0, 1, 2})).runWith(sinks, mat);
Source.<Integer>from(Arrays.asList(new Integer[] {0, 1, 2})).runWith(sinks, system);
// #sink-combine
probe.expectMsgEquals(0);
probe.expectMsgEquals(1);