!str - 18808 - Removes Sink.fanoutPublisher and makes Sink.publisher specify number of subscribers

Sink.publisher now takes a max number of Subscribers and
the elasticity between concurrent Subscribers.
This commit is contained in:
Viktor Klang 2015-10-30 16:00:44 +01:00
parent 33444c572b
commit f839a1f85d
54 changed files with 246 additions and 238 deletions

View file

@ -159,11 +159,11 @@ private[http] object StreamUtils {
case Nil Nil
case Seq(one) Vector(input.via(one))
case multiple
val (fanoutSub, fanoutPub) = Source.subscriber[ByteString].toMat(Sink.fanoutPublisher(16, 16))(Keep.both).run()
val (fanoutSub, fanoutPub) = Source.subscriber[ByteString].toMat(Sink.publisher(transformers.size))(Keep.both).run()
val sources = transformers.map { flow
// Doubly wrap to ensure that subscription to the running publisher happens before the final sources
// are exposed, so there is no race
Source(Source(fanoutPub).viaMat(flow)(Keep.right).runWith(Sink.publisher))
Source(Source(fanoutPub).viaMat(flow)(Keep.right).runWith(Sink.publisher(1)))
}
// The fanout publisher must be wired to the original source after all fanout subscribers have been subscribed
input.runWith(Sink(fanoutSub))

View file

@ -406,7 +406,7 @@ class ClientServerSpec extends WordSpec with Matchers with BeforeAndAfterAll {
def acceptConnection(): (TestSubscriber.ManualProbe[HttpRequest], TestPublisher.ManualProbe[HttpResponse]) = {
connSourceSub.request(1)
val incomingConnection = connSource.expectNext()
val sink = Sink.publisher[HttpRequest]
val sink = Sink.publisher[HttpRequest](1)
val source = Source.subscriber[HttpResponse]
val handler = Flow.fromSinkAndSourceMat(sink, source)(Keep.both)