public class HttpClientFactory extends Object
HttpExporterConfig.
Exporters with equal configurations (per HttpExporterConfig.hashCode()/
HttpExporterConfig.equals(Object)) share a single underlying HTTP client,
preventing native thread leaks from redundant Netty event loops.
The cache uses reference counting: the first acquire(io.confluent.telemetry.events.exporter.http.HttpExporterConfig, java.util.function.Supplier<T>) for a given config
creates the resource via the supplied factory; subsequent acquires increment the count
and return the same resource. release(io.confluent.telemetry.events.exporter.http.HttpExporterConfig) decrements the count and signals the
caller to close the resource when the last reference is released.
| Modifier and Type | Method and Description |
|---|---|
<T> T |
acquire(HttpExporterConfig config,
Supplier<T> factory)
Acquire a shared resource for the given config.
|
static HttpClientFactory |
getInstance() |
boolean |
release(HttpExporterConfig config)
Release a reference to the shared resource for the given config.
|
public static HttpClientFactory getInstance()
public <T> T acquire(HttpExporterConfig config, Supplier<T> factory)
config - the exporter config used as the cache keyfactory - supplier to create the resource if none exists for this configpublic boolean release(HttpExporterConfig config)
true if this was the last reference and the caller should close the resource;
false if other references remain or if the config is not tracked