Top Description Inners Fields Constructors Methods
io.rsocket.plugins

public Class LimitRateInterceptor

extends Object
implements RSocketInterceptor
Class Inheritance
All Implemented Interfaces
io.rsocket.plugins.RSocketInterceptor, java.util.function.Function
Imports
io.rsocket.Payload, .RSocket, io.rsocket.util.RSocketProxy, org.reactivestreams.Publisher, reactor.core.publisher.Flux

Interceptor that adds 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.

Since
1.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
LimitRateInterceptor.RequesterProxy

Requester side proxy, limits channel request stream.

private class
LimitRateInterceptor.ResponderProxy

Responder side proxy, limits response streams.

Field Summary

Modifier and TypeField and Description
private final int
private final int
private final boolean

Constructor Summary

AccessConstructor and Description
private
LimitRateInterceptor(int highTide, int lowTide, boolean requesterProxy)

Method Summary

Modifier and TypeMethod and Description
public RSocket
apply(RSocket
the function argument
socket
)

Implements java.util.function.Function.apply.

Applies this function to the given argument.
public static LimitRateInterceptor

Returns:

the created interceptor
forRequester
(int
the prefetch rate to pass to Flux#limitRate(int)
prefetchRate
)

Create an interceptor for an RSocket that performs request-channel interactions.

public static LimitRateInterceptor

Returns:

the created interceptor
forRequester
(int
the high tide value to pass to Flux#limitRate(int, int)
highTide
,
int
the low tide value to pass to Flux#limitRate(int, int)
lowTide
)

Create an interceptor for an RSocket that performs request-channel interactions with more control over the overall prefetch rate and replenish threshold.

public static LimitRateInterceptor

Returns:

the created interceptor
forResponder
(int
the prefetch rate to pass to Flux#limitRate(int)
prefetchRate
)

Create an interceptor for an RSocket that handles request-stream and/or request-channel interactions.

public static LimitRateInterceptor

Returns:

the created interceptor
forResponder
(int
the high tide value to pass to Flux#limitRate(int, int)
highTide
,
int
the low tide value to pass to Flux#limitRate(int, 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.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

highTideback to summary
private final int highTide
lowTideback to summary
private final int lowTide
requesterProxyback to summary
private final boolean requesterProxy

Constructor Detail

LimitRateInterceptorback to summary
private LimitRateInterceptor(int highTide, int lowTide, boolean requesterProxy)

Method Detail

applyback to summary
public RSocket apply(RSocket socket)

Implements java.util.function.Function.apply.

Doc from java.util.function.Function.apply.

Applies this function to the given argument.

Parameters
socket:RSocket

the function argument

Returns:RSocket

the function result

Annotations
@Override
forRequesterback to summary
public static LimitRateInterceptor forRequester(int prefetchRate)

Create an interceptor for an RSocket that performs request-channel interactions.

Parameters
prefetchRate:int

the prefetch rate to pass to Flux#limitRate(int)

Returns:LimitRateInterceptor

the created interceptor

forRequesterback to summary
public 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.

Parameters
highTide:int

the high tide value to pass to Flux#limitRate(int, int)

lowTide:int

the low tide value to pass to Flux#limitRate(int, int)

Returns:LimitRateInterceptor

the created interceptor

forResponderback to summary
public static LimitRateInterceptor forResponder(int prefetchRate)

Create an interceptor for an RSocket that handles request-stream and/or request-channel interactions.

Parameters
prefetchRate:int

the prefetch rate to pass to Flux#limitRate(int)

Returns:LimitRateInterceptor

the created interceptor

forResponderback to summary
public 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.

Parameters
highTide:int

the high tide value to pass to Flux#limitRate(int, int)

lowTide:int

the low tide value to pass to Flux#limitRate(int, int)

Returns:LimitRateInterceptor

the created interceptor

io.rsocket.plugins back to summary

private Class LimitRateInterceptor.RequesterProxy

extends RSocketProxy
Class Inheritance

Requester side proxy, limits channel request stream.

Field Summary

Inherited from io.rsocket.util.RSocketProxy:
source

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public Flux<Payload>
requestChannel(Publisher<Payload>
Stream of request payloads.
payloads
)

Overrides io.rsocket.util.RSocketProxy.requestChannel.

Overrides default io.rsocket.RSocket.requestChannel.

Request-Channel interaction model of RSocket.
Inherited from io.rsocket.util.RSocketProxy:
availabilitydisposefireAndForgetisDisposedmetadataPushonCloserequestResponserequestStream

Constructor Detail

RequesterProxyback to summary
pack-priv RequesterProxy(RSocket source)

Method Detail

requestChannelback to summary
public Flux<Payload> requestChannel(Publisher<Payload> payloads)

Overrides io.rsocket.util.RSocketProxy.requestChannel.

Overrides default io.rsocket.RSocket.requestChannel.

Doc from io.rsocket.RSocket.requestChannel.

Request-Channel interaction model of RSocket.

Parameters
payloads:Publisher<Payload>

Stream of request payloads.

Returns:Flux<Payload>

Stream of response payloads.

Annotations
@Override
io.rsocket.plugins back to summary

private Class LimitRateInterceptor.ResponderProxy

extends RSocketProxy
Class Inheritance

Responder side proxy, limits response streams.

Field Summary

Inherited from io.rsocket.util.RSocketProxy:
source

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public Flux<Payload>
requestChannel(Publisher<Payload>
Stream of request payloads.
payloads
)

Overrides io.rsocket.util.RSocketProxy.requestChannel.

Overrides default io.rsocket.RSocket.requestChannel.

Request-Channel interaction model of RSocket.
public Flux<Payload>
requestStream(Payload
Request payload.
payload
)

Overrides io.rsocket.util.RSocketProxy.requestStream.

Overrides default io.rsocket.RSocket.requestStream.

Request-Stream interaction model of RSocket.
Inherited from io.rsocket.util.RSocketProxy:
availabilitydisposefireAndForgetisDisposedmetadataPushonCloserequestResponse

Constructor Detail

ResponderProxyback to summary
pack-priv ResponderProxy(RSocket source)

Method Detail

requestChannelback to summary
public Flux<Payload> requestChannel(Publisher<Payload> payloads)

Overrides io.rsocket.util.RSocketProxy.requestChannel.

Overrides default io.rsocket.RSocket.requestChannel.

Doc from io.rsocket.RSocket.requestChannel.

Request-Channel interaction model of RSocket.

Parameters
payloads:Publisher<Payload>

Stream of request payloads.

Returns:Flux<Payload>

Stream of response payloads.

Annotations
@Override
requestStreamback to summary
public Flux<Payload> requestStream(Payload payload)

Overrides io.rsocket.util.RSocketProxy.requestStream.

Overrides default io.rsocket.RSocket.requestStream.

Doc from io.rsocket.RSocket.requestStream.

Request-Stream interaction model of RSocket.

Parameters
payload:Payload

Request payload.

Returns:Flux<Payload>

Publisher containing the stream of Payloads representing the response.

Annotations
@Override