Packages

object Sink

Source
Sink.scala
Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Sink
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. def actorRef[T](ref: ActorRef, onCompleteMessage: Any, onFailureMessage: (Throwable) => Any): Sink[T, NotUsed]

    INTERNAL API

    INTERNAL API

    Sends the elements of the stream to the given ActorRef. If the target actor terminates the stream will be canceled. When the stream is completed successfully the given onCompleteMessage will be sent to the destination actor. When the stream is completed with failure the onFailureMessage will be invoked and its result will be sent to the destination actor.

    It will request at most maxInputBufferSize number of elements from upstream, but 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 operator in front of this Sink.

  5. def actorRefWithBackpressure[T](ref: ActorRef, onInitMessage: Any, onCompleteMessage: Any, onFailureMessage: (Throwable) => Any): Sink[T, NotUsed]

    Sends the elements of the stream to the given ActorRef that sends back back-pressure signal.

    Sends the elements of the stream to the given ActorRef that sends back back-pressure signal. First element is always onInitMessage, then stream is waiting for acknowledgement message from the given actor which means that it is ready to process elements. It also requires an ack message after each stream element to make backpressure work. This variant will consider any message as ack message.

    If the target actor terminates the stream will be canceled. When the stream is completed successfully the given onCompleteMessage will be sent to the destination actor. When the stream is completed with failure - result of onFailureMessage(throwable) function will be sent to the destination actor.

  6. def actorRefWithBackpressure[T](ref: ActorRef, onInitMessage: Any, ackMessage: Any, onCompleteMessage: Any, onFailureMessage: (Throwable) => Any): Sink[T, NotUsed]

    Sends the elements of the stream to the given ActorRef that sends back back-pressure signal.

    Sends the elements of the stream to the given ActorRef that sends back back-pressure signal. First element is always onInitMessage, then stream is waiting for acknowledgement message ackMessage from the given actor which means that it is ready to process elements. It also requires ackMessage message after each stream element to make backpressure work.

    If the target actor terminates the stream will be canceled. When the stream is completed successfully the given onCompleteMessage will be sent to the destination actor. When the stream is completed with failure - result of onFailureMessage(throwable) function will be sent to the destination actor.

  7. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  8. def asPublisher[T](fanout: Boolean): Sink[T, Publisher[T]]

    A Sink that materializes into a org.reactivestreams.Publisher.

    A Sink that materializes into a org.reactivestreams.Publisher.

    If fanout is true, the materialized Publisher will support multiple Subscribers and the size of the inputBuffer configured for this operator becomes the maximum number of elements that the fastest org.reactivestreams.Subscriber can be ahead of the slowest one before slowing the processing down due to back pressure.

    If fanout is false then the materialized Publisher will only support a single Subscriber and reject any additional Subscribers.

  9. def cancelled[T]: Sink[T, NotUsed]

    A Sink that immediately cancels its upstream after materialization.

  10. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
  11. def collection[T, That](implicit cbf: Factory[T, That with Iterable[_]]): Sink[T, Future[That]]

    A Sink that keeps on collecting incoming elements until upstream terminates.

    A Sink that keeps on collecting incoming elements until upstream terminates. As upstream may be unbounded, Flow[T].take or the stricter Flow[T].limit (and their variants) may be used to ensure boundedness. Materializes into a Future of That[T] containing all the collected elements. That[T] is limited to the limitations of the CanBuildFrom associated with it. For example, Seq is limited to Int.MaxValue elements. See [The Architecture of Scala 2.13's Collections](https://docs.scala-lang.org/overviews/core/architecture-of-scala-213-collections.html) for more info. This Sink will cancel the stream after having received that many elements.

    See also Flow.limit, Flow.limitWeighted, Flow.take, Flow.takeWithin, Flow.takeWhile

  12. def combine[T, U](first: Sink[U, _], second: Sink[U, _], rest: Sink[U, _]*)(strategy: (Int) => Graph[UniformFanOutShape[T, U], NotUsed]): Sink[T, NotUsed]

    Combine several sinks with fan-out strategy like Broadcast or Balance and returns Sink.

  13. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  14. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  15. def fold[U, T](zero: U)(f: (U, T) => U): Sink[T, Future[U]]

    A Sink that will invoke the given function for every received element, giving it its previous output (or the given zero value) and the element as input.

    A Sink that will invoke the given function for every received element, giving it its previous output (or the given zero value) and the element as input. The returned scala.concurrent.Future will be completed with value of the final function evaluation when the input stream ends, or completed with Failure if there is a failure signaled in the stream.

    See also

    #foldAsync

  16. def foldAsync[U, T](zero: U)(f: (U, T) => Future[U]): Sink[T, Future[U]]

    A Sink that will invoke the given asynchronous function for every received element, giving it its previous output (or the given zero value) and the element as input.

    A Sink that will invoke the given asynchronous function for every received element, giving it its previous output (or the given zero value) and the element as input. The returned scala.concurrent.Future will be completed with value of the final function evaluation when the input stream ends, or completed with Failure if there is a failure signaled in the stream.

    See also

    #fold

  17. def foreach[T](f: (T) => Unit): Sink[T, Future[Done]]

    A Sink that will invoke the given procedure for each received element.

    A Sink that will invoke the given procedure for each received element. The sink is materialized into a scala.concurrent.Future which will be completed with Success when reaching the normal end of the stream, or completed with Failure if there is a failure signaled in the stream.

  18. def foreachAsync[T](parallelism: Int)(f: (T) => Future[Unit]): Sink[T, Future[Done]]

    A Sink that will invoke the given procedure asynchronously for each received element.

    A Sink that will invoke the given procedure asynchronously for each received element. The sink is materialized into a scala.concurrent.Future which will be completed with Success when reaching the normal end of the stream, or completed with Failure if there is a failure signaled in the stream.

  19. def fromGraph[T, M](g: Graph[SinkShape[T], M]): Sink[T, M]

    A graph with the shape of a sink logically is a sink, this method makes it so also in type.

  20. def fromMaterializer[T, M](factory: (Materializer, Attributes) => Sink[T, M]): Sink[T, Future[M]]

    Defers the creation of a Sink until materialization.

    Defers the creation of a Sink until materialization. The factory function exposes Materializer which is going to be used during materialization and Attributes of the Sink returned by this method.

  21. def fromSubscriber[T](subscriber: Subscriber[T]): Sink[T, NotUsed]

    Helper to create Sink from Subscriber.

  22. def futureSink[T, M](future: Future[Sink[T, M]]): Sink[T, Future[M]]

    Turn a Future[Sink] into a Sink that will consume the values of the source when the future completes successfully.

    Turn a Future[Sink] into a Sink that will consume the values of the source when the future completes successfully. If the Future is completed with a failure the stream is failed.

    The materialized future value is completed with the materialized value of the future sink or failed with a NeverMaterializedException if upstream fails or downstream cancels before the future has completed.

  23. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  24. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  25. def head[T]: Sink[T, Future[T]]

    A Sink that materializes into a Future of the first value received.

    A Sink that materializes into a Future of the first 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 headOption.

  26. def headOption[T]: Sink[T, Future[Option[T]]]

    A Sink that materializes into a Future of the optional first value received.

    A Sink that materializes into a Future of the optional first value received. If the stream completes before signaling at least a single element, the value of the Future will be None. 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.

  27. def ignore: Sink[Any, Future[Done]]

    A Sink that will consume the stream and discard the elements.

  28. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  29. def last[T]: Sink[T, Future[T]]

    A Sink that materializes into a Future of the last value received.

    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, the Future will be failed with the stream's exception.

    See also lastOption, takeLast.

  30. def lastOption[T]: Sink[T, Future[Option[T]]]

    A Sink that materializes into a Future of the optional last value received.

    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 None. If the stream signals an error, the Future will be failed with the stream's exception.

    See also last, takeLast.

  31. def lazyFutureSink[T, M](create: () => Future[Sink[T, M]]): Sink[T, Future[M]]

    Defers invoking the create function to create a future sink until there is a first element passed from upstream.

    Defers invoking the create function to create a future sink until there is a first element passed from upstream.

    The materialized future value is completed with the materialized value of the created sink when that has successfully been materialized.

    If the create function throws or returns a future that is failed, or the stream fails to materialize, in this case the materialized future value is failed with a pekko.stream.NeverMaterializedException.

  32. def lazySink[T, M](create: () => Sink[T, M]): Sink[T, Future[M]]

    Defers invoking the create function to create a sink until there is a first element passed from upstream.

    Defers invoking the create function to create a sink until there is a first element passed from upstream.

    The materialized future value is completed with the materialized value of the created sink when that has successfully been materialized.

    If the create function throws or returns or the stream fails to materialize, in this case the materialized future value is failed with a pekko.stream.NeverMaterializedException.

  33. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  34. def never: Sink[Any, Future[Done]]

    A Sink that will always backpressure never cancel and never consume any elements from the stream.

  35. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  36. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  37. def onComplete[T](callback: (Try[Done]) => Unit): Sink[T, NotUsed]

    A Sink that when the flow is completed, either through a failure or normal completion, apply the provided function with scala.util.Success or scala.util.Failure.

  38. def queue[T](): Sink[T, SinkQueueWithCancel[T]]

    Creates a Sink that is materialized as an pekko.stream.scaladsl.SinkQueueWithCancel.

    Creates a Sink that is materialized as an pekko.stream.scaladsl.SinkQueueWithCancel. pekko.stream.scaladsl.SinkQueueWithCancel.pull method is pulling element from the stream and returns Future[Option[T]]. Future completes when element is available.

    Before calling pull method second time you need to wait until previous Future completes. Pull returns Failed future with IllegalStateException if previous future has not yet completed.

    Sink will request at most number of elements equal to size of inputBuffer from upstream and then stop back pressure. You can configure size of input buffer by using Sink.withAttributes method.

    For stream completion you need to pull all elements from pekko.stream.scaladsl.SinkQueueWithCancel including last None as completion marker

    See also pekko.stream.scaladsl.SinkQueueWithCancel

  39. def queue[T](maxConcurrentPulls: Int): Sink[T, SinkQueueWithCancel[T]]

    Creates a Sink that is materialized as an pekko.stream.scaladsl.SinkQueueWithCancel.

    Creates a Sink that is materialized as an pekko.stream.scaladsl.SinkQueueWithCancel. pekko.stream.scaladsl.SinkQueueWithCancel.pull method is pulling element from the stream and returns Future[Option[T]. Future completes when element is available.

    Before calling pull method second time you need to ensure that number of pending pulls is less then maxConcurrentPulls or wait until some of the previous Futures completes. Pull returns Failed future with IllegalStateException if there will be more then maxConcurrentPulls number of pending pulls.

    Sink will request at most number of elements equal to size of inputBuffer from upstream and then stop back pressure. You can configure size of input buffer by using Sink.withAttributes method.

    For stream completion you need to pull all elements from pekko.stream.scaladsl.SinkQueueWithCancel including last None as completion marker

    See also pekko.stream.scaladsl.SinkQueueWithCancel

  40. def reduce[T](f: (T, T) => T): Sink[T, Future[T]]

    A Sink that will invoke the given function for every received element, giving it its previous output (from the second element) and the element as input.

    A Sink that will invoke the given function for every received element, giving it its previous output (from the second element) and the element as input. The returned scala.concurrent.Future will be completed with value of the final function evaluation when the input stream ends, or completed with Failure if there is a failure signaled in the stream.

    If the stream is empty (i.e. completes before signalling any elements), the reduce operator will fail its downstream with a NoSuchElementException, which is semantically in-line with that Scala's standard library collections do in such situations.

    Adheres to the ActorAttributes.SupervisionStrategy attribute.

  41. def seq[T]: Sink[T, Future[Seq[T]]]

    A Sink that keeps on collecting incoming elements until upstream terminates.

    A Sink that keeps on collecting incoming elements until upstream terminates. As upstream may be unbounded, Flow[T].take or the stricter Flow[T].limit (and their variants) may be used to ensure boundedness. Materializes into a Future of Seq[T] containing all the collected elements. Seq is limited to Int.MaxValue elements, this Sink will cancel the stream after having received that many elements.

    See also Flow.limit, Flow.limitWeighted, Flow.take, Flow.takeWithin, Flow.takeWhile

  42. def shape[T](name: String): SinkShape[T]

    INTERNAL API

  43. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  44. def takeLast[T](n: Int): Sink[T, Future[Seq[T]]]

    A Sink that materializes into a a Future of immutable.Seq[T] containing the last n collected elements.

    A Sink that materializes into a a Future of immutable.Seq[T] containing the last n collected elements.

    If the stream completes before signaling at least n elements, the Future will complete with all elements seen so far. If the stream never completes, the Future will never complete. If there is a failure signaled in the stream the Future will be completed with failure.

  45. def toString(): String
    Definition Classes
    AnyRef → Any
  46. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  47. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  48. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])

