Class HttpClientFactory
java.lang.Object
com.google.adk.internal.http.HttpClientFactory
Creates
OkHttpClients for the ADK. The default clients are cached per name so the
dispatcher and connection pool are reused across the ADK; a caller that supplies its own executor
gets a fresh, non-cached client it owns.-
Method Summary
Modifier and TypeMethodDescriptionstatic okhttp3.OkHttpClientcreateHttpClient(ExecutorService executorService) Returns a newOkHttpClientwhose dispatcher runs onexecutorService.static ExecutorServicedaemonExecutor(String name) Returns an unbounded pool of daemon threads, matching OkHttp's own dispatcher pool but with daemon threads so a standalone JVM can exit once work is done.static okhttp3.OkHttpClientReturns the sharedOkHttpClientcached byname, using OkHttp's default threading.
-
Method Details
-
createHttpClient
Returns a newOkHttpClientwhose dispatcher runs onexecutorService. PassdaemonExecutor(String)so a standalone JVM can exit once work is done, or a container-managed executor in a managed environment. The client is not cached: the caller owns the executor and the returned client.- Parameters:
executorService- executor for the dispatcher.
-
daemonExecutor
Returns an unbounded pool of daemon threads, matching OkHttp's own dispatcher pool but with daemon threads so a standalone JVM can exit once work is done. Managed container environments should inject their own executor instead of calling this.- Parameters:
name- prefix for the dispatcher thread names.