!str #16520 Add ActorRefSource
* and rename the factory for ActorPublisherSource, from Source.apply to Source.actorPublisher * including internal buffer, with OverflowStrategy * support to complete/fail stream
This commit is contained in:
parent
946faedd95
commit
f4ed62b84c
13 changed files with 318 additions and 33 deletions
|
|
@ -76,7 +76,7 @@ class ActorPublisherDocSpec extends AkkaSpec {
|
|||
testActor ! s
|
||||
|
||||
//#actor-publisher-usage
|
||||
val jobManagerSource = Source[JobManager.Job](JobManager.props)
|
||||
val jobManagerSource = Source.actorPublisher[JobManager.Job](JobManager.props)
|
||||
val ref = Flow[JobManager.Job]
|
||||
.map(_.payload.toUpperCase)
|
||||
.map { elem => println(elem); elem }
|
||||
|
|
|
|||
|
|
@ -8,7 +8,8 @@ Integrating with Actors
|
|||
=======================
|
||||
|
||||
For piping the elements of a stream as messages to an ordinary actor you can use the
|
||||
``Sink.actorRef``.
|
||||
``Sink.actorRef``. Messages can be sent to a stream via the :class:`ActorRef` that is
|
||||
materialized by ``Source.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
|
||||
|
|
@ -23,10 +24,29 @@ 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.
|
||||
|
||||
Source.actorRef
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
Messages sent to the actor that is materialized by ``Source.actorRef`` will be emitted to the
|
||||
stream if there is demand from downstream, otherwise they will be buffered until request for
|
||||
demand is received.
|
||||
|
||||
Depending on the defined :class:`OverflowStrategy` it might drop elements if there is no space
|
||||
available in the buffer.
|
||||
|
||||
The stream can be completed successfully by sending ``akka.actor.PoisonPill`` or
|
||||
``akka.actor.Status.Success`` to the actor reference.
|
||||
|
||||
The stream can be completed with failure by sending ``akka.actor.Status.Failure`` to the
|
||||
actor reference.
|
||||
|
||||
The actor will be stopped when the stream is completed, failed or cancelled from downstream,
|
||||
i.e. you can watch it to get notified when that happens.
|
||||
|
||||
Sink.actorRef
|
||||
^^^^^^^^^^^^^
|
||||
|
||||
The sink sends the elements of the stream to the given `ActorRef`. If the target actor terminates
|
||||
The sink sends the elements of the stream to the given :class:`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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue