Package org.kiwiproject.jersey.client
Interface ClientBuilder
-
- All Known Implementing Classes:
RegistryAwareClientBuilder
public interface ClientBuilder
Configure and createRegistryAwareClient
instances using a fluent builder interface. UseClientBuilders
to get a builder instance.Inspired by
ClientBuilder
.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description RegistryAwareClient
build()
Builds theRegistryAwareClient
with the configured options.ClientBuilder
connectTimeout(int millis)
Sets the connect timeout for the client.ClientBuilder
connectTimeout(long millis)
Sets the connect timeout for the client.ClientBuilder
headersSupplier(Supplier<Map<String,Object>> headersSupplier)
The givenSupplier
will be used to attach headers to all requests that the builtRegistryAwareClient
instance sends.ClientBuilder
hostnameVerifier(HostnameVerifier hostnameVerifier)
Sets the hostname verifier for the client.ClientBuilder
multipart()
Enables the multipart feature on the client.ClientBuilder
readTimeout(int millis)
Sets the read timeout for the client.ClientBuilder
readTimeout(long millis)
Sets the read timeout for the client.ClientBuilder
registryClient(org.kiwiproject.registry.client.RegistryClient registryClient)
Provides theRegistryClient
to use to find services.ClientBuilder
sslContext(SSLContext sslContext)
Sets the SSL context for the client.ClientBuilder
timeoutsFrom(ServiceIdentifier serviceIdentifier)
Sets the connect and read timeouts for the client from aServiceIdentifier
.ClientBuilder
tlsConfigProvider(org.kiwiproject.config.provider.TlsConfigProvider tlsConfigProvider)
Provides aTlsConfigProvider
to use to provide TLS configuration.
-
-
-
Method Detail
-
multipart
ClientBuilder multipart()
Enables the multipart feature on the client.- Returns:
- this builder
-
connectTimeout
ClientBuilder connectTimeout(int millis)
Sets the connect timeout for the client.- Parameters:
millis
- length of timeout in millis- Returns:
- this builder
-
connectTimeout
ClientBuilder connectTimeout(long millis)
Sets the connect timeout for the client.- Parameters:
millis
- length of timeout in millis- Returns:
- this builder
-
readTimeout
ClientBuilder readTimeout(int millis)
Sets the read timeout for the client.- Parameters:
millis
- length of timeout in millis- Returns:
- this builder
-
readTimeout
ClientBuilder readTimeout(long millis)
Sets the read timeout for the client.- Parameters:
millis
- length of timeout in millis- Returns:
- this builder
-
timeoutsFrom
ClientBuilder timeoutsFrom(ServiceIdentifier serviceIdentifier)
Sets the connect and read timeouts for the client from aServiceIdentifier
. This is most useful when you already have aServiceIdentifier
for a specific service, and you want to create a newRegistryAwareClient
for use making requests to that service. This in no way precludes using the client to connect to any other service, but is a convenience when you are using the "bulkhead" pattern.See Michael Nygard's excellent book Release It! for information on stability patterns including bulkheads. Microsoft also has a good description in their Azure design patterns.
- Parameters:
serviceIdentifier
- defines the read and connect timeouts to set on the client- Returns:
- this builder
-
hostnameVerifier
ClientBuilder hostnameVerifier(HostnameVerifier hostnameVerifier)
Sets the hostname verifier for the client.- Parameters:
hostnameVerifier
- TheHostnameVerifier
to use- Returns:
- this builder
-
sslContext
ClientBuilder sslContext(SSLContext sslContext)
Sets the SSL context for the client.- Parameters:
sslContext
- TheSSLContext
to use- Returns:
- this builder
-
tlsConfigProvider
ClientBuilder tlsConfigProvider(org.kiwiproject.config.provider.TlsConfigProvider tlsConfigProvider)
Provides aTlsConfigProvider
to use to provide TLS configuration.- Parameters:
tlsConfigProvider
- The config provider to provide TLS settings- Returns:
- this builder
-
registryClient
ClientBuilder registryClient(org.kiwiproject.registry.client.RegistryClient registryClient)
Provides theRegistryClient
to use to find services.- Parameters:
registryClient
- TheRegistryClient
responsible for looking up services to connect to- Returns:
- this builder
-
headersSupplier
ClientBuilder headersSupplier(Supplier<Map<String,Object>> headersSupplier)
The givenSupplier
will be used to attach headers to all requests that the builtRegistryAwareClient
instance sends.- Parameters:
headersSupplier
- aSupplier
that creates a header map- Returns:
- this builder
-
build
RegistryAwareClient build()
Builds theRegistryAwareClient
with the configured options.- Returns:
- a
RegistryAwareClient
-
-