!str #16521 Add ActorRefSink
* also rename the factory for ActorSubscriber props Sink, from apply to actorSubscriber
This commit is contained in:
parent
8f47b6dfcc
commit
946faedd95
11 changed files with 247 additions and 43 deletions
|
|
@ -80,10 +80,10 @@ class ActorSubscriberDocSpec extends AkkaSpec {
|
|||
//#actor-subscriber-usage
|
||||
val N = 117
|
||||
Source(1 to N).map(WorkerPool.Msg(_, replyTo))
|
||||
.runWith(Sink(WorkerPool.props))
|
||||
.runWith(Sink.actorSubscriber(WorkerPool.props))
|
||||
//#actor-subscriber-usage
|
||||
|
||||
receiveN(N).toSet should be((1 to N).map(WorkerPool.Done).toSet)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,8 +7,12 @@ Integration
|
|||
Integrating with Actors
|
||||
=======================
|
||||
|
||||
:class:`ActorPublisher` and :class:`ActorSubscriber` are two traits that provides support for
|
||||
implementing Reactive Streams :class:`Publisher` and :class:`Subscriber` with an :class:`Actor`.
|
||||
For piping the elements of a stream as messages to an ordinary actor you can use the
|
||||
``Sink.actorRef``.
|
||||
|
||||
For more advanced use cases the :class:`ActorPublisher` and :class:`ActorSubscriber` traits are
|
||||
provided to support implementing Reactive Streams :class:`Publisher` and :class:`Subscriber` with
|
||||
an :class:`Actor`.
|
||||
|
||||
These can be consumed by other Reactive Stream libraries or used as a
|
||||
Akka Streams :class:`Source` or :class:`Sink`.
|
||||
|
|
@ -19,6 +23,21 @@ Akka Streams :class:`Source` or :class:`Sink`.
|
|||
because if signals of the Reactive Streams protocol (e.g. ``request``) are lost the
|
||||
the stream may deadlock.
|
||||
|
||||
Sink.actorRef
|
||||
^^^^^^^^^^^^^
|
||||
|
||||
The sink sends the elements of the stream to the given `ActorRef`. If the target actor terminates
|
||||
the stream will be cancelled. When the stream is completed successfully the given ``onCompleteMessage``
|
||||
will be sent to the destination actor. When the stream is completed with failure a ``akka.actor.Status.Failure``
|
||||
message will be sent to the destination actor.
|
||||
|
||||
.. warning::
|
||||
|
||||
There is no back-pressure signal from the destination actor, i.e. if the actor is not consuming
|
||||
the messages fast enough the mailbox of the actor will grow. For potentially slow consumer actors
|
||||
it is recommended to use a bounded mailbox with zero `mailbox-push-timeout-time` or use a rate
|
||||
limiting stage in front of this stage.
|
||||
|
||||
ActorPublisher
|
||||
^^^^^^^^^^^^^^
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue