object Sink
- Source
- Sink.scala
- Alphabetic
- By Inheritance
- Sink
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Value Members
-   final  def !=(arg0: Any): Boolean- Definition Classes
- AnyRef → Any
 
-   final  def ##: Int- Definition Classes
- AnyRef → Any
 
-   final  def ==(arg0: Any): Boolean- Definition Classes
- AnyRef → Any
 
-    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 givenonCompleteMessagewill be sent to the destination actor. When the stream is completed with failure theonFailureMessagewill be invoked and its result will be sent to the destination actor.It will request at most maxInputBufferSizenumber 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 zeromailbox-push-timeout-timeor use a rate limiting operator in front of thisSink.
-    def actorRefWithBackpressure[T](ref: ActorRef, onInitMessage: Any, onCompleteMessage: Any, onFailureMessage: (Throwable) => Any): Sink[T, NotUsed]Sends the elements of the stream to the given ActorRefthat sends back back-pressure signal.Sends the elements of the stream to the given ActorRefthat sends back back-pressure signal. First element is alwaysonInitMessage, 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 onCompleteMessagewill be sent to the destination actor. When the stream is completed with failure - result ofonFailureMessage(throwable)function will be sent to the destination actor.
-    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 ActorRefthat sends back back-pressure signal.Sends the elements of the stream to the given ActorRefthat sends back back-pressure signal. First element is alwaysonInitMessage, then stream is waiting for acknowledgement messageackMessagefrom the given actor which means that it is ready to process elements. It also requiresackMessagemessage 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 onCompleteMessagewill be sent to the destination actor. When the stream is completed with failure - result ofonFailureMessage(throwable)function will be sent to the destination actor.
-   final  def asInstanceOf[T0]: T0- Definition Classes
- Any
 
-    def asPublisher[T](fanout: Boolean): Sink[T, Publisher[T]]A Sinkthat materializes into a org.reactivestreams.Publisher.A Sinkthat materializes into a org.reactivestreams.Publisher.If fanoutistrue, the materializedPublisherwill support multipleSubscribers and the size of theinputBufferconfigured 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 fanoutisfalsethen the materializedPublisherwill only support a singleSubscriberand reject any additionalSubscribers.
-    def cancelled[T]: Sink[T, NotUsed]A Sinkthat immediately cancels its upstream after materialization.
-    def clone(): AnyRef- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @IntrinsicCandidate() @native()
 
-    def collection[T, That](implicit cbf: Factory[T, That with Iterable[_]]): Sink[T, Future[That]]A Sinkthat keeps on collecting incoming elements until upstream terminates.A Sinkthat keeps on collecting incoming elements until upstream terminates. As upstream may be unbounded,Flow[T].takeor the stricterFlow[T].limit(and their variants) may be used to ensure boundedness. Materializes into aFutureofThat[T]containing all the collected elements.That[T]is limited to the limitations of the CanBuildFrom associated with it. For example,Seqis limited toInt.MaxValueelements. 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 
-    def combine[T, U, M](sinks: Seq[Graph[SinkShape[U], M]])(fanOutStrategy: (Int) => Graph[UniformFanOutShape[T, U], NotUsed]): Sink[T, Seq[M]]Combine several sinks with fan-out strategy like BroadcastorBalanceand returnsSink.Combine several sinks with fan-out strategy like BroadcastorBalanceand returnsSink. The fanoutGraph's outlets size must match the provides sinks'.- Since
- 1.1.0 
 
-    def combine[T, U](first: Sink[U, _], second: Sink[U, _], rest: Sink[U, _]*)(fanOutStrategy: (Int) => Graph[UniformFanOutShape[T, U], NotUsed]): Sink[T, NotUsed]Combine several sinks with fan-out strategy like BroadcastorBalanceand returnsSink.
-    def combineMat[T, U, M1, M2, M](first: Sink[U, M1], second: Sink[U, M2])(fanOutStrategy: (Int) => Graph[UniformFanOutShape[T, U], NotUsed])(matF: (M1, M2) => M): Sink[T, M]Combine two sinks with fan-out strategy like BroadcastorBalanceand returnsSinkwith 2 outlets.Combine two sinks with fan-out strategy like BroadcastorBalanceand returnsSinkwith 2 outlets.- Since
- 1.1.0 
 
