Class Sink<In,​Mat>

  • All Implemented Interfaces:
    Graph<SinkShape<In>,​Mat>

    public final class Sink<In,​Mat>
    extends java.lang.Object
    implements Graph<SinkShape<In>,​Mat>
    A Sink is a set of stream processing steps that has one open input. Can be used as a Subscriber
    • 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)
      Sends the elements of the stream to the given ActorRef.
      static <T> Sink<T,​NotUsed> actorRef​(ActorRef ref, java.lang.Object onCompleteMessage, scala.Function1<java.lang.Throwable,​java.lang.Object> onFailureMessage)
      INTERNAL API
      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)
      Sends the elements of the stream to the given ActorRef that sends back back-pressure signal.
      static <T> Sink<T,​NotUsed> actorRefWithAck​(ActorRef ref, scala.Function1<ActorRef,​scala.Function1<T,​java.lang.Object>> messageAdapter, scala.Function1<ActorRef,​java.lang.Object> onInitMessage, java.lang.Object ackMessage, java.lang.Object onCompleteMessage, scala.Function1<java.lang.Throwable,​java.lang.Object> onFailureMessage)
      INTERNAL API
      static <T> scala.Function1<java.lang.Throwable,​java.lang.Object> actorRefWithAck$default$5()  
      static <T> Sink<T,​ActorRef> actorSubscriber​(Props props)
      Deprecated.
      Use akka.stream.stage.GraphStage and fromGraph instead, it allows for all operations an Actor would and is more type-safe as well as guaranteed to be ReactiveStreams compliant.
      Sink<In,​Mat> addAttributes​(Attributes attr)
      Add the given attributes to this Sink.
      <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)
      A Sink that materializes into a Publisher.
      Sink<In,​Mat> async()
      Put an asynchronous boundary around this Source
      Sink<In,​Mat> async​(java.lang.String dispatcher)
      Put an asynchronous boundary around this Graph
      Sink<In,​Mat> async​(java.lang.String dispatcher, int inputBufferSize)
      Put an asynchronous boundary around this Graph
      static <T> Sink<T,​NotUsed> cancelled()
      A Sink that immediately cancels its upstream after materialization.
      static <T,​That>
      Sink<T,​scala.concurrent.Future<That>>
      collection​(scala.collection.generic.CanBuildFrom cbf)
      A Sink that keeps on collecting incoming elements until upstream terminates.
      static <T,​U>
      Sink<T,​NotUsed>
      combine​(Sink<U,​?> first, Sink<U,​?> second, scala.collection.Seq<Sink<U,​?>> rest, scala.Function1<java.lang.Object,​Graph<UniformFanOutShape<T,​U>,​NotUsed>> strategy)
      Combine several sinks with fan-out strategy like Broadcast or Balance and returns Sink.
      <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 the Sink
      static <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.
      static <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.
      static <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.
      static <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.
      static <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.
      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> Sink<T,​NotUsed> fromSubscriber​(org.reactivestreams.Subscriber<T> subscriber)
      Helper to create Sink from Subscriber.
      static <T> Sink<T,​scala.concurrent.Future<T>> head()
      A Sink that materializes into a Future of the first value received.
      static <T> Sink<T,​scala.concurrent.Future<scala.Option<T>>> headOption()
      A Sink that materializes into a Future of the optional first value received.
      static Sink<java.lang.Object,​scala.concurrent.Future<Done>> ignore()
      A Sink that will consume the stream and discard the elements.
      static <T> Sink<T,​scala.concurrent.Future<T>> last()
      A Sink that materializes into a Future of the last value received.
      static <T> Sink<T,​scala.concurrent.Future<scala.Option<T>>> lastOption()
      A Sink that materializes into a Future of the optional last value received.
      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 lazyInitAsync instead.
      static <T,​M>
      Sink<T,​scala.concurrent.Future<scala.Option<M>>>
      lazyInitAsync​(scala.Function0<scala.concurrent.Future<Sink<T,​M>>> sinkFactory)
      Creates a real Sink upon receiving the first element.
      <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 a name attribute to this Sink.
      static <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.
      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 a Sink that is materialized as an SinkQueue.
      static <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.
      <Mat2> Mat2 runWith​(Graph<SourceShape<In>,​Mat2> source, Materializer materializer)
      Connect this Sink to a Source and run it.
      static <T> Sink<T,​scala.concurrent.Future<scala.collection.immutable.Seq<T>>> seq()
      A Sink that keeps on collecting incoming elements until upstream terminates.
      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)
      A Sink that materializes into a a Future of immutable.Seq[T] containing the last n collected elements.
      java.lang.String toString()  
      LinearTraversalBuilder traversalBuilder()
      INTERNAL API.
      Sink<In,​Mat> withAttributes​(Attributes attr)
      Replace the attributes of this Sink with the given ones.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • 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.
        Parameters:
        g - (undocumented)
        Returns:
        (undocumented)
      • fromSubscriber

        public static <T> Sink<T,​NotUsed> fromSubscriber​(org.reactivestreams.Subscriber<T> subscriber)
        Helper to create Sink from Subscriber.
        Parameters:
        subscriber - (undocumented)
        Returns:
        (undocumented)
      • cancelled

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

        public static <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().

        Returns:
        (undocumented)
      • headOption

        public static <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().

        Returns:
        (undocumented)
      • last

        public static <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).

        Returns:
        (undocumented)
      • lastOption

        public static <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).

        Returns:
        (undocumented)
      • takeLast

        public static <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.

        Parameters:
        n - (undocumented)
        Returns:
        (undocumented)
      • seq

        public static <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

        Returns:
        (undocumented)
      • collection

        public static <T,​That> Sink<T,​scala.concurrent.Future<That>> collection​(scala.collection.generic.CanBuildFrom 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

        Parameters:
        cbf - (undocumented)
        Returns:
        (undocumented)
      • asPublisher

        public static <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.

        Parameters:
        fanout - (undocumented)
        Returns:
        (undocumented)
      • ignore

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

        public static <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.
        Parameters:
        f - (undocumented)
        Returns:
        (undocumented)
      • foreachAsync

        public static <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.
        Parameters:
        parallelism - (undocumented)
        f - (undocumented)
        Returns:
        (undocumented)
      • combine

        public static <T,​U> Sink<T,​NotUsed> combine​(Sink<U,​?> first,
                                                                Sink<U,​?> second,
                                                                scala.collection.Seq<Sink<U,​?>> rest,
                                                                scala.Function1<java.lang.Object,​Graph<UniformFanOutShape<T,​U>,​NotUsed>> strategy)
        Combine several sinks with fan-out strategy like Broadcast or Balance and returns Sink.
        Parameters:
        first - (undocumented)
        second - (undocumented)
        rest - (undocumented)
        strategy - (undocumented)
        Returns:
        (undocumented)
      • foreachParallel

        public static <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

        Parameters:
        parallelism - (undocumented)
        f - (undocumented)
        ec - (undocumented)
        Returns:
        (undocumented)
      • fold

        public static <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.

        Parameters:
        zero - (undocumented)
        f - (undocumented)
        Returns:
        (undocumented)
        See Also:
        foldAsync(U, scala.Function2<U, T, scala.concurrent.Future<U>>)
      • foldAsync

        public static <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.

        Parameters:
        zero - (undocumented)
        f - (undocumented)
        Returns:
        (undocumented)
        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)
        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.

        Parameters:
        f - (undocumented)
        Returns:
        (undocumented)
      • onComplete

        public static <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.
        Parameters:
        callback - (undocumented)
        Returns:
        (undocumented)
      • actorRef

        public static <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.

        Parameters:
        ref - (undocumented)
        onCompleteMessage - (undocumented)
        onFailureMessage - (undocumented)
        Returns:
        (undocumented)
      • actorRef

        public static <T> Sink<T,​NotUsed> actorRef​(ActorRef ref,
                                                         java.lang.Object onCompleteMessage)
        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.

        Parameters:
        ref - (undocumented)
        onCompleteMessage - (undocumented)
        Returns:
        (undocumented)
      • actorRefWithAck

        public static <T> Sink<T,​NotUsed> actorRefWithAck​(ActorRef ref,
                                                                scala.Function1<ActorRef,​scala.Function1<T,​java.lang.Object>> messageAdapter,
                                                                scala.Function1<ActorRef,​java.lang.Object> onInitMessage,
                                                                java.lang.Object ackMessage,
                                                                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 that sends back back-pressure signal. First element is created by calling onInitMessage with an ActorRef of the actor that expects acknowledgements. 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.

        Every message that is sent to the actor is first transformed using messageAdapter. This can be used to capture the ActorRef of the actor that expects acknowledgments as well as transforming messages from the stream to the ones that actor under ref handles.

        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.

        Parameters:
        ref - (undocumented)
        messageAdapter - (undocumented)
        onInitMessage - (undocumented)
        ackMessage - (undocumented)
        onCompleteMessage - (undocumented)
        onFailureMessage - (undocumented)
        Returns:
        (undocumented)
      • 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)
        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.

        Parameters:
        ref - (undocumented)
        onInitMessage - (undocumented)
        ackMessage - (undocumented)
        onCompleteMessage - (undocumented)
        onFailureMessage - (undocumented)
        Returns:
        (undocumented)
      • actorRefWithAck$default$5

        public static <T> scala.Function1<java.lang.Throwable,​java.lang.Object> actorRefWithAck$default$5()
      • actorSubscriber

        public static <T> Sink<T,​ActorRef> actorSubscriber​(Props props)
        Deprecated.
        Use akka.stream.stage.GraphStage and fromGraph instead, it allows for all operations an Actor would and is more type-safe as well as guaranteed to be ReactiveStreams compliant.
        Creates a Sink that is materialized to an ActorRef which points to an Actor created according to the passed in Props. Actor created by the props must be ActorSubscriber.

        Parameters:
        props - (undocumented)
        Returns:
        (undocumented)
      • queue

        public static <T> Sink<T,​SinkQueueWithCancel<T>> queue()
        Creates a Sink that is materialized as an SinkQueue. akka.stream.scaladsl.SinkQueue.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 SinkQueue including last None as completion marker

        See also SinkQueueWithCancel

        Returns:
        (undocumented)
      • 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 lazyInitAsync instead. (lazyInitAsync no more needs a fallback function and the materialized value more clearly indicates if the internal sink was materialized or not.). Since 2.5.11.
        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.

        Parameters:
        sinkFactory - (undocumented)
        fallback - (undocumented)
        Returns:
        (undocumented)
      • lazyInitAsync

        public static <T,​M> Sink<T,​scala.concurrent.Future<scala.Option<M>>> lazyInitAsync​(scala.Function0<scala.concurrent.Future<Sink<T,​M>>> sinkFactory)
        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.

        Parameters:
        sinkFactory - (undocumented)
        Returns:
        (undocumented)
      • traversalBuilder

        public LinearTraversalBuilder traversalBuilder()
        Description copied from interface: Graph
        INTERNAL API.

        Every materializable element must be backed by a stream layout module

        Specified by:
        traversalBuilder in interface Graph<In,​Mat>
        Returns:
        (undocumented)
      • shape

        public SinkShape<In> shape()
        Description copied from interface: Graph
        The shape of a graph is all that is externally visible: its inlets and outlets.
        Specified by:
        shape in interface Graph<In,​Mat>
        Returns:
        (undocumented)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • contramap

        public <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 the Sink

        '''Backpressures when''' original Sink backpressures

        '''Cancels when''' original Sink cancels

        Parameters:
        f - (undocumented)
        Returns:
        (undocumented)
      • runWith

        public <Mat2> Mat2 runWith​(Graph<SourceShape<In>,​Mat2> source,
                                   Materializer materializer)
        Connect this Sink to a Source and run it. The returned value is the materialized value of the Source, e.g. the Subscriber of a Source#subscriber.
        Parameters:
        source - (undocumented)
        materializer - (undocumented)
        Returns:
        (undocumented)
      • 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.
        Parameters:
        f - (undocumented)
        Returns:
        (undocumented)
      • 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.

        Parameters:
        materializer - (undocumented)
        Returns:
        (undocumented)
      • withAttributes

        public Sink<In,​Mat> withAttributes​(Attributes attr)
        Replace the attributes of this Sink with 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:
        withAttributes in interface Graph<In,​Mat>
        Parameters:
        attr - (undocumented)
        Returns:
        (undocumented)
      • addAttributes

        public Sink<In,​Mat> addAttributes​(Attributes attr)
        Add the given attributes to this Sink. 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:
        addAttributes in interface Graph<In,​Mat>
        Parameters:
        attr - (undocumented)
        Returns:
        (undocumented)
      • named

        public Sink<In,​Mat> named​(java.lang.String name)
        Add a name attribute to this Sink.
        Specified by:
        named in interface Graph<In,​Mat>
        Parameters:
        name - (undocumented)
        Returns:
        (undocumented)
      • async

        public Sink<In,​Mat> async()
        Put an asynchronous boundary around this Source
        Specified by:
        async in interface Graph<In,​Mat>
        Returns:
        (undocumented)
      • async

        public Sink<In,​Mat> async​(java.lang.String dispatcher)
        Put an asynchronous boundary around this Graph

        Specified by:
        async in interface Graph<In,​Mat>
        Parameters:
        dispatcher - Run the graph on this dispatcher
        Returns:
        (undocumented)
      • async

        public Sink<In,​Mat> async​(java.lang.String dispatcher,
                                        int inputBufferSize)
        Put an asynchronous boundary around this Graph

        Specified by:
        async in interface Graph<In,​Mat>
        Parameters:
        dispatcher - Run the graph on this dispatcher
        inputBufferSize - Set the input buffer to this size for the graph
        Returns:
        (undocumented)
      • asJava

        public <JIn extends InSink<JIn,​Mat> asJava()
        Converts this Scala DSL element to it's Java DSL counterpart.
        Returns:
        (undocumented)