public class LimitRateInterceptor extends Object implements RSocketInterceptor
Flux.limitRate(int, int)
to publishers of outbound streams that
breaks down or aggregates demand values from the remote end (i.e. REQUEST_N
frames) into
batches of a uniform size. For example the remote may request Long.MAXVALUE
or it may
start requesting one at a time, in both cases with the limit set to 64, the publisher will see a
demand of 64 to start and subsequent batches of 48, i.e. continuing to prefetch and refill an
internal queue when it falls to 75% full. The high and low tide marks are configurable.
See static factory methods to create an instance for a requester or for a responder.
Note: keep in mind that the limitRate
operator always uses requests
the same request values, even if the remote requests less than the limit. For example given a
limit of 64, if the remote requests 4, 64 will be prefetched of which 4 will be sent and 60 will
be cached.
Modifier and Type | Method and Description |
---|---|
RSocket |
apply(RSocket socket) |
static LimitRateInterceptor |
forRequester(int prefetchRate)
Create an interceptor for an
RSocket that performs request-channel interactions. |
static LimitRateInterceptor |
forRequester(int highTide,
int lowTide)
Create an interceptor for an
RSocket that performs request-channel interactions with
more control over the overall prefetch rate and replenish threshold. |
static LimitRateInterceptor |
forResponder(int prefetchRate)
Create an interceptor for an
RSocket that handles request-stream and/or request-channel
interactions. |
static LimitRateInterceptor |
forResponder(int highTide,
int lowTide)
Create an interceptor for an
RSocket that handles request-stream and/or request-channel
interactions with more control over the overall prefetch rate and replenish threshold. |
public static LimitRateInterceptor forResponder(int prefetchRate)
RSocket
that handles request-stream and/or request-channel
interactions.prefetchRate
- the prefetch rate to pass to Flux.limitRate(int)
public static LimitRateInterceptor forResponder(int highTide, int lowTide)
RSocket
that handles request-stream and/or request-channel
interactions with more control over the overall prefetch rate and replenish threshold.highTide
- the high tide value to pass to Flux.limitRate(int, int)
lowTide
- the low tide value to pass to Flux.limitRate(int, int)
public static LimitRateInterceptor forRequester(int prefetchRate)
RSocket
that performs request-channel interactions.prefetchRate
- the prefetch rate to pass to Flux.limitRate(int)
public static LimitRateInterceptor forRequester(int highTide, int lowTide)
RSocket
that performs request-channel interactions with
more control over the overall prefetch rate and replenish threshold.highTide
- the high tide value to pass to Flux.limitRate(int, int)
lowTide
- the low tide value to pass to Flux.limitRate(int, int)