-    def count[T]: Sink[T, Future[Long]]A Sinkthat counts all incoming elements until upstream terminates.A Sinkthat counts all incoming elements until upstream terminates.Since upstream may be unbounded, consider using Flow[T].takeor the stricterFlow[T].limit(and their variants) to ensure boundedness. The sink materializes into aFutureofLongcontaining the total count of elements that passed through.Completes when upstream completes Backpressures when never (counting is a lightweight operation) Cancels when never - returns
- a - Sinkthat materializes to a- Future[Long]with the element count
 - Since
- 1.3.0 See also Flow.limit, Flow.limitWeighted, Flow.take, Flow.takeWithin, Flow.takeWhile 
 
-   final  def eq(arg0: AnyRef): Boolean- Definition Classes
- AnyRef
 
-    def equals(arg0: AnyRef): Boolean- Definition Classes
- AnyRef → Any
 
-    def exists[T](p: (T) => Boolean): Sink[T, Future[Boolean]]A Sinkthat will test the given predicatepfor every received element andA Sinkthat will test the given predicatepfor every received element and- completes and returns scala.concurrent.Future of trueif the predicate is true for any element; 2. completes and returns scala.concurrent.Future offalseif the stream is empty (i.e. completes before signalling any elements); 3. completes and returns scala.concurrent.Future offalseif the predicate is false for all elements.
 The materialized value scala.concurrent.Future will be completed with the value trueorfalsewhen the input stream ends, or completed withFailureif there is a failure signaled in the stream.Adheres to the ActorAttributes.SupervisionStrategy attribute. Completes when upstream completes or the predicate preturnstrueBackpressures when the invocation of predicate phas not yet completedCancels when predicate preturnstrue- Since
- 1.1.0 
 
- completes and returns scala.concurrent.Future of 
-    def fold[U, T](zero: U)(f: (U, T) => U): Sink[T, Future[U]]A Sinkthat will invoke the given function for every received element, giving it its previous output (or the givenzerovalue) and the element as input.A Sinkthat will invoke the given function for every received element, giving it its previous output (or the givenzerovalue) 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 withFailureif there is a failure signaled in the stream.- See also
 
-    def foldAsync[U, T](zero: U)(f: (U, T) => Future[U]): Sink[T, Future[U]]A Sinkthat will invoke the given asynchronous function for every received element, giving it its previous output (or the givenzerovalue) and the element as input.A Sinkthat will invoke the given asynchronous function for every received element, giving it its previous output (or the givenzerovalue) 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 withFailureif there is a failure signaled in the stream.- See also
 
-    def foldWhile[U, T](zero: U)(p: (U) => Boolean)(f: (U, T) => U): Sink[T, Future[U]]A Sinkthat will invoke the given function for every received element, giving it its previous output (or the givenzerovalue) and the element as input.A Sinkthat will invoke the given function for every received element, giving it its previous output (or the givenzerovalue) 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, predicatepreturns false, or completed withFailureif there is a failure signaled in the stream.- Since
- 1.1.0 
- See also
 
-    def forall[T](p: (T) => Boolean): Sink[T, Future[Boolean]]A Sinkthat will test the given predicatepfor every received element andA Sinkthat will test the given predicatepfor every received element and- completes and returns scala.concurrent.Future of trueif the predicate is true for all elements; 2. completes and returns scala.concurrent.Future oftrueif the stream is empty (i.e. completes before signalling any elements); 3. completes and returns scala.concurrent.Future offalseif the predicate is false for any element.
 The materialized value scala.concurrent.Future will be completed with the value trueorfalsewhen the input stream ends, or completed withFailureif there is a failure signaled in the stream.Adheres to the ActorAttributes.SupervisionStrategy attribute. Completes when upstream completes or the predicate preturnsfalseBackpressures when the invocation of predicate phas not yet completedCancels when predicate preturnsfalse- Since
