Class HttpClientPool
java.lang.Object
com.github.nhenneaux.resilienthttpclient.monitoredclientpool.HttpClientPool
- All Implemented Interfaces:
AutoCloseable
A HTTP clients pool which keeps internally a round robin list of HTTP clients.
Each HTTP client represents a connection to the acquirer using a distinct IP address, taken from endpoint resolving.
The number of distinct HTTP clients in this connection pool is equal to the number of different IP addresses for the given acquirer hostname.
Each HTTP client represents a connection to the acquirer using a distinct IP address, taken from endpoint resolving.
The number of distinct HTTP clients in this connection pool is equal to the number of different IP addresses for the given acquirer hostname.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedHttpClientPool(DnsLookupWrapper dnsLookupWrapper, ScheduledExecutorService scheduledExecutorService, ServerConfiguration serverConfiguration, Function<InetAddress, HttpClient> singleHttpClientProvider) -
Method Summary
Modifier and TypeMethodDescriptionstatic HttpClientPoolBuilderbuilder(ServerConfiguration serverConfiguration) check()Returns statusHealthCheckResult.HealthStatus.OKif all httpClientsCache are healthy.
Returns statusHealthCheckResult.HealthStatus.ERRORif all httpClientsCache are unhealthy.
Returns statusHealthCheckResult.HealthStatus.WARNINGif only some httpClientsCache are healthy.voidclose()Take the next HTTP client from the pool.
Please note that it uses a round-robin internally.static HttpClientPoolnewHttpClientPool(ServerConfiguration serverConfiguration) Return a resilient client with the following features.toString()
-
Constructor Details
-
HttpClientPool
protected HttpClientPool(DnsLookupWrapper dnsLookupWrapper, ScheduledExecutorService scheduledExecutorService, ServerConfiguration serverConfiguration, Function<InetAddress, HttpClient> singleHttpClientProvider)
-
-
Method Details
-
builder
-
newHttpClientPool
-
getNextHttpClient
Take the next HTTP client from the pool.
Please note that it uses a round-robin internally. So once it reaches the end of the list it starts returning items from the beginning and so on. -
resilientClient
Return a resilient client with the following features.DNS failover if an IP resolved by DNS is not reachable it automatically fallbacks to another IP
Monitored each IP connection to the server is monitored in HTTP
Load balanced the traffic is load balanced on DNS records
-
check
Returns statusHealthCheckResult.HealthStatus.OKif all httpClientsCache are healthy.
Returns statusHealthCheckResult.HealthStatus.ERRORif all httpClientsCache are unhealthy.
Returns statusHealthCheckResult.HealthStatus.WARNINGif only some httpClientsCache are healthy. -
toString
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-