Class HttpConnectionPools

java.lang.Object
ai.redouble.nucleo.http.HttpConnectionPools

public class HttpConnectionPools extends Object
Shared HTTP connection pool for all API calls.

Single pool serves all workloads (LLM, embeddings, general HTTP). Apache HttpClient's internal connection pooling handles concurrency. The pool holds HttpSettings.poolSize connections, as the total and as the per-route maximum alike. Its timeouts: 30 seconds to open a connection, 15 minutes for a response and for socket reads, 60 minutes to obtain a connection from the pool when every one is leased. A connection idle for more than 5 seconds is validated before reuse; one idle for 5 minutes is evicted.

Usage: Just call getClient() from anywhere that needs HTTP.

Since:
0.1 (2025-01-10)
Author:
Andrey Santrosyan
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    How long a connection may take to open; SDK transports a provider builds itself use the same.
    static final int
    How long a response may take to arrive: a model call writing a long answer is silent until it is done, so this is the window of the longest call, and SDK transports a provider builds itself use the same rather than their own shorter defaults.
  • Method Summary

    Modifier and Type
    Method
    Description
    The admission account a job's demand names when it makes HTTP calls: one permit per admitted job, sized to this pool, so the pool is never the narrower door.
    org.apache.hc.client5.http.impl.classic.CloseableHttpClient
    Gets the shared HTTP client.
     
    org.apache.hc.core5.pool.PoolStats
    Gets current pool statistics.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • CONNECT_TIMEOUT_SECONDS

      public static final int CONNECT_TIMEOUT_SECONDS
      How long a connection may take to open; SDK transports a provider builds itself use the same.
      See Also:
    • RESPONSE_TIMEOUT_MINUTES

      public static final int RESPONSE_TIMEOUT_MINUTES
      How long a response may take to arrive: a model call writing a long answer is silent until it is done, so this is the window of the longest call, and SDK transports a provider builds itself use the same rather than their own shorter defaults.
      See Also:
  • Method Details

    • getInstance

      public static HttpConnectionPools getInstance()
    • getClient

      public org.apache.hc.client5.http.impl.classic.CloseableHttpClient getClient()
      Gets the shared HTTP client.
    • gate

      public HttpConnectionGate gate()
      The admission account a job's demand names when it makes HTTP calls: one permit per admitted job, sized to this pool, so the pool is never the narrower door.
    • getStats

      public org.apache.hc.core5.pool.PoolStats getStats()
      Gets current pool statistics.