Skip to content

Commit

Permalink
Merge 29d2e3b into 3.4.6
Browse files Browse the repository at this point in the history
  • Loading branch information
simonbasle committed May 6, 2021
2 parents 3b45ed8 + 29d2e3b commit f383f4d
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions reactor-core/src/main/java/reactor/core/publisher/Flux.java
Original file line number Diff line number Diff line change
Expand Up @@ -5895,7 +5895,12 @@ public final Flux<T> limitRate(int highTide, int lowTide) {
}

/**
* Ensure that the total amount requested upstream is capped at {@code cap}.
* Take only the first N values from this {@link Flux}, if available.
* Furthermore, ensure that the total amount requested upstream is capped at {@code n}.
* If n is zero, the source isn't even subscribed to and the operator completes immediately
* upon subscription.
* <img class="marble" src="doc-files/marbles/limitRequest.svg" alt="">
* <p>
* Backpressure signals from downstream subscribers are smaller than the cap are
* propagated as is, but if they would cause the total requested amount to go over the
* cap, they are reduced to the minimum value that doesn't go over.
Expand All @@ -5905,17 +5910,15 @@ public final Flux<T> limitRate(int highTide, int lowTide) {
* for cases where a race between request and cancellation can lead the upstream to
* producing a lot of extraneous data, and such a production is undesirable (e.g.
* a source that would send the extraneous data over the network).
* <p>
* <img class="marble" src="doc-files/marbles/limitRequest.svg" alt="">
*
* @param requestCap the global backpressure limit to apply to the sum of downstream's requests
* @param n the number of elements to emit from this flux, which is also the backpressure
* cap for all of downstream's request
*
* @return a {@link Flux} that requests AT MOST {@code cap} from upstream in total.
* @see #limitRate(int)
* @return a {@link Flux} of {@code n} elements from the source, that requests AT MOST {@code n} from upstream in total.
* @see #take(long)
*/
public final Flux<T> limitRequest(long requestCap) {
return onAssembly(new FluxLimitRequest<>(this, requestCap));
public final Flux<T> limitRequest(long n) {
return onAssembly(new FluxLimitRequest<>(this, n));
}

/**
Expand Down

0 comments on commit f383f4d

Please sign in to comment.