Class SdkAdvancedAsyncClientOption<T>

    • Field Detail

      • FUTURE_COMPLETION_EXECUTOR

        public static final SdkAdvancedAsyncClientOption<Executor> FUTURE_COMPLETION_EXECUTOR
        Configure the Executor that should be used to complete the CompletableFuture that is returned by the async service client. By default, this is a dedicated, per-client ThreadPoolExecutor that is managed by the SDK.

        The configured Executor will be invoked by the async HTTP client's I/O threads (e.g., EventLoops), which must be reserved for non-blocking behavior. Blocking an I/O thread can cause severe performance degradation, including across multiple clients, as clients are configured, by default, to share a single I/O thread pool (e.g., EventLoopGroup).

        You should typically only want to customize the future-completion Executor for a few possible reasons:

        1. You want more fine-grained control over the ThreadPoolExecutor used, such as configuring the pool size or sharing a single pool between multiple clients.
        2. You want to add instrumentation (i.e., metrics) around how the Executor is used.
        WARNING

        We strongly discourage using Runnable::run, which executes the future-completion directly from within the I/O thread because it may block the I/O thread and cause deadlock, especially if you are sending another SDK request in the CompletableFuture chain since the SDK may perform blocking calls in some cases.