Class ReactorResources


  • public class ReactorResources
    extends Object
    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.

    • Field Detail

      • DEFAULT_TIMER_TASK_SCHEDULER

        public static final Supplier<Scheduler> DEFAULT_TIMER_TASK_SCHEDULER
      • DEFAULT_BLOCKING_TASK_SCHEDULER

        public static final Supplier<Scheduler> DEFAULT_BLOCKING_TASK_SCHEDULER
    • Constructor Detail

      • ReactorResources

        public ReactorResources()
        Create with a default HttpClient and Schedulers for timed and blocking tasks.
      • ReactorResources

        public ReactorResources​(HttpClient httpClient,
                                Scheduler timerTaskScheduler,
                                Scheduler blockingTaskScheduler)
        Create with a pre-configured HttpClient and Schedulers for timed and blocking tasks.
        Parameters:
        httpClient - the underlying HttpClient to use
        timerTaskScheduler - the time-capable Scheduler to use
        blockingTaskScheduler - the Scheduler to use for potentially blocking tasks
    • Method Detail

      • getHttpClient

        public HttpClient getHttpClient()
        Get the HttpClient configured by this provider.
        Returns:
        a Reactor Netty HTTP client ready to perform requests
      • getTimerTaskScheduler

        public Scheduler getTimerTaskScheduler()
        Get the Scheduler configured by this provider to be used in timed tasks.
        Returns:
        a time-capable Scheduler
      • getBlockingTaskScheduler

        public Scheduler getBlockingTaskScheduler()
        Get the Scheduler configured by this provider to be used in blocking tasks.
        Returns:
        a blocking-capable Scheduler
      • newHttpClient

        public static HttpClient newHttpClient​(ConnectionProvider provider,
                                               LoopResources resources)
        Create a Reactor Netty HttpClient using 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. Requires externally disposing of the given parameters on application shutdown, through ConnectionProvider.dispose() and LoopResources.dispose().

        Parameters:
        provider - the connection pool provider to use
        resources - the set of event loop threads to use
        Returns:
        an HttpClient configured with custom resources