Deprecated Value Members

  1. def actorRef[T](ref: ActorRef, onCompleteMessage: Any): Sink[T, NotUsed]

    Sends the elements of the stream to the given ActorRef.

    Sends the elements of the stream to the given ActorRef. If the target actor terminates the stream will be canceled. When the stream is completed successfully the given onCompleteMessage will be sent to the destination actor. When the stream is completed with failure a pekko.actor.Status.Failure message will be sent to the destination actor.

    It will request at most maxInputBufferSize number of elements from upstream, but 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 operator in front of this Sink.

    Annotations
    @deprecated
    Deprecated

    (Since version Akka 2.6.0) Use variant accepting both on complete and on failure message

  2. def actorRefWithAck[T](ref: ActorRef, onInitMessage: Any, ackMessage: Any, onCompleteMessage: Any, onFailureMessage: (Throwable) => Any = Status.Failure.apply): Sink[T, NotUsed]

    Sends the elements of the stream to the given ActorRef that sends back back-pressure signal.

    Sends the elements of the stream to the given ActorRef that sends back back-pressure signal. First element is always onInitMessage, then stream is waiting for acknowledgement message ackMessage from the given actor which means that it is ready to process elements. It also requires ackMessage message after each stream element to make backpressure work.

    If the target actor terminates the stream will be canceled. When the stream is completed successfully the given onCompleteMessage will be sent to the destination actor. When the stream is completed with failure - result of onFailureMessage(throwable) function will be sent to the destination actor.

    Annotations
    @deprecated
    Deprecated

    (Since version Akka 2.6.0) Use actorRefWithBackpressure accepting completion and failure matchers instead

  3. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable]) @Deprecated @Deprecated
    Deprecated
  4. def foreachParallel[T](parallelism: Int)(f: (T) => Unit)(implicit ec: ExecutionContext): Sink[T, Future[Done]]

    A Sink that will invoke the given function to each of the elements as they pass in.

    A Sink that will invoke the given function to each of the elements as they pass in. The sink is materialized into a scala.concurrent.Future

    If f throws an exception and the supervision decision is pekko.stream.Supervision.Stop the Future will be completed with failure.

    If f throws an exception and the supervision decision is pekko.stream.Supervision.Resume or pekko.stream.Supervision.Restart the element is dropped and the stream continues.

    See also Flow.mapAsyncUnordered

    Annotations
    @deprecated
    Deprecated

    (Since version Akka 2.5.17) Use foreachAsync instead, it allows you to choose how to run the procedure, by calling some other API returning a Future or spawning a new Future.

  5. def lazyInit[T, M](sinkFactory: (T) => Future[Sink[T, M]], fallback: () => M): Sink[T, Future[M]]

    Creates a real Sink upon receiving the first element.

    Creates a real Sink upon receiving the first element. Internal Sink will not be created if there are no elements, because of completion or error.

    If upstream completes before an element was received then the Future is completed with the value created by fallback. If upstream fails before an element was received, sinkFactory throws an exception, or materialization of the internal sink fails then the Future is completed with the exception. Otherwise the Future is completed with the materialized value of the internal sink.

    Annotations
    @deprecated
    Deprecated

    (Since version Akka 2.6.0) Use 'Sink.lazyFutureSink' in combination with 'Flow.prefixAndTail(1)' instead

  6. def lazyInitAsync[T, M](sinkFactory: () => Future[Sink[T, M]]): Sink[T, Future[Option[M]]]

    Creates a real Sink upon receiving the first element.

    Creates a real Sink upon receiving the first element. Internal Sink will not be created if there are no elements, because of completion or error.

    If upstream completes before an element was received then the Future is completed with None. If upstream fails before an element was received, sinkFactory throws an exception, or materialization of the internal sink fails then the Future is completed with the exception. Otherwise the Future is completed with the materialized value of the internal sink.

    Annotations
    @deprecated
    Deprecated

    (Since version Akka 2.6.0) Use 'Sink.lazyFutureSink' instead

  7. def setup[T, M](factory: (ActorMaterializer, Attributes) => Sink[T, M]): Sink[T, Future[M]]

    Defers the creation of a Sink until materialization.

    Defers the creation of a Sink until materialization. The factory function exposes ActorMaterializer which is going to be used during materialization and Attributes of the Sink returned by this method.

    Annotations
    @deprecated
    Deprecated

    (Since version Akka 2.6.0) Use 'fromMaterializer' instead

Inherited from AnyRef

Inherited from Any

Ungrouped