Package discord4j.common
Class ReactorResources
java.lang.Object
discord4j.common.ReactorResources
Provides Reactor Netty resources like an
HttpClient and Scheduler instances that can be customized
and reused across the application.
Allow a user to externally manage the connection pool through a custom ConnectionProvider, and custom
event loop threads using a LoopResources.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionCreate with a defaultHttpClientandSchedulers for timed and blocking tasks.protectedReactorResources(ReactorResources.Builder builder) ReactorResources(HttpClient httpClient, Scheduler timerTaskScheduler, Scheduler blockingTaskScheduler) Create with a pre-configuredHttpClientandSchedulers for timed and blocking tasks. -
Method Summary
Modifier and TypeMethodDescriptionstatic ReactorResources.Builderbuilder()static ReactorResourcescreate()Get theSchedulerconfigured by this provider to be used in blocking tasks.Get theHttpClientconfigured by this provider.Get theSchedulerconfigured by this provider to be used in timed tasks.static HttpClientnewHttpClient(ConnectionProvider provider) Create a Reactor NettyHttpClientusing the given connection pool.static HttpClientnewHttpClient(ConnectionProvider provider, LoopResources resources) Create a Reactor NettyHttpClientusing the given connection pool and event loop threads.
-
Field Details
-
DEFAULT_HTTP_CLIENT
-
DEFAULT_TIMER_TASK_SCHEDULER
-
DEFAULT_BLOCKING_TASK_SCHEDULER
-
-
Constructor Details
-
ReactorResources
public ReactorResources()Create with a defaultHttpClientandSchedulers for timed and blocking tasks. -
ReactorResources
public ReactorResources(HttpClient httpClient, Scheduler timerTaskScheduler, Scheduler blockingTaskScheduler) Create with a pre-configuredHttpClientandSchedulers for timed and blocking tasks.- Parameters:
httpClient- the underlyingHttpClientto usetimerTaskScheduler- the time-capableSchedulerto useblockingTaskScheduler- theSchedulerto use for potentially blocking tasks
-
ReactorResources
-
-
Method Details
-
create
-
builder
-
getHttpClient
Get theHttpClientconfigured by this provider.- Returns:
- a Reactor Netty HTTP client ready to perform requests
-
getTimerTaskScheduler
Get theSchedulerconfigured by this provider to be used in timed tasks.- Returns:
- a time-capable
Scheduler
-
getBlockingTaskScheduler
Get theSchedulerconfigured by this provider to be used in blocking tasks.- Returns:
- a blocking-capable
Scheduler
-
newHttpClient
Create a Reactor NettyHttpClientusing the given connection pool.Use this in case you want dedicated resources for a particular client or clients instead of the global default.
- Parameters:
provider- the connection pool provider to use- Returns:
- an
HttpClientconfigured with custom resources
-
newHttpClient
Create a Reactor NettyHttpClientusing the given connection pool and event loop threads.Use this in case you want dedicated resources for a particular client or clients instead of the global default.
- Parameters:
provider- the connection pool provider to useresources- the set of event loop threads to use- Returns:
- an
HttpClientconfigured with custom resources
-