- 1.1.0 
 
- completes and returns scala.concurrent.Future of 
-    def foreach[T](f: (T) => Unit): Sink[T, Future[Done]]A Sinkthat will invoke the given procedure for each received element.A Sinkthat will invoke the given procedure for each received element. The sink is materialized into a scala.concurrent.Future which will be completed withSuccesswhen reaching the normal end of the stream, or completed withFailureif there is a failure signaled in the stream.
-    def foreachAsync[T](parallelism: Int)(f: (T) => Future[Unit]): Sink[T, Future[Done]]A Sinkthat will invoke the given procedure asynchronously for each received element.A Sinkthat will invoke the given procedure asynchronously for each received element. The sink is materialized into a scala.concurrent.Future which will be completed withSuccesswhen reaching the normal end of the stream, or completed withFailureif there is a failure signaled in the stream.
-    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. 
-    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 factoryfunction exposes Materializer which is going to be used during materialization and Attributes of the Sink returned by this method.
-    def fromSubscriber[T](subscriber: Subscriber[T]): Sink[T, NotUsed]Helper to create Sink from Subscriber.
-    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 theFutureis 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. 
-   final  def getClass(): Class[_ <: AnyRef]- Definition Classes
- AnyRef → Any
- Annotations
- @IntrinsicCandidate() @native()
 
-    def hashCode(): Int- Definition Classes
- AnyRef → Any
- Annotations
- @IntrinsicCandidate() @native()
 
-    def head[T]: Sink[T, Future[T]]A Sinkthat materializes into aFutureof the first value received.A Sinkthat materializes into aFutureof 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. 
-    def headOption[T]: Sink[T, Future[Option[T]]]A Sinkthat materializes into aFutureof the optional first value received.A Sinkthat materializes into aFutureof the optional first value received. If the stream completes before signaling at least a single element, the value of the Future will be scala.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. 
-    def ignore: Sink[Any, Future[Done]]A Sinkthat will consume the stream and discard the elements.
-   final  def isInstanceOf[T0]: Boolean- Definition Classes
- Any
 
-    def last[T]: Sink[T, Future[T]]A Sinkthat materializes into aFutureof the last value received.A Sinkthat materializes into aFutureof 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. 
-    def lastOption[T]: Sink[T, Future[Option[T]]]A Sinkthat materializes into aFutureof the optional last value received.A Sinkthat materializes into aFutureof the optional last value received. If the stream completes before signaling at least a single element, the value of the Future will be scala.None. If the stream signals an error, the Future will be failed with the stream's exception.
-    def lazyFutureSink[T, M](create: () => Future[Sink[T, M]]): Sink[T, Future[M]]Defers invoking the createfunction to create a future sink until there is a first element passed from upstream.Defers invoking the createfunction 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 createfunction 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.
-    def lazySink[T, M](create: () => Sink[T, M]): Sink[T, Future[M]]Defers invoking the createfunction to create a sink until there is a first element passed from upstream.Defers invoking the createfunction 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 createfunction throws or returns or the stream fails to materialize, in this case the materialized future value is failed with a pekko.stream.NeverMaterializedException.
-   final  def ne(arg0: AnyRef): Boolean- Definition Classes
- AnyRef
 
-    def never: Sink[Any, Future[Done]]A Sink that will always backpressure never cancel and never consume any elements from the stream. 
-    def none[T](p: (T) => Boolean): Sink[T, Future[Boolean]]A Sinkthat will test the given predicatepfor every received element andA Sinkthat will test the given predicatepfor every received element and- completes and returns scala.concurrent.Future of trueif the predicate is false for all elements; 2. completes and returns scala.concurrent.Future oftrueif the stream is empty (i.e. completes before signalling any elements); 3. completes and returns scala.concurrent.Future offalseif the predicate is true for any element.
 The materialized value scala.concurrent.Future will be completed with the value trueorfalsewhen the input stream ends, or completed withFailureif there is a failure signaled in the stream.Adheres to the ActorAttributes.SupervisionStrategy attribute. Completes when upstream completes or the predicate preturnstrueBackpressures when the invocation of predicate phas not yet completedCancels when predicate preturnstrue- Since
