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

@ -29,19 +29,16 @@ import static org.junit.Assert.assertEquals;
class KillSwitchDocTest extends AbstractJavaTest {
static ActorSystem system;
static Materializer mat;
@BeforeClass
public static void setup() {
system = ActorSystem.create("GraphDSLDocTest");
mat = ActorMaterializer.create(system);
}
@AfterClass
public static void tearDown() {
TestKit.shutdownActorSystem(system);
system = null;
mat = null;
}
@Test
@ -58,7 +55,7 @@ class KillSwitchDocTest extends AbstractJavaTest {
countingSrc
.viaMat(KillSwitches.single(), Keep.right())
.toMat(lastSnk, Keep.both())
.run(mat);
.run(system);
final UniqueKillSwitch killSwitch = stream.first();
final CompletionStage<Integer> completionStage = stream.second();
@ -82,7 +79,7 @@ class KillSwitchDocTest extends AbstractJavaTest {
countingSrc
.viaMat(KillSwitches.single(), Keep.right())
.toMat(lastSnk, Keep.both())
.run(mat);
.run(system);
final UniqueKillSwitch killSwitch = stream.first();
final CompletionStage<Integer> completionStage = stream.second();
@ -105,13 +102,16 @@ class KillSwitchDocTest extends AbstractJavaTest {
final SharedKillSwitch killSwitch = KillSwitches.shared("my-kill-switch");
final CompletionStage<Integer> completionStage =
countingSrc.viaMat(killSwitch.flow(), Keep.right()).toMat(lastSnk, Keep.right()).run(mat);
countingSrc
.viaMat(killSwitch.flow(), Keep.right())
.toMat(lastSnk, Keep.right())
.run(system);
final CompletionStage<Integer> completionStageDelayed =
countingSrc
.delay(Duration.ofSeconds(1), DelayOverflowStrategy.backpressure())
.viaMat(killSwitch.flow(), Keep.right())
.toMat(lastSnk, Keep.right())
.run(mat);
.run(system);
doSomethingElse();
killSwitch.shutdown();
@ -134,9 +134,15 @@ class KillSwitchDocTest extends AbstractJavaTest {
final SharedKillSwitch killSwitch = KillSwitches.shared("my-kill-switch");
final CompletionStage<Integer> completionStage1 =
countingSrc.viaMat(killSwitch.flow(), Keep.right()).toMat(lastSnk, Keep.right()).run(mat);
countingSrc
.viaMat(killSwitch.flow(), Keep.right())
.toMat(lastSnk, Keep.right())
.run(system);
final CompletionStage<Integer> completionStage2 =
countingSrc.viaMat(killSwitch.flow(), Keep.right()).toMat(lastSnk, Keep.right()).run(mat);
countingSrc
.viaMat(killSwitch.flow(), Keep.right())
.toMat(lastSnk, Keep.right())
.run(system);
final Exception error = new Exception("boom!");
killSwitch.abort(error);