public static class RouterOptions.Builder extends Object
RouterOptions.| Modifier | Constructor and Description |
|---|---|
protected |
Builder() |
| Modifier and Type | Method and Description |
|---|---|
RouterOptions |
build()
Creates the
RouterOptions object. |
RouterOptions.Builder |
globalRateLimiter(GlobalRateLimiter globalRateLimiter)
Define the
GlobalRateLimiter to be applied while configuring the Router for a client. |
RouterOptions.Builder |
onClientResponse(ResponseFunction errorHandler)
Sets a new API response behavior to the supporting
Router, allowing cross-cutting behavior across
all requests made by it. |
RouterOptions.Builder |
rateLimitScheduler(Scheduler rateLimitScheduler)
Sets the
Scheduler used to handle delays introduced by rate limiting. |
RouterOptions.Builder |
requestParallelism(int requestParallelism)
Define the level of parallel requests the configured
Router should be allowed to make. |
RouterOptions.Builder |
responseScheduler(Scheduler responseScheduler)
Sets the
Scheduler used to process API responses. |
public RouterOptions.Builder responseScheduler(Scheduler responseScheduler)
Scheduler used to process API responses. Defaults to Schedulers.elastic().responseScheduler - the Scheduler used to process responsespublic RouterOptions.Builder rateLimitScheduler(Scheduler rateLimitScheduler)
Scheduler used to handle delays introduced by rate limiting. Defaults to
Schedulers.elastic().rateLimitScheduler - the Scheduler used to handle rate limiting@Experimental public RouterOptions.Builder onClientResponse(ResponseFunction errorHandler)
Router, allowing cross-cutting behavior across
all requests made by it.
The given ResponseFunction will be applied after every response. Calling this function multiple
times will result in additive behavior, so care must be taken regarding the order in
which multiple calls occur. Transformations will be added to the response pipeline in that order.
Built-in factories are supplied for commonly used behavior:
ResponseFunction.emptyIfNotFound() transforms any HTTP 404 error into an empty sequence.ResponseFunction.emptyIfNotFound(RouteMatcher) transforms HTTP 404 errors from the given
Routes into an empty sequence.ResponseFunction.emptyOnErrorStatus(RouteMatcher, Integer...) provides the same behavior as
above but for any given status codes.ResponseFunction.retryOnceOnErrorStatus(Integer...) retries once for the given status codes.ResponseFunction.retryOnceOnErrorStatus(RouteMatcher, Integer...) provides the same behavior
as above but for any matching Route.errorHandler - the ResponseFunction to transform the responses from matching requests.public RouterOptions.Builder requestParallelism(int requestParallelism)
Router should be allowed to make. In-flight
requests beyond the parallelism value will wait until a permit is released.
Modifying this value can increase the API request throughput at the cost of potentially hitting the global
rate limit. Defaults to RouterOptions.DEFAULT_REQUEST_PARALLELISM.
requestParallelism - the number of parallel requests allowedpublic RouterOptions.Builder globalRateLimiter(GlobalRateLimiter globalRateLimiter)
GlobalRateLimiter to be applied while configuring the Router for a client.
GlobalRateLimiter purpose is to coordinate API requests to properly delay them under global rate
limiting scenarios. RouterFactory is responsible for applying the given implementation when building
the Router.
Setting a limiter here will override any value set on requestParallelism(int).
globalRateLimiter - the limiter instance to be used while configuring a Router, if supported by
the used RouterFactoryGlobalRateLimiterpublic RouterOptions build()
RouterOptions object.RouterOptions