- 1.2.0 
 
- completes and returns scala.concurrent.Future of 
-   final  def notify(): Unit- Definition Classes
- AnyRef
- Annotations
- @IntrinsicCandidate() @native()
 
-   final  def notifyAll(): Unit- Definition Classes
- AnyRef
- Annotations
- @IntrinsicCandidate() @native()
 
-    def onComplete[T](callback: (Try[Done]) => Unit): Sink[T, NotUsed]A Sinkthat when the flow is completed, either through a failure or normal completion, apply the provided function with scala.util.Success or scala.util.Failure.
-    def queue[T](): Sink[T, SinkQueueWithCancel[T]]Creates a Sinkthat is materialized as an pekko.stream.scaladsl.SinkQueueWithCancel.Creates a Sinkthat is materialized as an pekko.stream.scaladsl.SinkQueueWithCancel. pekko.stream.scaladsl.SinkQueueWithCancel.pull method is pulling element from the stream and returnsFuture[Option[T]]Futurecompletes 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. Sinkwill request at most number of elements equal to size ofinputBufferfrom 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 
-    def queue[T](maxConcurrentPulls: Int): Sink[T, SinkQueueWithCancel[T]]Creates a Sinkthat is materialized as an pekko.stream.scaladsl.SinkQueueWithCancel.Creates a Sinkthat is materialized as an pekko.stream.scaladsl.SinkQueueWithCancel. pekko.stream.scaladsl.SinkQueueWithCancel.pull method is pulling element from the stream and returnsFuture[Option[T]Futurecompletes when element is available.Before calling pull method second time you need to ensure that number of pending pulls is less then maxConcurrentPullsmaxConcurrentPullsSinkwill request at most number of elements equal to size ofinputBufferfrom 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 
-    def reduce[T](f: (T, T) => T): Sink[T, Future[T]]A Sinkthat will invoke the given function for every received element, giving it its previous output (from the second element) and the element as input.A Sinkthat 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 withFailureif 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. 
-    def seq[T]: Sink[T, Future[Seq[T]]]A Sinkthat keeps on collecting incoming elements until upstream terminates.A Sinkthat keeps on collecting incoming elements until upstream terminates. As upstream may be unbounded,Flow[T].takeor the stricterFlow[T].limit(and their variants) may be used to ensure boundedness. Materializes into aFutureofSeq[T]containing all the collected elements.Seqis limited toInt.MaxValueelements, this Sink will cancel the stream after having received that many elements.See also Flow.limit, Flow.limitWeighted, Flow.take, Flow.takeWithin, Flow.takeWhile 
-    def shape[T](name: String): SinkShape[T]INTERNAL API 
-    def source[T]: Sink[T, Source[T, NotUsed]]A Sinkthat materializes thisSinkitself as aSource.A Sinkthat materializes thisSinkitself as aSource. The returnedSourceis a "live view" onto theSinkand only supports a singleSubscriber.Use BroadcastHub#sink if you need a Sourcethat allows multiple subscribers.Note: even if the Sourceis directly connected to theSink, there is still an asynchronous boundary between them; performance may be improved in the future.- Since
- 1.3.0 
 
-   final  def synchronized[T0](arg0: => T0): T0- Definition Classes
- AnyRef
 
-    def takeLast[T](n: Int): Sink[T, Future[Seq[T]]]A Sinkthat materializes into aFutureofimmutable.Seq[T]containing the lastncollected elements.A Sinkthat materializes into aFutureofimmutable.Seq[T]containing the lastncollected elements.If the stream completes before signaling at least n elements, the Futurewill complete with all elements seen so far. If the stream never completes, theFuturewill never complete. If there is a failure signaled in the stream theFuturewill be completed with failure.
-    def toString(): String- Definition Classes
- AnyRef → Any
 
-   final  def wait(arg0: Long, arg1: Int): Unit- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
 
-   final  def wait(arg0: Long): Unit- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
 
-   final  def wait(): Unit- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])