Class Sink$
- java.lang.Object
-
- org.apache.pekko.stream.scaladsl.Sink$
-
public class Sink$ extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description Sink$()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description <T> Sink<T,NotUsed>actorRef(ActorRef ref, java.lang.Object onCompleteMessage)Deprecated.Use variant accepting both on complete and on failure message.<T> Sink<T,NotUsed>actorRef(ActorRef ref, java.lang.Object onCompleteMessage, scala.Function1<java.lang.Throwable,java.lang.Object> onFailureMessage)INTERNAL API<T> Sink<T,NotUsed>actorRefWithAck(ActorRef ref, java.lang.Object onInitMessage, java.lang.Object ackMessage, java.lang.Object onCompleteMessage, scala.Function1<java.lang.Throwable,java.lang.Object> onFailureMessage)Deprecated.Use actorRefWithBackpressure accepting completion and failure matchers instead.<T> scala.Function1<java.lang.Throwable,java.lang.Object>actorRefWithAck$default$5()<T> Sink<T,NotUsed>actorRefWithBackpressure(ActorRef ref, java.lang.Object onInitMessage, java.lang.Object ackMessage, java.lang.Object onCompleteMessage, scala.Function1<java.lang.Throwable,java.lang.Object> onFailureMessage)Sends the elements of the stream to the givenActorRefthat sends back back-pressure signal.<T> Sink<T,NotUsed>actorRefWithBackpressure(ActorRef ref, java.lang.Object onInitMessage, java.lang.Object onCompleteMessage, scala.Function1<java.lang.Throwable,java.lang.Object> onFailureMessage)Sends the elements of the stream to the givenActorRefthat sends back back-pressure signal.<T> Sink<T,org.reactivestreams.Publisher<T>>asPublisher(boolean fanout)ASinkthat materializes into aPublisher.<T> Sink<T,NotUsed>cancelled()ASinkthat immediately cancels its upstream after materialization.<T,That>
Sink<T,scala.concurrent.Future<That>>collection(scala.collection.Factory<T,That> cbf)ASinkthat keeps on collecting incoming elements until upstream terminates.<T,U>
Sink<T,NotUsed>combine(Sink<U,?> first, Sink<U,?> second, scala.collection.immutable.Seq<Sink<U,?>> rest, scala.Function1<java.lang.Object,Graph<UniformFanOutShape<T,U>,NotUsed>> fanOutStrategy)Combine several sinks with fan-out strategy likeBroadcastorBalanceand returnsSink.<T,U,M>
Sink<T,scala.collection.immutable.Seq<M>>combine(scala.collection.immutable.Seq<Graph<SinkShape<U>,M>> sinks, scala.Function1<java.lang.Object,Graph<UniformFanOutShape<T,U>,NotUsed>> fanOutStrategy)Combine several sinks with fan-out strategy likeBroadcastorBalanceand returnsSink.<T,U,M1,M2,M>
Sink<T,M>combineMat(Sink<U,M1> first, Sink<U,M2> second, scala.Function1<java.lang.Object,Graph<UniformFanOutShape<T,U>,NotUsed>> fanOutStrategy, scala.Function2<M1,M2,M> matF)Combine two sinks with fan-out strategy likeBroadcastorBalanceand returnsSinkwith 2 outlets.<T> Sink<T,scala.concurrent.Future<java.lang.Object>>exists(scala.Function1<T,java.lang.Object> p)ASinkthat will test the given predicatepfor every received element and 1.<U,T>
Sink<T,scala.concurrent.Future<U>>fold(U zero, scala.Function2<U,T,U> f)ASinkthat will invoke the given function for every received element, giving it its previous output (or the givenzerovalue) and the element as input.<U,T>
Sink<T,scala.concurrent.Future<U>>foldAsync(U zero, scala.Function2<U,T,scala.concurrent.Future<U>> f)ASinkthat will invoke the given asynchronous function for every received element, giving it its previous output (or the givenzerovalue) and the element as input.<U,T>
Sink<T,scala.concurrent.Future<U>>foldWhile(U zero, scala.Function1<U,java.lang.Object> p, scala.Function2<U,T,U> f)ASinkthat will invoke the given function for every received element, giving it its previous output (or the givenzerovalue) and the element as input.<T> Sink<T,scala.concurrent.Future<java.lang.Object>>forall(scala.Function1<T,java.lang.Object> p)ASinkthat will test the given predicatepfor every received element and 1.<T> Sink<T,scala.concurrent.Future<Done>>foreach(scala.Function1<T,scala.runtime.BoxedUnit> f)ASinkthat will invoke the given procedure for each received element.<T> Sink<T,scala.concurrent.Future<Done>>foreachAsync(int parallelism, scala.Function1<T,scala.concurrent.Future<scala.runtime.BoxedUnit>> f)ASinkthat will invoke the given procedure asynchronously for each received element.<T> Sink<T,scala.concurrent.Future<Done>>foreachParallel(int parallelism, scala.Function1<T,scala.runtime.BoxedUnit> f, scala.concurrent.ExecutionContext ec)Deprecated.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.<T,M>
Sink<T,M>fromGraph(Graph<SinkShape<T>,M> g)A graph with the shape of a sink logically is a sink, this method makes it so also in type.<T,M>
Sink<T,scala.concurrent.Future<M>>fromMaterializer(scala.Function2<Materializer,Attributes,Sink<T,M>> factory)Defers the creation of aSinkuntil materialization.<T> Sink<T,NotUsed>fromSubscriber(org.reactivestreams.Subscriber<T> subscriber)Helper to createSinkfromSubscriber.<T,M>
Sink<T,scala.concurrent.Future<M>>futureSink(scala.concurrent.Future<Sink<T,M>> future)Turn aFuture[Sink]into a Sink that will consume the values of the source when the future completes successfully.<T> Sink<T,scala.concurrent.Future<T>>head()ASinkthat materializes into aFutureof the first value received.<T> Sink<T,scala.concurrent.Future<scala.Option<T>>>headOption()ASinkthat materializes into aFutureof the optional first value received.Sink<java.lang.Object,scala.concurrent.Future<Done>>ignore()ASinkthat will consume the stream and discard the elements.<T> Sink<T,scala.concurrent.Future<T>>last()ASinkthat materializes into aFutureof the last value received.<T> Sink<T,scala.concurrent.Future<scala.Option<T>>>lastOption()ASinkthat materializes into aFutureof the optional last value received.<T,M>
Sink<T,scala.concurrent.Future<M>>lazyFutureSink(scala.Function0<scala.concurrent.Future<Sink<T,M>>> create)Defers invoking thecreatefunction to create a future sink until there is a first element passed from upstream.<T,M>
Sink<T,scala.concurrent.Future<M>>lazyInit(scala.Function1<T,scala.concurrent.Future<Sink<T,M>>> sinkFactory, scala.Function0<M> fallback)Deprecated.Use 'Sink.lazyFutureSink' in combination with 'Flow.prefixAndTail(1)' instead.<T,M>
Sink<T,scala.concurrent.Future<scala.Option<M>>>lazyInitAsync(scala.Function0<scala.concurrent.Future<Sink<T,M>>> sinkFactory)Deprecated.Use 'Sink.lazyFutureSink' instead.<T,M>
Sink<T,scala.concurrent.Future<M>>lazySink(scala.Function0<Sink<T,M>> create)Defers invoking thecreatefunction to create a sink until there is a first element passed from upstream.Sink<java.lang.Object,scala.concurrent.Future<Done>>never()ASinkthat will always backpressure never cancel and never consume any elements from the stream.<T> Sink<T,scala.concurrent.Future<java.lang.Object>>none(scala.Function1<T,java.lang.Object> p)ASinkthat will test the given predicatepfor every received element and 1.<T> Sink<T,NotUsed>onComplete(scala.Function1<scala.util.Try<Done>,scala.runtime.BoxedUnit> callback)ASinkthat when the flow is completed, either through a failure or normal completion, apply the provided function withSuccessorFailure.<T> Sink<T,SinkQueueWithCancel<T>>queue()Creates aSinkthat is materialized as anpekko.stream.scaladsl.SinkQueueWithCancel.<T> Sink<T,SinkQueueWithCancel<T>>queue(int maxConcurrentPulls)Creates aSinkthat is materialized as anpekko.stream.scaladsl.SinkQueueWithCancel.<T> Sink<T,scala.concurrent.Future<T>>reduce(scala.Function2<T,T,T> f)ASinkthat will invoke the given function for every received element, giving it its previous output (from the second element) and the element as input.<T> Sink<T,scala.concurrent.Future<scala.collection.immutable.Seq<T>>>seq()ASinkthat keeps on collecting incoming elements until upstream terminates.<T,M>
Sink<T,scala.concurrent.Future<M>>setup(scala.Function2<ActorMaterializer,Attributes,Sink<T,M>> factory)Deprecated.Use 'fromMaterializer' instead.<T> SinkShape<T>shape(java.lang.String name)INTERNAL API<T> Sink<T,scala.concurrent.Future<scala.collection.immutable.Seq<T>>>takeLast(int n)ASinkthat materializes into aFutureofimmutable.Seq[T]containing the lastncollected elements.
-
-
-
Field Detail
-
MODULE$
public static final Sink$ MODULE$
Static reference to the singleton instance of this Scala object.
-
-
Method Detail
-
shape
public <T> SinkShape<T> shape(java.lang.String name)
INTERNAL API
-
fromGraph
public <T,M> Sink<T,M> fromGraph(Graph<SinkShape<T>,M> g)
A graph with the shape of a sink logically is a sink, this method makes it so also in type.
-
fromMaterializer
public <T,M> Sink<T,scala.concurrent.Future<M>> fromMaterializer(scala.Function2<Materializer,Attributes,Sink<T,M>> factory)
-
setup
public <T,M> Sink<T,scala.concurrent.Future<M>> setup(scala.Function2<ActorMaterializer,Attributes,Sink<T,M>> factory)
Deprecated.Use 'fromMaterializer' instead. Since Akka 2.6.0.
-
fromSubscriber
public <T> Sink<T,NotUsed> fromSubscriber(org.reactivestreams.Subscriber<T> subscriber)
Helper to createSinkfromSubscriber.
-
cancelled
public <T> Sink<T,NotUsed> cancelled()
ASinkthat immediately cancels its upstream after materialization.
-
head
public <T> Sink<T,scala.concurrent.Future<T>> head()
ASinkthat materializes into aFutureof the first value received. If the stream completes before signaling at least a single element, the Future will be failed with aNoSuchElementException. 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
<T>headOption().
-
headOption
public <T> Sink<T,scala.concurrent.Future<scala.Option<T>>> headOption()
ASinkthat 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 beNone. 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
<T>head().
-
last
public <T> Sink<T,scala.concurrent.Future<T>> last()
ASinkthat materializes into aFutureof the last value received. If the stream completes before signaling at least a single element, the Future will be failed with aNoSuchElementException. If the stream signals an error, the Future will be failed with the stream's exception.See also
<T>lastOption(),<T>takeLast(int).
-
lastOption
public <T> Sink<T,scala.concurrent.Future<scala.Option<T>>> lastOption()
ASinkthat 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 beNone. If the stream signals an error, the Future will be failed with the stream's exception.See also
<T>last(),<T>takeLast(int).
-
takeLast
public <T> Sink<T,scala.concurrent.Future<scala.collection.immutable.Seq<T>>> takeLast(int n)
ASinkthat 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.
-
seq
public <T> Sink<T,scala.concurrent.Future<scala.collection.immutable.Seq<T>>> seq()
ASinkthat 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
-
collection
public <T,That> Sink<T,scala.concurrent.Future<That>> collection(scala.collection.Factory<T,That> cbf)
ASinkthat 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
-
asPublisher
public <T> Sink<T,org.reactivestreams.Publisher<T>> asPublisher(boolean fanout)
ASinkthat materializes into aPublisher.If
fanoutistrue, the materializedPublisherwill support multipleSubscribers and the size of theinputBufferconfigured for this operator becomes the maximum number of elements that the fastestSubscribercan 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.
-
ignore
public Sink<java.lang.Object,scala.concurrent.Future<Done>> ignore()
ASinkthat will consume the stream and discard the elements.
-
never
public Sink<java.lang.Object,scala.concurrent.Future<Done>> never()
ASinkthat will always backpressure never cancel and never consume any elements from the stream.
-
foreach
public <T> Sink<T,scala.concurrent.Future<Done>> foreach(scala.Function1<T,scala.runtime.BoxedUnit> f)
ASinkthat will invoke the given procedure for each received element. The sink is materialized into aFuturewhich will be completed withSuccesswhen reaching the normal end of the stream, or completed withFailureif there is a failure signaled in the stream.
-
foreachAsync
public <T> Sink<T,scala.concurrent.Future<Done>> foreachAsync(int parallelism, scala.Function1<T,scala.concurrent.Future<scala.runtime.BoxedUnit>> f)
ASinkthat will invoke the given procedure asynchronously for each received element. The sink is materialized into aFuturewhich will be completed withSuccesswhen reaching the normal end of the stream, or completed withFailureif there is a failure signaled in the stream.
-
combine
public <T,U> Sink<T,NotUsed> combine(Sink<U,?> first, Sink<U,?> second, scala.collection.immutable.Seq<Sink<U,?>> rest, scala.Function1<java.lang.Object,Graph<UniformFanOutShape<T,U>,NotUsed>> fanOutStrategy)
Combine several sinks with fan-out strategy likeBroadcastorBalanceand returnsSink.
-
combineMat
public <T,U,M1,M2,M> Sink<T,M> combineMat(Sink<U,M1> first, Sink<U,M2> second, scala.Function1<java.lang.Object,Graph<UniformFanOutShape<T,U>,NotUsed>> fanOutStrategy, scala.Function2<M1,M2,M> matF)
Combine two sinks with fan-out strategy likeBroadcastorBalanceand returnsSinkwith 2 outlets.- Since:
- 1.1.0
-
combine
public <T,U,M> Sink<T,scala.collection.immutable.Seq<M>> combine(scala.collection.immutable.Seq<Graph<SinkShape<U>,M>> sinks, scala.Function1<java.lang.Object,Graph<UniformFanOutShape<T,U>,NotUsed>> fanOutStrategy)
Combine several sinks with fan-out strategy likeBroadcastorBalanceand returnsSink. The fanoutGraph's outlets size must match the provides sinks'.- Since:
- 1.1.0
-
foreachParallel
public <T> Sink<T,scala.concurrent.Future<Done>> foreachParallel(int parallelism, scala.Function1<T,scala.runtime.BoxedUnit> f, scala.concurrent.ExecutionContext ec)
Deprecated.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. Since Akka 2.5.17.ASinkthat will invoke the given function to each of the elements as they pass in. The sink is materialized into aFutureIf
fthrows an exception and the supervision decision ispekko.stream.Supervision.StoptheFuturewill be completed with failure.If
fthrows an exception and the supervision decision ispekko.stream.Supervision.Resumeorpekko.stream.Supervision.Restartthe element is dropped and the stream continues.See also
Flow.mapAsyncUnordered
-
fold
public <U,T> Sink<T,scala.concurrent.Future<U>> fold(U zero, scala.Function2<U,T,U> f)
ASinkthat will invoke the given function for every received element, giving it its previous output (or the givenzerovalue) and the element as input. The returnedFuturewill 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.
-
foldWhile
public <U,T> Sink<T,scala.concurrent.Future<U>> foldWhile(U zero, scala.Function1<U,java.lang.Object> p, scala.Function2<U,T,U> f)
ASinkthat will invoke the given function for every received element, giving it its previous output (or the givenzerovalue) and the element as input. The returnedFuturewill 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:
fold(U, scala.Function2<U, T, U>)
-
foldAsync
public <U,T> Sink<T,scala.concurrent.Future<U>> foldAsync(U zero, scala.Function2<U,T,scala.concurrent.Future<U>> f)
ASinkthat will invoke the given asynchronous function for every received element, giving it its previous output (or the givenzerovalue) and the element as input. The returnedFuturewill 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:
fold(U, scala.Function2<U, T, U>)
-
forall
public <T> Sink<T,scala.concurrent.Future<java.lang.Object>> forall(scala.Function1<T,java.lang.Object> p)
ASinkthat will test the given predicatepfor every received element and 1. completes and returnsFutureoftrueif the predicate is true for all elements; 2. completes and returnsFutureoftrueif the stream is empty (i.e. completes before signalling any elements); 3. completes and returnsFutureoffalseif the predicate is false for any element.The materialized value
Futurewill be completed with the valuetrueorfalsewhen the input stream ends, or completed withFailureif there is a failure signaled in the stream.Adheres to the
ActorAttributes.SupervisionStrategyattribute.'''Completes when''' upstream completes or the predicate
preturnsfalse'''Backpressures when''' the invocation of predicate
phas not yet completed'''Cancels when''' predicate
preturnsfalse- Since:
- 1.1.0
-
none
public <T> Sink<T,scala.concurrent.Future<java.lang.Object>> none(scala.Function1<T,java.lang.Object> p)
ASinkthat will test the given predicatepfor every received element and 1. completes and returnsFutureoftrueif the predicate is false for all elements; 2. completes and returnsFutureoftrueif the stream is empty (i.e. completes before signalling any elements); 3. completes and returnsFutureoffalseif the predicate is true for any element.The materialized value
Futurewill be completed with the valuetrueorfalsewhen the input stream ends, or completed withFailureif there is a failure signaled in the stream.Adheres to the
ActorAttributes.SupervisionStrategyattribute.'''Completes when''' upstream completes or the predicate
preturnstrue'''Backpressures when''' the invocation of predicate
phas not yet completed'''Cancels when''' predicate
preturnstrue- Since:
- 1.2.0
-
exists
public <T> Sink<T,scala.concurrent.Future<java.lang.Object>> exists(scala.Function1<T,java.lang.Object> p)
ASinkthat will test the given predicatepfor every received element and 1. completes and returnsFutureoftrueif the predicate is true for any element; 2. completes and returnsFutureoffalseif the stream is empty (i.e. completes before signalling any elements); 3. completes and returnsFutureoffalseif the predicate is false for all elements.The materialized value
Futurewill be completed with the valuetrueorfalsewhen the input stream ends, or completed withFailureif there is a failure signaled in the stream.Adheres to the
ActorAttributes.SupervisionStrategyattribute.'''Completes when''' upstream completes or the predicate
preturnstrue'''Backpressures when''' the invocation of predicate
phas not yet completed'''Cancels when''' predicate
preturnstrue- Since:
- 1.1.0
-
reduce
public <T> Sink<T,scala.concurrent.Future<T>> reduce(scala.Function2<T,T,T> f)
ASinkthat will invoke the given function for every received element, giving it its previous output (from the second element) and the element as input. The returnedFuturewill 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.SupervisionStrategyattribute.
-
onComplete
public <T> Sink<T,NotUsed> onComplete(scala.Function1<scala.util.Try<Done>,scala.runtime.BoxedUnit> callback)
ASinkthat when the flow is completed, either through a failure or normal completion, apply the provided function withSuccessorFailure.
-
actorRef
public <T> Sink<T,NotUsed> actorRef(ActorRef ref, java.lang.Object onCompleteMessage, scala.Function1<java.lang.Throwable,java.lang.Object> onFailureMessage)
INTERNAL APISends 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.
-
actorRef
public <T> Sink<T,NotUsed> actorRef(ActorRef ref, java.lang.Object onCompleteMessage)
Deprecated.Use variant accepting both on complete and on failure message. Since Akka 2.6.0.Sends the elements of the stream to the givenActorRef. 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 apekko.actor.Status.Failuremessage 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.
-
actorRefWithBackpressure
public <T> Sink<T,NotUsed> actorRefWithBackpressure(ActorRef ref, java.lang.Object onInitMessage, java.lang.Object ackMessage, java.lang.Object onCompleteMessage, scala.Function1<java.lang.Throwable,java.lang.Object> onFailureMessage)
Sends the elements of the stream to the givenActorRefthat 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.
-
actorRefWithBackpressure
public <T> Sink<T,NotUsed> actorRefWithBackpressure(ActorRef ref, java.lang.Object onInitMessage, java.lang.Object onCompleteMessage, scala.Function1<java.lang.Throwable,java.lang.Object> onFailureMessage)
Sends the elements of the stream to the givenActorRefthat 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.
-
actorRefWithAck
public <T> Sink<T,NotUsed> actorRefWithAck(ActorRef ref, java.lang.Object onInitMessage, java.lang.Object ackMessage, java.lang.Object onCompleteMessage, scala.Function1<java.lang.Throwable,java.lang.Object> onFailureMessage)
Deprecated.Use actorRefWithBackpressure accepting completion and failure matchers instead. Since Akka 2.6.0.Sends the elements of the stream to the givenActorRefthat 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.
-
actorRefWithAck$default$5
public <T> scala.Function1<java.lang.Throwable,java.lang.Object> actorRefWithAck$default$5()
-
queue
public <T> Sink<T,SinkQueueWithCancel<T>> queue(int maxConcurrentPulls)
Creates aSinkthat is materialized as anpekko.stream.scaladsl.SinkQueueWithCancel.pekko.stream.scaladsl.SinkQueueWithCancel.pullmethod 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
maxConcurrentPullsor wait until some of the previous Futures completes. Pull returns Failed future with ''IllegalStateException'' if there will be more thenmaxConcurrentPullsnumber of pending pulls.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 usingSink.withAttributesmethod.For stream completion you need to pull all elements from
pekko.stream.scaladsl.SinkQueueWithCancelincluding last None as completion markerSee also
pekko.stream.scaladsl.SinkQueueWithCancel
-
queue
public <T> Sink<T,SinkQueueWithCancel<T>> queue()
Creates aSinkthat is materialized as anpekko.stream.scaladsl.SinkQueueWithCancel.pekko.stream.scaladsl.SinkQueueWithCancel.pullmethod 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 usingSink.withAttributesmethod.For stream completion you need to pull all elements from
pekko.stream.scaladsl.SinkQueueWithCancelincluding last None as completion markerSee also
pekko.stream.scaladsl.SinkQueueWithCancel
-
lazyInit
public <T,M> Sink<T,scala.concurrent.Future<M>> lazyInit(scala.Function1<T,scala.concurrent.Future<Sink<T,M>>> sinkFactory, scala.Function0<M> fallback)
Deprecated.Use 'Sink.lazyFutureSink' in combination with 'Flow.prefixAndTail(1)' instead. Since Akka 2.6.0.Creates a realSinkupon receiving the first element. InternalSinkwill not be created if there are no elements, because of completion or error.If upstream completes before an element was received then the
Futureis completed with the value created by fallback. If upstream fails before an element was received,sinkFactorythrows an exception, or materialization of the internal sink fails then theFutureis completed with the exception. Otherwise theFutureis completed with the materialized value of the internal sink.
-
lazyInitAsync
public <T,M> Sink<T,scala.concurrent.Future<scala.Option<M>>> lazyInitAsync(scala.Function0<scala.concurrent.Future<Sink<T,M>>> sinkFactory)
Deprecated.Use 'Sink.lazyFutureSink' instead. Since Akka 2.6.0.Creates a realSinkupon receiving the first element. InternalSinkwill not be created if there are no elements, because of completion or error.If upstream completes before an element was received then the
Futureis completed withNone. If upstream fails before an element was received,sinkFactorythrows an exception, or materialization of the internal sink fails then theFutureis completed with the exception. Otherwise theFutureis completed with the materialized value of the internal sink.
-
futureSink
public <T,M> Sink<T,scala.concurrent.Future<M>> futureSink(scala.concurrent.Future<Sink<T,M>> future)
Turn aFuture[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
NeverMaterializedExceptionif upstream fails or downstream cancels before the future has completed.
-
lazySink
public <T,M> Sink<T,scala.concurrent.Future<M>> lazySink(scala.Function0<Sink<T,M>> create)
Defers invoking thecreatefunction 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 apekko.stream.NeverMaterializedException.
-
lazyFutureSink
public <T,M> Sink<T,scala.concurrent.Future<M>> lazyFutureSink(scala.Function0<scala.concurrent.Future<Sink<T,M>>> create)
Defers invoking thecreatefunction 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 apekko.stream.NeverMaterializedException.
-
-