Merge pull request #18951 from akka/wip-add-sink-last-√
+str - Adds Sink.last and Sink.lastOption to mirror Sink.head and Sin…
This commit is contained in:
commit
fa683e1842
12 changed files with 267 additions and 190 deletions
|
|
@ -113,6 +113,27 @@ object Sink {
|
|||
new Sink(scaladsl.Sink.headOption[In].mapMaterializedValue(
|
||||
_.map(akka.japi.Option.fromScalaOption)(ExecutionContexts.sameThreadExecutionContext)))
|
||||
|
||||
/**
|
||||
* A `Sink` that materializes into a `Future` of the last value received.
|
||||
* If the stream completes before signaling at least a single element, the Future will be failed with a [[NoSuchElementException]].
|
||||
* If the stream signals an error errors before signaling at least a single element, the Future will be failed with the streams exception.
|
||||
*
|
||||
* See also [[lastOption]].
|
||||
*/
|
||||
def last[In](): Sink[In, Future[In]] =
|
||||
new Sink(scaladsl.Sink.last[In])
|
||||
|
||||
/**
|
||||
* A `Sink` that materializes into a `Future` of the optional last value received.
|
||||
* If the stream completes before signaling at least a single element, the value of the Future will be an empty [[akka.japi.Option]].
|
||||
* If the stream signals an error errors before signaling at least a single element, the Future will be failed with the streams exception.
|
||||
*
|
||||
* See also [[head]].
|
||||
*/
|
||||
def lastOption[In](): Sink[In, Future[akka.japi.Option[In]]] =
|
||||
new Sink(scaladsl.Sink.lastOption[In].mapMaterializedValue(
|
||||
_.map(akka.japi.Option.fromScalaOption)(ExecutionContexts.sameThreadExecutionContext)))
|
||||
|
||||
/**
|
||||
* Sends the elements of the stream to the given `ActorRef`.
|
||||
* If the target actor terminates the stream will be canceled.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue