object Sink
- 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[In](ref: ActorRef, onCompleteMessage: Any): Sink[In, 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 givenonCompleteMessage
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 zeromailbox-push-timeout-time
or use a rate limiting operator in front of thisSink
. - def actorRefWithBackpressure[In](ref: ActorRef, onInitMessage: Any, onCompleteMessage: Any, onFailureMessage: Function[Throwable, Any]): Sink[In, 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 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
onCompleteMessage
will be sent to the destination actor. When the stream is completed with failure - result ofonFailureMessage(throwable)
message will be sent to the destination actor. - def actorRefWithBackpressure[In](ref: ActorRef, onInitMessage: Any, ackMessage: Any, onCompleteMessage: Any, onFailureMessage: Function[Throwable, Any]): Sink[In, 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 alwaysonInitMessage
, then stream is waiting for acknowledgement messageackMessage
from the given actor which means that it is ready to process elements. It also requiresackMessage
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 ofonFailureMessage(throwable)
message will be sent to the destination actor. - final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def asPublisher[T](fanout: AsPublisher): Sink[T, Publisher[T]]
A
Sink
that materializes into a org.reactivestreams.Publisher.A
Sink
that materializes into a org.reactivestreams.Publisher.If
fanout
istrue
, the materializedPublisher
will support multipleSubscriber
s and the size of theinputBuffer
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
isfalse
then the materializedPublisher
will only support a singleSubscriber
and reject any additionalSubscriber
s. - def cancelled[T](): Sink[T, NotUsed]
A
Sink
that immediately cancels its upstream after materialization. - def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
- def collect[U, In](collector: Collector[In, _, U]): Sink[In, CompletionStage[U]]
Creates a sink which materializes into a
which will be completed with a result of the JavaCompletionStage
transformation and reduction operations.Collector
Creates a sink which materializes into a
which will be completed with a result of the JavaCompletionStage
transformation and reduction operations. This allows usage of Java streams transformations for reactive streams. TheCollector
will trigger demand downstream. Elements emitted through the stream will be accumulated into a mutable result container, optionally transformed into a final representation after all input elements have been processed. TheCollector
can also do reduction at the end. Reduction processing is performed sequentially.Collector
- def combine[T, U](output1: Sink[U, _], output2: Sink[U, _], rest: List[Sink[U, _]], strategy: Function[Integer, Graph[UniformFanOutShape[T, U], NotUsed]]): Sink[T, NotUsed]
Combine several sinks with fan-out strategy like
Broadcast
orBalance
and returnsSink
. - def completionStageSink[T, M](future: CompletionStage[Sink[T, M]]): Sink[T, CompletionStage[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 theFuture
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.
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def fold[U, In](zero: U, f: Function2[U, In, U]): Sink[In, CompletionStage[U]]
A
Sink
that will invoke the given function for every received element, giving it its previous output (or the givenzero
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 givenzero
value) and the element as input. The returned java.util.concurrent.CompletionStage will be completed with value of the final function evaluation when the input stream ends, or completed withFailure
if there is a failure is signaled in the stream. - def foldAsync[U, In](zero: U, f: Function2[U, In, CompletionStage[U]]): Sink[In, CompletionStage[U]]
A
Sink
that will invoke the given asynchronous function for every received element, giving it its previous output (or the givenzero
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 givenzero
value) and the element as input. The returned java.util.concurrent.CompletionStage will be completed with value of the final function evaluation when the input stream ends, or completed withFailure
if there is a failure is signaled in the stream. - def foreach[T](f: Procedure[T]): Sink[T, CompletionStage[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 java.util.concurrent.CompletionStage which will be completed withSuccess
when reaching the normal end of the stream, or completed withFailure
if there is a failure signaled in the stream. - def foreachAsync[T](parallelism: Int)(f: Function[T, CompletionStage[Void]]): Sink[T, CompletionStage[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 java.util.concurrent.CompletionStage which will be completed withSuccess
when reaching the normal end of the stream, or completed withFailure
if 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: BiFunction[Materializer, Attributes, Sink[T, M]]): Sink[T, CompletionStage[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. - def fromSubscriber[In](subs: Subscriber[In]): Sink[In, NotUsed]
Helper to create Sink from
Subscriber
. - final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- def head[In](): Sink[In, CompletionStage[In]]
A
Sink
that materializes into aCompletionStage
of the first value received.A
Sink
that materializes into aCompletionStage
of the first value received. If the stream completes before signaling at least a single element, the CompletionStage will be failed with a NoSuchElementException. If the stream signals an error before signaling at least a single element, the CompletionStage will be failed with the streams exception.See also headOption.
- def headOption[In](): Sink[In, CompletionStage[Optional[In]]]
A
Sink
that materializes into aCompletionStage
of the optional first value received.A
Sink
that materializes into aCompletionStage
of the optional first value received. If the stream completes before signaling at least a single element, the value of the CompletionStage will be an empty java.util.Optional. If the stream signals an error errors before signaling at least a single element, the CompletionStage will be failed with the streams exception.See also head.
- def ignore[T](): Sink[T, CompletionStage[Done]]
A
Sink
that will consume the stream and discard the elements. - final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def last[In](): Sink[In, CompletionStage[In]]
A
Sink
that materializes into aCompletionStage
of the last value received.A
Sink
that materializes into aCompletionStage
of the last value received. If the stream completes before signaling at least a single element, the CompletionStage will be failed with a NoSuchElementException. If the stream signals an error errors before signaling at least a single element, the CompletionStage will be failed with the streams exception.See also lastOption, takeLast.
- def lastOption[In](): Sink[In, CompletionStage[Optional[In]]]
A
Sink
that materializes into aCompletionStage
of the optional last value received.A
Sink
that materializes into aCompletionStage
of the optional last value received. If the stream completes before signaling at least a single element, the value of the CompletionStage will be an empty java.util.Optional. If the stream signals an error errors before signaling at least a single element, the CompletionStage will be failed with the streams exception. - def lazyCompletionStageSink[T, M](create: Creator[CompletionStage[Sink[T, M]]]): Sink[T, CompletionStage[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. - def lazySink[T, M](create: Creator[Sink[T, M]]): Sink[T, CompletionStage[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. - final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def never[T]: Sink[T, CompletionStage[Done]]
A Sink that will always backpressure never cancel and never consume any elements from the stream.
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- def onComplete[In](callback: Procedure[Try[Done]]): Sink[In, 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. - def queue[T](): Sink[T, SinkQueueWithCancel[T]]
Creates a
Sink
that is materialized as an pekko.stream.javadsl.SinkQueueWithCancel.Creates a
Sink
that is materialized as an pekko.stream.javadsl.SinkQueueWithCancel. pekko.stream.javadsl.SinkQueueWithCancel.pull method is pulling element from the stream and returns
.CompletionStage[Option[T]]
CompletionStage
completes when element is available.Before calling pull method second time you need to wait until previous CompletionStage 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 ofinputBuffer
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.javadsl.SinkQueueWithCancel including last None as completion marker
- def queue[T](maxConcurrentPulls: Int): Sink[T, SinkQueueWithCancel[T]]
Creates a
Sink
that is materialized as an pekko.stream.javadsl.SinkQueueWithCancel.Creates a
Sink
that is materialized as an pekko.stream.javadsl.SinkQueueWithCancel. pekko.stream.javadsl.SinkQueueWithCancel.pull method is pulling element from the stream and returns
.CompletionStage[Option[T]]
CompletionStage
completes when element is available.Before calling pull method second time you need to ensure that number of pending pulls is less then
or wait until some of the previous Futures completes. Pull returns Failed future with IllegalStateException if there will be more thenmaxConcurrentPulls
number of pending pulls.maxConcurrentPulls
Sink
will request at most number of elements equal to size ofinputBuffer
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.javadsl.SinkQueueWithCancel including last None as completion marker
- def reduce[In](f: Function2[In, In, In]): Sink[In, CompletionStage[In]]
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 java.util.concurrent.CompletionStage will be completed with value of the final function evaluation when the input stream ends, or completed withFailure
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.
- def seq[In]: Sink[In, CompletionStage[List[In]]]
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 stricterFlow[T].limit
(and their variants) may be used to ensure boundedness. Materializes into aCompletionStage
ofSeq[T]
containing all the collected elements.List
is limited toInteger.MAX_VALUE
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
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def takeLast[In](n: Int): Sink[In, CompletionStage[List[In]]]
A
Sink
that materializes into a aCompletionStage
ofList<In>
containing the lastn
collected elements.A
Sink
that materializes into a aCompletionStage
ofList<In>
containing the lastn
collected elements.If the stream completes before signaling at least n elements, the
CompletionStage
will complete with all elements seen so far. If the stream never completes theCompletionStage
will never complete. If there is a failure signaled in the stream theCompletionStage
will 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])
Deprecated Value Members
- def actorRefWithAck[In](ref: ActorRef, onInitMessage: Any, ackMessage: Any, onCompleteMessage: Any, onFailureMessage: Function[Throwable, Any]): Sink[In, 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 alwaysonInitMessage
, then stream is waiting for acknowledgement messageackMessage
from the given actor which means that it is ready to process elements. It also requiresackMessage
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 ofonFailureMessage(throwable)
message will be sent to the destination actor.- Annotations
- @deprecated
- Deprecated
(Since version Akka 2.6.0) Use actorRefWithBackpressure instead
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable]) @Deprecated @Deprecated
- Deprecated
- def foreachParallel[T](parallel: Int)(f: Procedure[T])(ec: ExecutionContext): Sink[T, CompletionStage[Done]]
A
Sink
that will invoke the given procedure for each received element in parallel.A
Sink
that will invoke the given procedure for each received element in parallel. The sink is materialized into a java.util.concurrent.CompletionStage.If
f
throws an exception and the supervision decision is pekko.stream.Supervision.Stop theCompletionStage
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.- 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 CompletionStage or using CompletableFuture.supplyAsync.
- def lazyInit[T, M](sinkFactory: Function[T, CompletionStage[Sink[T, M]]], fallback: Creator[M]): Sink[T, CompletionStage[M]]
Creates a real
Sink
upon receiving the first element.Creates a real
Sink
upon receiving the first element. InternalSink
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 theFuture
is completed with the exception. Otherwise theFuture
is completed with the materialized value of the internal sink.- Annotations
- @deprecated
- Deprecated
(Since version Akka 2.6.0) Use 'Sink.lazyCompletionStageSink' in combination with 'Flow.prefixAndTail(1)' instead
- def lazyInitAsync[T, M](sinkFactory: Creator[CompletionStage[Sink[T, M]]]): Sink[T, CompletionStage[Optional[M]]]
Creates a real
Sink
upon receiving the first element.Creates a real
Sink
upon receiving the first element. InternalSink
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 withNone
. If upstream fails before an element was received,sinkFactory
throws an exception, or materialization of the internal sink fails then theFuture
is completed with the exception. Otherwise theFuture
is completed with the materialized value of the internal sink.- Annotations
- @deprecated
- Deprecated
(Since version Akka 2.6.0) Use 'Sink.lazyCompletionStageSink' instead
- def setup[T, M](factory: BiFunction[ActorMaterializer, Attributes, Sink[T, M]]): Sink[T, CompletionStage[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