Package io.servicetalk.http.netty
Class HttpClients
- java.lang.Object
-
- io.servicetalk.http.netty.HttpClients
-
public final class HttpClients extends java.lang.Object
Factory methods for buildingHttpClient
(and other API variations) instances.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static MultiAddressHttpClientBuilder<HostAndPort,java.net.InetSocketAddress>
forMultiAddressUrl()
Creates aMultiAddressHttpClientBuilder
for clients capable of parsing an absolute-form URL, connecting to multiple addresses with defaultLoadBalancer
and DNSServiceDiscoverer
.static MultiAddressHttpClientBuilder<HostAndPort,java.net.InetSocketAddress>
forMultiAddressUrl(ServiceDiscoverer<HostAndPort,java.net.InetSocketAddress,ServiceDiscovererEvent<java.net.InetSocketAddress>> serviceDiscoverer)
Creates aMultiAddressHttpClientBuilder
for clients capable of parsing an absolute-form URL, connecting to multiple addresses with defaultLoadBalancer
and user providedServiceDiscoverer
.static <U,R>
PartitionedHttpClientBuilder<U,R>forPartitionedAddress(ServiceDiscoverer<U,R,PartitionedServiceDiscovererEvent<R>> serviceDiscoverer, U address, java.util.function.Function<HttpRequestMetaData,PartitionAttributesBuilder> partitionAttributesBuilderFactory)
Creates aPartitionedHttpClientBuilder
for a custom address type with defaultLoadBalancer
and user providedServiceDiscoverer
.static SingleAddressHttpClientBuilder<HostAndPort,java.net.InetSocketAddress>
forResolvedAddress(HostAndPort address)
Creates aSingleAddressHttpClientBuilder
for an address with defaultLoadBalancer
and DNSServiceDiscoverer
.static SingleAddressHttpClientBuilder<HostAndPort,java.net.InetSocketAddress>
forResolvedAddress(java.lang.String host, int port)
Creates aSingleAddressHttpClientBuilder
for a resolved address with defaultLoadBalancer
.static <T extends java.net.SocketAddress>
SingleAddressHttpClientBuilder<T,T>forResolvedAddress(T address)
Creates aSingleAddressHttpClientBuilder
for an address with defaultLoadBalancer
and DNSServiceDiscoverer
.static SingleAddressHttpClientBuilder<HostAndPort,java.net.InetSocketAddress>
forResolvedAddressViaProxy(HostAndPort address, HostAndPort proxyAddress)
Creates aSingleAddressHttpClientBuilder
for an address via a proxy, with defaultLoadBalancer
and DNSServiceDiscoverer
.static SingleAddressHttpClientBuilder<HostAndPort,java.net.InetSocketAddress>
forResolvedAddressViaProxy(java.lang.String host, int port, java.lang.String proxyHost, int proxyPort)
Creates aSingleAddressHttpClientBuilder
for a resolved address via a proxy, with defaultLoadBalancer
.static SingleAddressHttpClientBuilder<java.net.InetSocketAddress,java.net.InetSocketAddress>
forResolvedAddressViaProxy(java.net.InetSocketAddress address, java.net.InetSocketAddress proxyAddress)
Creates aSingleAddressHttpClientBuilder
for an address via a proxy, with defaultLoadBalancer
and DNSServiceDiscoverer
.static SingleAddressHttpClientBuilder<java.lang.String,java.net.InetSocketAddress>
forServiceAddress(java.lang.String serviceName)
Creates aSingleAddressHttpClientBuilder
for the passedserviceName
with defaultLoadBalancer
and a DNSServiceDiscoverer
using SRV record lookups.static <U,R>
SingleAddressHttpClientBuilder<U,R>forSingleAddress(ServiceDiscoverer<U,R,ServiceDiscovererEvent<R>> serviceDiscoverer, U address)
Creates aSingleAddressHttpClientBuilder
for a custom address type with defaultLoadBalancer
and user providedServiceDiscoverer
.static SingleAddressHttpClientBuilder<HostAndPort,java.net.InetSocketAddress>
forSingleAddress(HostAndPort address)
Creates aSingleAddressHttpClientBuilder
for an address with defaultLoadBalancer
and DNSServiceDiscoverer
.static SingleAddressHttpClientBuilder<HostAndPort,java.net.InetSocketAddress>
forSingleAddress(java.lang.String host, int port)
Creates aSingleAddressHttpClientBuilder
for an address with defaultLoadBalancer
and DNSServiceDiscoverer
.static SingleAddressHttpClientBuilder<HostAndPort,java.net.InetSocketAddress>
forSingleAddressViaProxy(HostAndPort address, HostAndPort proxyAddress)
Creates aSingleAddressHttpClientBuilder
for an address via a proxy, with defaultLoadBalancer
and DNSServiceDiscoverer
.static SingleAddressHttpClientBuilder<HostAndPort,java.net.InetSocketAddress>
forSingleAddressViaProxy(java.lang.String host, int port, java.lang.String proxyHost, int proxyPort)
Creates aSingleAddressHttpClientBuilder
for an address via a proxy, with defaultLoadBalancer
and DNSServiceDiscoverer
.
-
-
-
Method Detail
-
forMultiAddressUrl
public static MultiAddressHttpClientBuilder<HostAndPort,java.net.InetSocketAddress> forMultiAddressUrl()
Creates aMultiAddressHttpClientBuilder
for clients capable of parsing an absolute-form URL, connecting to multiple addresses with defaultLoadBalancer
and DNSServiceDiscoverer
.When a relative URL is passed in the
StreamingHttpRequest.requestTarget(String)
this client requires aHttpHeaderNames.HOST
present in order to infer the remote address.- Returns:
- new builder with default configuration
-
forMultiAddressUrl
public static MultiAddressHttpClientBuilder<HostAndPort,java.net.InetSocketAddress> forMultiAddressUrl(ServiceDiscoverer<HostAndPort,java.net.InetSocketAddress,ServiceDiscovererEvent<java.net.InetSocketAddress>> serviceDiscoverer)
Creates aMultiAddressHttpClientBuilder
for clients capable of parsing an absolute-form URL, connecting to multiple addresses with defaultLoadBalancer
and user providedServiceDiscoverer
.When a relative URL is passed in the
StreamingHttpRequest.requestTarget(String)
this client requires aHttpHeaderNames.HOST
present in order to infer the remote address.- Parameters:
serviceDiscoverer
- TheServiceDiscoverer
to resolve addresses of remote servers to connect to. The lifecycle of the providedServiceDiscoverer
should be managed by the caller.- Returns:
- new builder with default configuration
-
forSingleAddress
public static SingleAddressHttpClientBuilder<HostAndPort,java.net.InetSocketAddress> forSingleAddress(java.lang.String host, int port)
Creates aSingleAddressHttpClientBuilder
for an address with defaultLoadBalancer
and DNSServiceDiscoverer
.- Parameters:
host
- host to connect to, resolved by default using a DNSServiceDiscoverer
. This will also be used for theHttpHeaderNames.HOST
together with theport
. UseSingleAddressHttpClientBuilder.unresolvedAddressToHost(Function)
if you want to override that value orSingleAddressHttpClientBuilder.disableHostHeaderFallback()
if you want to disable this behavior.port
- port to connect to- Returns:
- new builder for the address
-
forSingleAddressViaProxy
public static SingleAddressHttpClientBuilder<HostAndPort,java.net.InetSocketAddress> forSingleAddressViaProxy(java.lang.String host, int port, java.lang.String proxyHost, int proxyPort)
Creates aSingleAddressHttpClientBuilder
for an address via a proxy, with defaultLoadBalancer
and DNSServiceDiscoverer
.- Parameters:
host
- host to connect to via the proxy. This will also be used for theHttpHeaderNames.HOST
together with theport
. UseSingleAddressHttpClientBuilder.unresolvedAddressToHost(Function)
if you want to override that value orSingleAddressHttpClientBuilder.disableHostHeaderFallback()
if you want to disable this behavior.port
- port to connect toproxyHost
- the proxy host to connect to, resolved by default using a DNSServiceDiscoverer
.proxyPort
- The proxy port to connect.- Returns:
- new builder for the address
-
forSingleAddress
public static SingleAddressHttpClientBuilder<HostAndPort,java.net.InetSocketAddress> forSingleAddress(HostAndPort address)
Creates aSingleAddressHttpClientBuilder
for an address with defaultLoadBalancer
and DNSServiceDiscoverer
.- Parameters:
address
- theUnresolvedAddress
to connect to, resolved by default using a DNSServiceDiscoverer
. This address will also be used for theHttpHeaderNames.HOST
. UseSingleAddressHttpClientBuilder.unresolvedAddressToHost(Function)
if you want to override that value orSingleAddressHttpClientBuilder.disableHostHeaderFallback()
if you want to disable this behavior.- Returns:
- new builder for the address
-
forServiceAddress
public static SingleAddressHttpClientBuilder<java.lang.String,java.net.InetSocketAddress> forServiceAddress(java.lang.String serviceName)
Creates aSingleAddressHttpClientBuilder
for the passedserviceName
with defaultLoadBalancer
and a DNSServiceDiscoverer
using SRV record lookups.- Parameters:
serviceName
- The service name to resolve with SRV DNS.- Returns:
- new builder for the address
-
forSingleAddressViaProxy
public static SingleAddressHttpClientBuilder<HostAndPort,java.net.InetSocketAddress> forSingleAddressViaProxy(HostAndPort address, HostAndPort proxyAddress)
Creates aSingleAddressHttpClientBuilder
for an address via a proxy, with defaultLoadBalancer
and DNSServiceDiscoverer
.- Parameters:
address
- theUnresolvedAddress
to connect to via the proxy. This address will also be used for theHttpHeaderNames.HOST
. UseSingleAddressHttpClientBuilder.unresolvedAddressToHost(Function)
if you want to override that value orSingleAddressHttpClientBuilder.disableHostHeaderFallback()
if you want to disable this behavior.proxyAddress
- the proxyUnresolvedAddress
to connect to, resolved by default using a DNSServiceDiscoverer
.- Returns:
- new builder for the address
-
forResolvedAddress
public static SingleAddressHttpClientBuilder<HostAndPort,java.net.InetSocketAddress> forResolvedAddress(java.lang.String host, int port)
Creates aSingleAddressHttpClientBuilder
for a resolved address with defaultLoadBalancer
.- Parameters:
host
- resolved host address to connect. This will also be used for theHttpHeaderNames.HOST
together with theport
. UseSingleAddressHttpClientBuilder.unresolvedAddressToHost(Function)
if you want to override that value orSingleAddressHttpClientBuilder.disableHostHeaderFallback()
if you want to disable this behavior.port
- port to connect to- Returns:
- new builder for the address
-
forResolvedAddressViaProxy
public static SingleAddressHttpClientBuilder<HostAndPort,java.net.InetSocketAddress> forResolvedAddressViaProxy(java.lang.String host, int port, java.lang.String proxyHost, int proxyPort)
Creates aSingleAddressHttpClientBuilder
for a resolved address via a proxy, with defaultLoadBalancer
.- Parameters:
host
- resolved host address to connect via the proxy. This will also be used for theHttpHeaderNames.HOST
together with theport
. UseSingleAddressHttpClientBuilder.unresolvedAddressToHost(Function)
if you want to override that value orSingleAddressHttpClientBuilder.disableHostHeaderFallback()
if you want to disable this behavior.port
- port to connect to via the proxyproxyHost
- The proxy resolved host address to connect.proxyPort
- The proxy port to connect.- Returns:
- new builder for the address
-
forResolvedAddress
public static SingleAddressHttpClientBuilder<HostAndPort,java.net.InetSocketAddress> forResolvedAddress(HostAndPort address)
Creates aSingleAddressHttpClientBuilder
for an address with defaultLoadBalancer
and DNSServiceDiscoverer
.- Parameters:
address
- theResolvedAddress
to connect. This address will also be used for theHttpHeaderNames.HOST
. UseSingleAddressHttpClientBuilder.unresolvedAddressToHost(Function)
if you want to override that value orSingleAddressHttpClientBuilder.disableHostHeaderFallback()
if you want to disable this behavior.- Returns:
- new builder for the address
-
forResolvedAddressViaProxy
public static SingleAddressHttpClientBuilder<HostAndPort,java.net.InetSocketAddress> forResolvedAddressViaProxy(HostAndPort address, HostAndPort proxyAddress)
Creates aSingleAddressHttpClientBuilder
for an address via a proxy, with defaultLoadBalancer
and DNSServiceDiscoverer
.- Parameters:
address
- theResolvedAddress
to connect to via the proxy. This address will also be used for theHttpHeaderNames.HOST
. UseSingleAddressHttpClientBuilder.unresolvedAddressToHost(Function)
if you want to override that value orSingleAddressHttpClientBuilder.disableHostHeaderFallback()
if you want to disable this behavior.proxyAddress
- The proxyResolvedAddress
to connect.- Returns:
- new builder for the address
-
forResolvedAddress
public static <T extends java.net.SocketAddress> SingleAddressHttpClientBuilder<T,T> forResolvedAddress(T address)
Creates aSingleAddressHttpClientBuilder
for an address with defaultLoadBalancer
and DNSServiceDiscoverer
.- Type Parameters:
T
- The type ofSocketAddress
.- Parameters:
address
- theResolvedAddress
to connect. This address will also be used for theHttpHeaderNames.HOST
. UseSingleAddressHttpClientBuilder.unresolvedAddressToHost(Function)
if you want to override that value orSingleAddressHttpClientBuilder.disableHostHeaderFallback()
if you want to disable this behavior.- Returns:
- new builder for the address
-
forResolvedAddressViaProxy
public static SingleAddressHttpClientBuilder<java.net.InetSocketAddress,java.net.InetSocketAddress> forResolvedAddressViaProxy(java.net.InetSocketAddress address, java.net.InetSocketAddress proxyAddress)
Creates aSingleAddressHttpClientBuilder
for an address via a proxy, with defaultLoadBalancer
and DNSServiceDiscoverer
.- Parameters:
address
- theResolvedAddress
to connect to via the proxy. This address will also be used for theHttpHeaderNames.HOST
. UseSingleAddressHttpClientBuilder.unresolvedAddressToHost(Function)
if you want to override that value orSingleAddressHttpClientBuilder.disableHostHeaderFallback()
if you want to disable this behavior.proxyAddress
- The proxyResolvedAddress
to connect.- Returns:
- new builder for the address
-
forSingleAddress
public static <U,R> SingleAddressHttpClientBuilder<U,R> forSingleAddress(ServiceDiscoverer<U,R,ServiceDiscovererEvent<R>> serviceDiscoverer, U address)
Creates aSingleAddressHttpClientBuilder
for a custom address type with defaultLoadBalancer
and user providedServiceDiscoverer
.- Type Parameters:
U
- the type of address before resolution (unresolved address)R
- the type of address after resolution (resolved address)- Parameters:
serviceDiscoverer
- TheServiceDiscoverer
to resolve addresses of remote servers to connect to. The lifecycle of the providedServiceDiscoverer
should be managed by the caller.address
- theUnresolvedAddress
to connect to resolved using the providedserviceDiscoverer
. This address will also be used for theHttpHeaderNames.HOST
using a best effort conversion. UseSingleAddressHttpClientBuilder.unresolvedAddressToHost(Function)
if you want to override that value orSingleAddressHttpClientBuilder.disableHostHeaderFallback()
if you want to disable this behavior.- Returns:
- new builder with provided configuration
-
forPartitionedAddress
public static <U,R> PartitionedHttpClientBuilder<U,R> forPartitionedAddress(ServiceDiscoverer<U,R,PartitionedServiceDiscovererEvent<R>> serviceDiscoverer, U address, java.util.function.Function<HttpRequestMetaData,PartitionAttributesBuilder> partitionAttributesBuilderFactory)
Creates aPartitionedHttpClientBuilder
for a custom address type with defaultLoadBalancer
and user providedServiceDiscoverer
.- Type Parameters:
U
- the type of address before resolution (unresolved address)R
- the type of address after resolution (resolved address)- Parameters:
serviceDiscoverer
- TheServiceDiscoverer
to resolve addresses of remote servers to connect to. The lifecycle of the providedServiceDiscoverer
should be managed by the caller.address
- theUnresolvedAddress
to resolve using the providedserviceDiscoverer
. This address will also be used for theHttpHeaderNames.HOST
using a best effort conversion. UsePartitionedHttpClientBuilder.unresolvedAddressToHost(Function)
if you want to override that value orPartitionedHttpClientBuilder.disableHostHeaderFallback()
if you want to disable this behavior.partitionAttributesBuilderFactory
- The factoryFunction
used to buildPartitionAttributes
fromHttpRequestMetaData
.- Returns:
- new builder with provided configuration
-
-