Class Sink$


  • public class Sink$
    extends java.lang.Object
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static Sink$ MODULE$
      Static reference to the singleton instance of this Scala 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 given ActorRef that 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 given ActorRef that sends back back-pressure signal.
      <T> Sink<T,​org.reactivestreams.Publisher<T>> asPublisher​(boolean fanout)
      A Sink that materializes into a Publisher.
      <T> Sink<T,​NotUsed> cancelled()
      A Sink that immediately cancels its upstream after materialization.
      <T,​That>
      Sink<T,​scala.concurrent.Future<That>>
      collection​(scala.collection.Factory<T,​That> cbf)
      A Sink that 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 like Broadcast or Balance and returns Sink.
      <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 like Broadcast or Balance and returns Sink.
      <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 like Broadcast or Balance and returns Sink with 2 outlets.
      <U,​T>
      Sink<T,​scala.concurrent.Future<U>>
      fold​(U zero, scala.Function2<U,​T,​U> f)
      A Sink that will invoke the given function for every received element, giving it its previous output (or the given zero value) and the element as input.
      <U,​T>
      Sink<T,​scala.concurrent.Future<U>>
      foldAsync​(U zero, scala.Function2<U,​T,​scala.concurrent.Future<U>> f)
      A Sink that will invoke the given asynchronous function for every received element, giving it its previous output (or the given zero value) and the element as input.
      <T> Sink<T,​scala.concurrent.Future<Done>> foreach​(scala.Function1<T,​scala.runtime.BoxedUnit> f)
      A Sink that 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)
      A Sink that 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 a Sink until materialization.
      <T> Sink<T,​NotUsed> fromSubscriber​(org.reactivestreams.Subscriber<T> subscriber)
      Helper to create Sink from Subscriber.
      <T,​M>
      Sink<T,​scala.concurrent.Future<M>>
      futureSink​(scala.concurrent.Future<Sink<T,​M>> future)
      Turn a Future[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()
      A Sink that materializes into a Future of the first value received.
      <T> Sink<T,​scala.concurrent.Future<scala.Option<T>>> headOption()
      A Sink that materializes into a Future of the optional first value received.
      Sink<java.lang.Object,​scala.concurrent.Future<Done>> ignore()
      A Sink that will consume the stream and discard the elements.
      <T> Sink<T,​scala.concurrent.Future<T>> last()
      A Sink that materializes into a Future of the last value received.
      <T> Sink<T,​scala.concurrent.Future<scala.Option<T>>> lastOption()
      A Sink that materializes into a Future of 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 the create function 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 the create function to create a sink until there is a first element passed from upstream.
      Sink<java.lang.Object,​scala.concurrent.Future<Done>> never()
      A Sink that will always backpressure never cancel and never consume any elements from the stream.
      <T> Sink<T,​NotUsed> onComplete​(scala.Function1<scala.util.Try<Done>,​scala.runtime.BoxedUnit> callback)
      A Sink that when the flow is completed, either through a failure or normal completion, apply the provided function with Success or Failure.
      <T> Sink<T,​SinkQueueWithCancel<T>> queue()
      Creates a Sink that is materialized as an SinkQueueWithCancel.
      <T> Sink<T,​SinkQueueWithCancel<T>> queue​(int maxConcurrentPulls)
      Creates a Sink that is materialized as an SinkQueueWithCancel.
      <T> Sink<T,​scala.concurrent.Future<T>> reduce​(scala.Function2<T,​T,​T> f)
      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.
      <T> Sink<T,​scala.concurrent.Future<scala.collection.immutable.Seq<T>>> seq()
      A Sink that 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)
      A Sink that materializes into a a Future of immutable.Seq[T] containing the last n collected elements.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • MODULE$

        public static final Sink$ MODULE$
        Static reference to the singleton instance of this Scala object.
    • Constructor Detail

      • Sink$

        public Sink$()
    • 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)
        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.
      • setup

        public <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.
        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.
      • fromSubscriber

        public <T> Sink<T,​NotUsed> fromSubscriber​(org.reactivestreams.Subscriber<T> subscriber)
        Helper to create Sink from Subscriber.
      • cancelled

        public <T> Sink<T,​NotUsed> cancelled()
        A Sink that immediately cancels its upstream after materialization.
      • head

        public <T> Sink<T,​scala.concurrent.Future<T>> head()
        A Sink that materializes into a Future of the first value received. If the stream completes before signaling at least a single element, the Future will be failed with a NoSuchElementException. If the stream signals an error errors before signaling at least a single element, the Future will be failed with the streams exception.

        See also <T>headOption().

      • headOption

        public <T> Sink<T,​scala.concurrent.Future<scala.Option<T>>> headOption()
        A Sink that materializes into a Future of the optional first value received. If the stream completes before signaling at least a single element, the value of the Future will be None. If the stream signals an error errors before signaling at least a single element, the Future will be failed with the streams exception.

        See also <T>head().

      • last

        public <T> Sink<T,​scala.concurrent.Future<T>> last()
        A Sink that materializes into a Future of the last value received. If the stream completes before signaling at least a single element, the Future will be failed with a NoSuchElementException. If the stream signals an error, the Future will be failed with the stream's exception.

        See also <T>lastOption(), <T>takeLast(int).

      • lastOption

        public <T> Sink<T,​scala.concurrent.Future<scala.Option<T>>> lastOption()
        A Sink that materializes into a Future of the optional last value received. If the stream completes before signaling at least a single element, the value of the Future will be None. If the stream signals an error, the Future will be failed with the stream's exception.

        See also <T>last(), <T>takeLast(int).

      • takeLast

        public <T> Sink<T,​scala.concurrent.Future<scala.collection.immutable.Seq<T>>> takeLast​(int n)
        A Sink that materializes into a a Future of immutable.Seq[T] containing the last n collected elements.

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

      • seq

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

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

      • collection

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

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

      • asPublisher

        public <T> Sink<T,​org.reactivestreams.Publisher<T>> asPublisher​(boolean fanout)
        A Sink that materializes into a Publisher.

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

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

      • ignore

        public Sink<java.lang.Object,​scala.concurrent.Future<Done>> ignore()
        A Sink that will consume the stream and discard the elements.
      • never

        public Sink<java.lang.Object,​scala.concurrent.Future<Done>> never()
        A Sink that 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)
        A Sink that will invoke the given procedure for each received element. The sink is materialized into a Future which will be completed with Success when reaching the normal end of the stream, or completed with Failure if there is a failure signaled in the stream.
      • foreachAsync

        public <T> Sink<T,​scala.concurrent.Future<Done>> foreachAsync​(int parallelism,
                                                                            scala.Function1<T,​scala.concurrent.Future<scala.runtime.BoxedUnit>> f)
        A Sink that will invoke the given procedure asynchronously for each received element. The sink is materialized into a Future which will be completed with Success when reaching the normal end of the stream, or completed with Failure if there is a failure signaled in the stream.
      • 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 like Broadcast or Balance and returns Sink.
      • 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 like Broadcast or Balance and returns Sink with 2 outlets.
      • 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 like Broadcast or Balance and returns Sink. The fanoutGraph's outlets size must match the provides sinks'.
      • 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 2.5.17.
        A Sink that will invoke the given function to each of the elements as they pass in. The sink is materialized into a Future

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

        If f throws an exception and the supervision decision is akka.stream.Supervision.Resume or akka.stream.Supervision.Restart the 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)
        A Sink that will invoke the given function for every received element, giving it its previous output (or the given zero value) and the element as input. The returned Future will be completed with value of the final function evaluation when the input stream ends, or completed with Failure if there is a failure signaled in the stream.

        See Also:
        foldAsync(U, scala.Function2<U, T, scala.concurrent.Future<U>>)
      • foldAsync

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

        See Also:
        fold(U, scala.Function2<U, T, U>)
      • reduce

        public <T> Sink<T,​scala.concurrent.Future<T>> reduce​(scala.Function2<T,​T,​T> f)
        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 Future will be completed with value of the final function evaluation when the input stream ends, or completed with Failure if there is a failure signaled in the stream.

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

        Adheres to the ActorAttributes.SupervisionStrategy attribute.

      • onComplete

        public <T> Sink<T,​NotUsed> onComplete​(scala.Function1<scala.util.Try<Done>,​scala.runtime.BoxedUnit> callback)
        A Sink that when the flow is completed, either through a failure or normal completion, apply the provided function with Success or Failure.
      • actorRef

        public <T> Sink<T,​NotUsed> actorRef​(ActorRef ref,
                                                  java.lang.Object onCompleteMessage,
                                                  scala.Function1<java.lang.Throwable,​java.lang.Object> onFailureMessage)
        INTERNAL API

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

        It will request at most maxInputBufferSize number of elements from upstream, but there is no back-pressure signal from the destination actor, i.e. if the actor is not consuming the messages fast enough the mailbox of the actor will grow. For potentially slow consumer actors it is recommended to use a bounded mailbox with zero mailbox-push-timeout-time or use a rate limiting operator in front of this Sink.

      • 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 2.6.0.
        Sends the elements of the stream to the given ActorRef. If the target actor terminates the stream will be canceled. When the stream is completed successfully the given onCompleteMessage will be sent to the destination actor. When the stream is completed with failure a Status.Failure message will be sent to the destination actor.

        It will request at most maxInputBufferSize number of elements from upstream, but there is no back-pressure signal from the destination actor, i.e. if the actor is not consuming the messages fast enough the mailbox of the actor will grow. For potentially slow consumer actors it is recommended to use a bounded mailbox with zero mailbox-push-timeout-time or use a rate limiting operator in front of this Sink.

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

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

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

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

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

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

      • 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 a Sink that is materialized as an SinkQueueWithCancel. akka.stream.scaladsl.SinkQueueWithCancel.pull method is pulling element from the stream and returns Future[Option[T]. Future completes when element is available.

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

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

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

        See also SinkQueueWithCancel

      • queue

        public <T> Sink<T,​SinkQueueWithCancel<T>> queue()
        Creates a Sink that is materialized as an SinkQueueWithCancel. akka.stream.scaladsl.SinkQueueWithCancel.pull method is pulling element from the stream and returns Future[Option[T}. Future completes when element is available.

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

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

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

        See also 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 2.6.0.
        Creates a real Sink upon receiving the first element. Internal Sink will not be created if there are no elements, because of completion or error.

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

      • 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 2.6.0.
        Creates a real Sink upon receiving the first element. Internal Sink will not be created if there are no elements, because of completion or error.

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

      • futureSink

        public <T,​M> Sink<T,​scala.concurrent.Future<M>> futureSink​(scala.concurrent.Future<Sink<T,​M>> future)
        Turn a Future[Sink] into a Sink that will consume the values of the source when the future completes successfully. If the Future is completed with a failure the stream is failed.

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

      • lazySink

        public <T,​M> Sink<T,​scala.concurrent.Future<M>> lazySink​(scala.Function0<Sink<T,​M>> create)
        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 NeverMaterializedException.

      • lazyFutureSink

        public <T,​M> Sink<T,​scala.concurrent.Future<M>> lazyFutureSink​(scala.Function0<scala.concurrent.Future<Sink<T,​M>>> create)
        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 NeverMaterializedException.