Class Sink<In,Mat>
- java.lang.Object
-
- akka.stream.scaladsl.Sink<In,Mat>
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface akka.stream.Graph
Graph.GraphMapMatVal<S extends Shape,M>
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static <T> Sink<T,NotUsed>actorRef(ActorRef ref, java.lang.Object onCompleteMessage)Deprecated.Use variant accepting both on complete and on failure message.static <T> Sink<T,NotUsed>actorRef(ActorRef ref, java.lang.Object onCompleteMessage, scala.Function1<java.lang.Throwable,java.lang.Object> onFailureMessage)INTERNAL APIstatic <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.static <T> scala.Function1<java.lang.Throwable,java.lang.Object>actorRefWithAck$default$5()static <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.static <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.Sink<In,Mat>addAttributes(Attributes attr)Add the given attributes to thisSink.<JIn extends In>
Sink<JIn,Mat>asJava()Converts this Scala DSL element to it's Java DSL counterpart.static <T> Sink<T,org.reactivestreams.Publisher<T>>asPublisher(boolean fanout)ASinkthat materializes into aPublisher.Sink<In,Mat>async()Put an asynchronous boundary around thisSourceSink<In,Mat>async(java.lang.String dispatcher)Put an asynchronous boundary around thisGraphSink<In,Mat>async(java.lang.String dispatcher, int inputBufferSize)Put an asynchronous boundary around thisGraphstatic <T> Sink<T,NotUsed>cancelled()ASinkthat immediately cancels its upstream after materialization.static <T,That>
Sink<T,scala.concurrent.Future<That>>collection(scala.collection.Factory<T,That> cbf)ASinkthat keeps on collecting incoming elements until upstream terminates.static <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.static <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.static <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.<In2> Sink<In2,Mat>contramap(scala.Function1<In2,In> f)Transform this Sink by applying a function to each *incoming* upstream element before it is passed to theSinkstatic <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.static <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.static <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.static <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.static <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.static <T,M>
Sink<T,scala.concurrent.Future<M>>fromMaterializer(scala.Function2<Materializer,Attributes,Sink<T,M>> factory)Defers the creation of aSinkuntil materialization.static <T> Sink<T,NotUsed>fromSubscriber(org.reactivestreams.Subscriber<T> subscriber)Helper to createSinkfromSubscriber.static <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.AttributesgetAttributes()static <T> Sink<T,scala.concurrent.Future<T>>head()ASinkthat materializes into aFutureof the first value received.static <T> Sink<T,scala.concurrent.Future<scala.Option<T>>>headOption()ASinkthat materializes into aFutureof the optional first value received.static Sink<java.lang.Object,scala.concurrent.Future<Done>>ignore()ASinkthat will consume the stream and discard the elements.static <T> Sink<T,scala.concurrent.Future<T>>last()ASinkthat materializes into aFutureof the last value received.static <T> Sink<T,scala.concurrent.Future<scala.Option<T>>>lastOption()ASinkthat materializes into aFutureof the optional last value received.static <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.static <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.static <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.static <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.<Mat2> Sink<In,Mat2>mapMaterializedValue(scala.Function1<Mat,Mat2> f)Transform only the materialized value of this Sink, leaving all other properties as they were.Sink<In,Mat>named(java.lang.String name)Add anameattribute to this Sink.static Sink<java.lang.Object,scala.concurrent.Future<Done>>never()ASinkthat will always backpressure never cancel and never consume any elements from the stream.static <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.scala.Tuple2<Mat,Sink<In,NotUsed>>preMaterialize(Materializer materializer)Materializes this Sink, immediately returning (1) its materialized value, and (2) a new Sink that can be consume elements 'into' the pre-materialized one.static <T> Sink<T,SinkQueueWithCancel<T>>queue()Creates aSinkthat is materialized as anSinkQueueWithCancel.static <T> Sink<T,SinkQueueWithCancel<T>>queue(int maxConcurrentPulls)Creates aSinkthat is materialized as anSinkQueueWithCancel.static <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.<Mat2> Mat2runWith(Graph<SourceShape<In>,Mat2> source, Materializer materializer)Connect thisSinkto aSourceand run it.static <T> Sink<T,scala.concurrent.Future<scala.collection.immutable.Seq<T>>>seq()ASinkthat keeps on collecting incoming elements until upstream terminates.static <T,M>
Sink<T,scala.concurrent.Future<M>>setup(scala.Function2<ActorMaterializer,Attributes,Sink<T,M>> factory)Deprecated.Use 'fromMaterializer' instead.SinkShape<In>shape()The shape of a graph is all that is externally visible: its inlets and outlets.static <T> Sink<T,scala.concurrent.Future<scala.collection.immutable.Seq<T>>>takeLast(int n)ASinkthat materializes into a aFutureofimmutable.Seq[T]containing the lastncollected elements.java.lang.StringtoString()akka.stream.impl.LinearTraversalBuildertraversalBuilder()INTERNAL API.Sink<In,Mat>withAttributes(Attributes attr)Replace the attributes of thisSinkwith the given ones.
-
-
-
Method Detail
-
fromGraph
public static <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 static <T,M> Sink<T,scala.concurrent.Future<M>> fromMaterializer(scala.Function2<Materializer,Attributes,Sink<T,M>> factory)
-
setup
public static <T,M> Sink<T,scala.concurrent.Future<M>> setup(scala.Function2<ActorMaterializer,Attributes,Sink<T,M>> factory)
Deprecated.Use 'fromMaterializer' instead. Since 2.6.0.
-
fromSubscriber
public static <T> Sink<T,NotUsed> fromSubscriber(org.reactivestreams.Subscriber<T> subscriber)
Helper to createSinkfromSubscriber.
-
cancelled
public static <T> Sink<T,NotUsed> cancelled()
ASinkthat immediately cancels its upstream after materialization.
-
head
public static <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 static <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 static <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 static <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 static <T> Sink<T,scala.concurrent.Future<scala.collection.immutable.Seq<T>>> takeLast(int n)
ASinkthat materializes into a 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 static <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 static <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 static <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 static Sink<java.lang.Object,scala.concurrent.Future<Done>> ignore()
ASinkthat will consume the stream and discard the elements.
-
never
public static 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 static <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 static <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 static <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 static <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.
-
combine
public static <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'.
-
fold
public static <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.
-
foldAsync
public static <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>)
-
reduce
public static <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 static <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 static <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 static <T> Sink<T,NotUsed> actorRef(ActorRef ref, java.lang.Object onCompleteMessage)
Deprecated.Use variant accepting both on complete and on failure message. Since 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 aStatus.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 static <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 static <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 static <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 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 static <T> scala.Function1<java.lang.Throwable,java.lang.Object> actorRefWithAck$default$5()
-
queue
public static <T> Sink<T,SinkQueueWithCancel<T>> queue(int maxConcurrentPulls)
Creates aSinkthat is materialized as anSinkQueueWithCancel.akka.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
SinkQueueWithCancelincluding last None as completion markerSee also
SinkQueueWithCancel
-
queue
public static <T> Sink<T,SinkQueueWithCancel<T>> queue()
Creates aSinkthat is materialized as anSinkQueueWithCancel.akka.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
SinkQueueWithCancelincluding last None as completion markerSee also
SinkQueueWithCancel
-
lazyInit
public static <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 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 static <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 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 static <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 static <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 aNeverMaterializedException.
-
lazyFutureSink
public static <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 aNeverMaterializedException.
-
traversalBuilder
public akka.stream.impl.LinearTraversalBuilder traversalBuilder()
Description copied from interface:GraphINTERNAL API.Every materializable element must be backed by a stream layout module
- Specified by:
traversalBuilderin interfaceGraph<In,Mat>
-
shape
public SinkShape<In> shape()
Description copied from interface:GraphThe shape of a graph is all that is externally visible: its inlets and outlets.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
runWith
public <Mat2> Mat2 runWith(Graph<SourceShape<In>,Mat2> source, Materializer materializer)
Connect thisSinkto aSourceand run it. The returned value is the materialized value of theSource, e.g. theSubscriberof aSource#subscriber.Note that the
ActorSystemcan be used as the implicitmaterializerparameter to use theSystemMaterializerfor running the stream.
-
mapMaterializedValue
public <Mat2> Sink<In,Mat2> mapMaterializedValue(scala.Function1<Mat,Mat2> f)
Transform only the materialized value of this Sink, leaving all other properties as they were.
-
preMaterialize
public scala.Tuple2<Mat,Sink<In,NotUsed>> preMaterialize(Materializer materializer)
Materializes this Sink, immediately returning (1) its materialized value, and (2) a new Sink that can be consume elements 'into' the pre-materialized one.Useful for when you need a materialized value of a Sink when handing it out to someone to materialize it for you.
-
withAttributes
public Sink<In,Mat> withAttributes(Attributes attr)
Replace the attributes of thisSinkwith the given ones. If this Sink is a composite of multiple graphs, new attributes on the composite will be less specific than attributes set directly on the individual graphs of the composite.- Specified by:
withAttributesin interfaceGraph<In,Mat>
-
addAttributes
public Sink<In,Mat> addAttributes(Attributes attr)
Add the given attributes to thisSink. If the specific attribute was already present on this graph this means the added attribute will be more specific than the existing one. If this Sink is a composite of multiple graphs, new attributes on the composite will be less specific than attributes set directly on the individual graphs of the composite.- Specified by:
addAttributesin interfaceGraph<In,Mat>
-
async
public Sink<In,Mat> async(java.lang.String dispatcher)
Put an asynchronous boundary around thisGraph
-
async
public Sink<In,Mat> async(java.lang.String dispatcher, int inputBufferSize)
Put an asynchronous boundary around thisGraph
-
asJava
public <JIn extends In> Sink<JIn,Mat> asJava()
Converts this Scala DSL element to it's Java DSL counterpart.
-
getAttributes
public Attributes getAttributes()
- Specified by:
getAttributesin interfaceGraph<In,Mat>
-
-