Extrapolate stage and expand redoc #23804
This commit is contained in:
parent
26f0f86088
commit
00068e2d1d
13 changed files with 670 additions and 82 deletions
|
|
@ -1103,7 +1103,7 @@ class SubSource[Out, Mat](delegate: scaladsl.SubFlow[Out, Mat, scaladsl.Source[O
|
|||
new SubSource(delegate.batchWeighted(max, costFn.apply, seed.apply)(aggregate.apply))
|
||||
|
||||
/**
|
||||
* Allows a faster downstream to progress independently of a slower publisher by extrapolating elements from an older
|
||||
* Allows a faster downstream to progress independently of a slower upstream by extrapolating elements from an older
|
||||
* element until new element comes from the upstream. For example an expand step might repeat the last element for
|
||||
* the subscriber until it receives an update from upstream.
|
||||
*
|
||||
|
|
@ -1112,7 +1112,9 @@ class SubSource[Out, Mat](delegate: scaladsl.SubFlow[Out, Mat, scaladsl.Source[O
|
|||
* subscriber.
|
||||
*
|
||||
* Expand does not support [[akka.stream.Supervision#restart]] and [[akka.stream.Supervision#resume]].
|
||||
* Exceptions from the `seed` or `extrapolate` functions will complete the stream with failure.
|
||||
* Exceptions from the `expander` function will complete the stream with failure.
|
||||
*
|
||||
* See also [[#extrapolate]] for a version that always preserves the original element and allows for an initial "startup" element.
|
||||
*
|
||||
* '''Emits when''' downstream stops backpressuring
|
||||
*
|
||||
|
|
@ -1122,11 +1124,67 @@ class SubSource[Out, Mat](delegate: scaladsl.SubFlow[Out, Mat, scaladsl.Source[O
|
|||
*
|
||||
* '''Cancels when''' downstream cancels
|
||||
*
|
||||
* @param extrapolate Takes the current extrapolation state to produce an output element and the next extrapolation
|
||||
* state.
|
||||
* @param expander Takes the current extrapolation state to produce an output element and the next extrapolation
|
||||
* state.
|
||||
* @see [[#extrapolate]]
|
||||
*/
|
||||
def expand[U](extrapolate: function.Function[Out, java.util.Iterator[U]]): SubSource[U, Mat] =
|
||||
new SubSource(delegate.expand(in ⇒ extrapolate(in).asScala))
|
||||
def expand[U](expander: function.Function[Out, java.util.Iterator[U]]): SubSource[U, Mat] =
|
||||
new SubSource(delegate.expand(in ⇒ expander(in).asScala))
|
||||
|
||||
/**
|
||||
* Allows a faster downstream to progress independent of a slower upstream.
|
||||
*
|
||||
* This is achieved by introducing "extrapolated" elements - based on those from upstream - whenever downstream
|
||||
* signals demand.
|
||||
*
|
||||
* Extrapolate does not support [[akka.stream.Supervision#restart]] and [[akka.stream.Supervision#resume]].
|
||||
* Exceptions from the `extrapolate` function will complete the stream with failure.
|
||||
*
|
||||
* See also [[#expand]] for a version that can overwrite the original element.
|
||||
*
|
||||
* '''Emits when''' downstream stops backpressuring, AND EITHER upstream emits OR initial element is present OR
|
||||
* `extrapolate` is non-empty and applicable
|
||||
*
|
||||
* '''Backpressures when''' downstream backpressures or current `extrapolate` runs empty
|
||||
*
|
||||
* '''Completes when''' upstream completes and current `extrapolate` runs empty
|
||||
*
|
||||
* '''Cancels when''' downstream cancels
|
||||
*
|
||||
* @param extrapolator takes the current upstream element and provides a sequence of "extrapolated" elements based
|
||||
* on the original, to be emitted in case downstream signals demand.
|
||||
* @see [[#expand]]
|
||||
*/
|
||||
def extrapolate(extrapolator: function.Function[Out @uncheckedVariance, java.util.Iterator[Out @uncheckedVariance]]): SubSource[Out, Mat] =
|
||||
new SubSource(delegate.extrapolate(in ⇒ extrapolator(in).asScala))
|
||||
|
||||
/**
|
||||
* Allows a faster downstream to progress independent of a slower upstream.
|
||||
*
|
||||
* This is achieved by introducing "extrapolated" elements - based on those from upstream - whenever downstream
|
||||
* signals demand.
|
||||
*
|
||||
* Extrapolate does not support [[akka.stream.Supervision#restart]] and [[akka.stream.Supervision#resume]].
|
||||
* Exceptions from the `extrapolate` function will complete the stream with failure.
|
||||
*
|
||||
* See also [[#expand]] for a version that can overwrite the original element.
|
||||
*
|
||||
* '''Emits when''' downstream stops backpressuring, AND EITHER upstream emits OR initial element is present OR
|
||||
* `extrapolate` is non-empty and applicable
|
||||
*
|
||||
* '''Backpressures when''' downstream backpressures or current `extrapolate` runs empty
|
||||
*
|
||||
* '''Completes when''' upstream completes and current `extrapolate` runs empty
|
||||
*
|
||||
* '''Cancels when''' downstream cancels
|
||||
*
|
||||
* @param extrapolator takes the current upstream element and provides a sequence of "extrapolated" elements based
|
||||
* on the original, to be emitted in case downstream signals demand.
|
||||
* @param initial the initial element to be emitted, in case upstream is able to stall the entire stream.
|
||||
* @see [[#expand]]
|
||||
*/
|
||||
def extrapolate(extrapolator: function.Function[Out @uncheckedVariance, java.util.Iterator[Out @uncheckedVariance]], initial: Out @uncheckedVariance): SubSource[Out, Mat] =
|
||||
new SubSource(delegate.extrapolate(in ⇒ extrapolator(in).asScala, Some(initial)))
|
||||
|
||||
/**
|
||||
* Adds a fixed size buffer in the flow that allows to store elements from a faster upstream until it becomes full.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue