public class DefaultRouter extends Object implements Router
DiscordRequests
to the proper
RequestStream
according to the bucket in which the request falls.
Must be cached using SingleRouterFactory
if intended for sharding, to properly
coordinate queueing and rate-limiting across buckets.
Constructor and Description |
---|
DefaultRouter(DiscordWebClient httpClient)
Create a bucket-aware router using the
Schedulers.elastic() scheduler, to allow
the use of blocking API. |
DefaultRouter(DiscordWebClient httpClient,
Scheduler responseScheduler,
Scheduler rateLimitScheduler)
Create a bucket-aware router that uses the given
Scheduler . |
Modifier and Type | Method and Description |
---|---|
<T> Mono<T> |
exchange(DiscordRequest<T> request)
Queues a request for execution.
|
public DefaultRouter(DiscordWebClient httpClient)
Schedulers.elastic()
scheduler, to allow
the use of blocking API. Use the alternate constructor to customize it.httpClient
- the web client executing each request instructed by this routerpublic DefaultRouter(DiscordWebClient httpClient, Scheduler responseScheduler, Scheduler rateLimitScheduler)
Scheduler
.httpClient
- the web client executing each request instructed by this routerresponseScheduler
- the scheduler used to execute each requestrateLimitScheduler
- the scheduler used to perform delays caused by rate limitingpublic <T> Mono<T> exchange(DiscordRequest<T> request)
Router