| Modifier and Type | Method and Description |
|---|---|
static <In> Sink<In,NotUsed> |
actorRef(ActorRef ref,
java.lang.Object onCompleteMessage)
Sends the elements of the stream to the given
ActorRef. |
static <In> Sink<In,NotUsed> |
actorRefWithAck(ActorRef ref,
java.lang.Object onInitMessage,
java.lang.Object ackMessage,
java.lang.Object onCompleteMessage,
Function<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,ActorRef> |
actorSubscriber(Props props)
|
Sink<In,Mat> |
addAttributes(Attributes attr)
Add the given attributes to this Sink.
|
static <T> Sink<T,org.reactivestreams.Publisher<T>> |
asPublisher(AsPublisher fanout)
A
Sink that materializes into a Publisher. |
Sink<In,Mat> |
asScala()
Converts this Sink to its Scala DSL counterpart.
|
Sink<In,Mat> |
async()
Put an asynchronous boundary around this
Sink |
static <T> Sink<T,NotUsed> |
cancelled()
A
Sink that immediately cancels its upstream after materialization. |
static <T,U> Sink<T,NotUsed> |
combine(Sink<U,?> output1,
Sink<U,?> output2,
java.util.List<Sink<U,?>> rest,
Function<java.lang.Integer,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(Function<In2,In> f)
Transform this Sink by applying a function to each *incoming* upstream element before
it is passed to the
Sink |
static <U,In> Sink<In,java.util.concurrent.CompletionStage<U>> |
fold(U zero,
Function2<U,In,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,In> Sink<In,java.util.concurrent.CompletionStage<U>> |
foldAsync(U zero,
Function2<U,In,java.util.concurrent.CompletionStage<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,java.util.concurrent.CompletionStage<Done>> |
foreach(Procedure<T> f)
A
Sink that will invoke the given procedure for each received element. |
static <T> Sink<T,java.util.concurrent.CompletionStage<Done>> |
foreachParallel(int parallel,
Procedure<T> f,
scala.concurrent.ExecutionContext ec)
A
Sink that will invoke the given procedure for each received element in parallel. |
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 <In> Sink<In,NotUsed> |
fromSubscriber(org.reactivestreams.Subscriber<In> subs)
Helper to create
Sink from Subscriber. |
static <In> Sink<In,java.util.concurrent.CompletionStage<In>> |
head()
A
Sink that materializes into a CompletionStage of the first value received. |
static <In> Sink<In,java.util.concurrent.CompletionStage<java.util.Optional<In>>> |
headOption()
A
Sink that materializes into a CompletionStage of the optional first value received. |
static <T> Sink<T,java.util.concurrent.CompletionStage<Done>> |
ignore()
A
Sink that will consume the stream and discard the elements. |
static <In> Sink<In,java.util.concurrent.CompletionStage<In>> |
last()
A
Sink that materializes into a CompletionStage of the last value received. |
static <In> Sink<In,java.util.concurrent.CompletionStage<java.util.Optional<In>>> |
lastOption()
A
Sink that materializes into a CompletionStage of the optional last value received. |
static <T,M> Sink<T,java.util.concurrent.CompletionStage<M>> |
lazyInit(Function<T,java.util.concurrent.CompletionStage<Sink<T,M>>> sinkFactory,
Creator<M> fallback)
Creates a real
Sink upon receiving the first element. |
<Mat2> Sink<In,Mat2> |
mapMaterializedValue(Function<Mat,Mat2> f)
Transform only the materialized value of this Sink, leaving all other properties as they were.
|
StreamLayout.Module |
module()
INTERNAL API.
|
Sink<In,Mat> |
named(java.lang.String name)
Add a
name attribute to this Sink. |
static <In> Sink<In,NotUsed> |
onComplete(Procedure<scala.util.Try<Done>> callback)
A
Sink that when the flow is completed, either through a failure or normal
completion, apply the provided function with Success
or Failure. |
static <T> Sink<T,SinkQueueWithCancel<T>> |
queue()
Creates a
Sink that is materialized as an SinkQueue. |
static <In> Sink<In,java.util.concurrent.CompletionStage<In>> |
reduce(Function2<In,In,In> 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. |
<M> M |
runWith(Graph<SourceShape<In>,M> source,
Materializer materializer)
Connect this
Sink to a Source and run it. |
static <In> Sink<In,java.util.concurrent.CompletionStage<java.util.List<In>>> |
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.
|
java.lang.String |
toString() |
Sink<In,Mat> |
withAttributes(Attributes attr)
Change the attributes of this
Sink to the given ones and seal the list
of attributes. |
public static <U,In> Sink<In,java.util.concurrent.CompletionStage<U>> fold(U zero, Function2<U,In,U> f)
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 CompletionStage will be completed with value of the final
function evaluation when the input stream ends, or completed with Failure
if there is a failure is signaled in the stream.zero - (undocumented)f - (undocumented)public static <U,In> Sink<In,java.util.concurrent.CompletionStage<U>> foldAsync(U zero, Function2<U,In,java.util.concurrent.CompletionStage<U>> f)
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 CompletionStage will be completed with value of the final
function evaluation when the input stream ends, or completed with Failure
if there is a failure is signaled in the stream.zero - (undocumented)f - (undocumented)public static <In> Sink<In,java.util.concurrent.CompletionStage<In>> reduce(Function2<In,In,In> f)
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 CompletionStage 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 stage will fail its downstream with a NoSuchElementException,
which is semantically in-line with that Scala's standard library collections
do in such situations.
f - (undocumented)public static <In> Sink<In,NotUsed> fromSubscriber(org.reactivestreams.Subscriber<In> subs)
Sink from Subscriber.subs - (undocumented)public static <T> Sink<T,NotUsed> cancelled()
Sink that immediately cancels its upstream after materialization.public static <T> Sink<T,java.util.concurrent.CompletionStage<Done>> ignore()
Sink that will consume the stream and discard the elements.public static <T> Sink<T,org.reactivestreams.Publisher<T>> asPublisher(AsPublisher fanout)
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 stage 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.
fanout - (undocumented)public static <T> Sink<T,java.util.concurrent.CompletionStage<Done>> foreach(Procedure<T> f)
Sink that will invoke the given procedure for each received element. The sink is materialized
into a CompletionStage will be completed with Success when reaching the
normal end of the stream, or completed with Failure if there is a failure is signaled in
the stream..f - (undocumented)public static <T> Sink<T,java.util.concurrent.CompletionStage<Done>> foreachParallel(int parallel, Procedure<T> f, scala.concurrent.ExecutionContext ec)
Sink that will invoke the given procedure for each received element in parallel. The sink is materialized
into a CompletionStage.
If f throws an exception and the supervision decision is
akka.stream.Supervision.Stop the CompletionStage 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.
parallel - (undocumented)f - (undocumented)ec - (undocumented)public static <In> Sink<In,NotUsed> onComplete(Procedure<scala.util.Try<Done>> callback)
Sink that when the flow is completed, either through a failure or normal
completion, apply the provided function with Success
or Failure.callback - (undocumented)public static <In> Sink<In,java.util.concurrent.CompletionStage<In>> head()
Sink that materializes into a CompletionStage of the first value received.
If the stream completes before signaling at least a single element, the CompletionStage will be failed with a NoSuchElementException.
If the stream signals an error before signaling at least a single element, the CompletionStage will be failed with the streams exception.
See also headOption.
public static <In> Sink<In,java.util.concurrent.CompletionStage<java.util.Optional<In>>> headOption()
Sink that materializes into a CompletionStage of the optional first value received.
If the stream completes before signaling at least a single element, the value of the CompletionStage will be an empty Optional.
If the stream signals an error errors before signaling at least a single element, the CompletionStage will be failed with the streams exception.
See also head.
public static <In> Sink<In,java.util.concurrent.CompletionStage<In>> last()
Sink that materializes into a CompletionStage of the last value received.
If the stream completes before signaling at least a single element, the CompletionStage will be failed with a NoSuchElementException.
If the stream signals an error errors before signaling at least a single element, the CompletionStage will be failed with the streams exception.
See also lastOption.
public static <In> Sink<In,java.util.concurrent.CompletionStage<java.util.Optional<In>>> lastOption()
Sink that materializes into a CompletionStage of the optional last value received.
If the stream completes before signaling at least a single element, the value of the CompletionStage will be an empty Optional.
If the stream signals an error errors before signaling at least a single element, the CompletionStage will be failed with the streams exception.
See also head.
public static <In> Sink<In,java.util.concurrent.CompletionStage<java.util.List<In>>> seq()
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 CompletionStage of Seq[T] containing all the collected elements.
List is limited to Integer.MAX_VALUE elements, this Sink will cancel the stream
after having received that many elements.
See also Flow.limit, Flow.limitWeighted, Flow.take, Flow.takeWithin, Flow.takeWhile
public static <In> Sink<In,NotUsed> actorRef(ActorRef ref, java.lang.Object onCompleteMessage)
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 stage in front of this Sink.
ref - (undocumented)onCompleteMessage - (undocumented)public static <In> Sink<In,NotUsed> actorRefWithAck(ActorRef ref, java.lang.Object onInitMessage, java.lang.Object ackMessage, java.lang.Object onCompleteMessage, Function<java.lang.Throwable,java.lang.Object> onFailureMessage)
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)
message will be sent to the destination actor.
ref - (undocumented)onInitMessage - (undocumented)ackMessage - (undocumented)onCompleteMessage - (undocumented)onFailureMessage - (undocumented)public static <T> Sink<T,ActorRef> actorSubscriber(Props props)
Sink that is materialized to an ActorRef which points to an Actor
created according to the passed in Props. Actor created by the props should
be ActorSubscriber.props - (undocumented)public static <T,M> Sink<T,M> fromGraph(Graph<SinkShape<T>,M> g)
g - (undocumented)public static <T,U> Sink<T,NotUsed> combine(Sink<U,?> output1, Sink<U,?> output2, java.util.List<Sink<U,?>> rest, Function<java.lang.Integer,Graph<UniformFanOutShape<T,U>,NotUsed>> strategy)
Broadcast or Balance and returns Sink.output1 - (undocumented)output2 - (undocumented)rest - (undocumented)strategy - (undocumented)public static <T> Sink<T,SinkQueueWithCancel<T>> queue()
Sink that is materialized as an SinkQueue.
akka.stream.javadsl.SinkQueue.pull method is pulling element from the stream and returns CompletionStage[Option[T}.
CompletionStage completes when element is available.
Before calling pull method second time you need to wait until previous CompletionStage completes. Pull returns Failed future with ''IllegalStateException'' if previous future has not yet completed.
Sink will request at most number of elements equal to size 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
SinkQueueWithCancelpublic static <T,M> Sink<T,java.util.concurrent.CompletionStage<M>> lazyInit(Function<T,java.util.concurrent.CompletionStage<Sink<T,M>>> sinkFactory, Creator<M> fallback)
Sink upon receiving the first element. Internal Sink will not be created if there are no elements,
because of completion or error.
If sinkFactory throws an exception and the supervision decision is
akka.stream.Supervision.Stop the Future will be completed with failure. For all other supervision options it will
try to create sink with next element
fallback will be executed when there was no elements and completed is received from upstream.
sinkFactory - (undocumented)fallback - (undocumented)public SinkShape<In> shape()
Graphpublic StreamLayout.Module module()
GraphEvery materializable element must be backed by a stream layout module
public java.lang.String toString()
toString in class java.lang.Objectpublic Sink<In,Mat> asScala()
public <M> M runWith(Graph<SourceShape<In>,M> source, Materializer materializer)
Sink to a Source and run it.source - (undocumented)materializer - (undocumented)public <In2> Sink<In2,Mat> contramap(Function<In2,In> f)
Sink
'''Backpressures when''' original Sink backpressures
'''Cancels when''' original Sink backpressures
f - (undocumented)public <Mat2> Sink<In,Mat2> mapMaterializedValue(Function<Mat,Mat2> f)
f - (undocumented)public Sink<In,Mat> withAttributes(Attributes attr)
Sink to the given ones and seal the list
of attributes. This means that further calls will not be able to remove these
attributes, but instead add new ones. Note that this
operation has no effect on an empty Flow (because the attributes apply
only to the contained processing stages).withAttributes in interface Graph<SinkShape<In>,Mat>attr - (undocumented)public Sink<In,Mat> addAttributes(Attributes attr)
withAttributes
will not remove these attributes. Note that this
operation has no effect on an empty Flow (because the attributes apply
only to the contained processing stages).addAttributes in interface Graph<SinkShape<In>,Mat>attr - (undocumented)