!str #15950 Add runWith and remove toX

* runWith(drainWithKey) and runWith(tapWithKey) returning the
  materialized drain/tap
* remove toPublisher, toSubscriber, and friends, in favor of using
  runWith
* MaterializedMap is the return type for both flow and graph
* Source[T] return type for Source.apply methods
This commit is contained in:
Patrik Nordwall 2014-10-02 13:34:27 +02:00
parent dc4d121f48
commit 14d3501f92
50 changed files with 379 additions and 419 deletions

View file

@ -23,7 +23,7 @@ class FlowMapAsyncSpec extends AkkaSpec {
"produce future elements" in {
val c = StreamTestKit.SubscriberProbe[Int]()
implicit val ec = system.dispatcher
val p = Source(1 to 3).mapAsync(n Future(n)).publishTo(c)
val p = Source(1 to 3).mapAsync(n Future(n)).connect(SubscriberDrain(c)).run()
val sub = c.expectSubscription()
sub.request(2)
c.expectNext(1)
@ -40,7 +40,7 @@ class FlowMapAsyncSpec extends AkkaSpec {
val p = Source(1 to 50).mapAsync(n Future {
Thread.sleep(ThreadLocalRandom.current().nextInt(1, 10))
n
}).publishTo(c)
}).connect(SubscriberDrain(c)).run()
val sub = c.expectSubscription()
sub.request(1000)
for (n 1 to 50) c.expectNext(n)
@ -54,7 +54,7 @@ class FlowMapAsyncSpec extends AkkaSpec {
val p = Source(1 to 20).mapAsync(n Future {
probe.ref ! n
n
}).publishTo(c)
}).connect(SubscriberDrain(c)).run()
val sub = c.expectSubscription()
// nothing before requested
probe.expectNoMsg(500.millis)
@ -82,7 +82,7 @@ class FlowMapAsyncSpec extends AkkaSpec {
Await.ready(latch, 10.seconds)
n
}
}).publishTo(c)
}).connect(SubscriberDrain(c)).run()
val sub = c.expectSubscription()
sub.request(10)
c.expectError.getMessage should be("err1")
@ -101,7 +101,7 @@ class FlowMapAsyncSpec extends AkkaSpec {
n
}
}).
publishTo(c)
connect(SubscriberDrain(c)).run()
val sub = c.expectSubscription()
sub.request(10)
c.expectError.getMessage should be("err2")