Modifier and Type | Method and Description |
---|---|
Consul |
build()
Constructs a new
Consul client. |
Consul.Builder |
withAclToken(String token)
Sets the ACL token to be used with Consul
|
Consul.Builder |
withBasicAuth(String username,
String password)
Sets the username and password to be used for basic authentication
|
Consul.Builder |
withClientConfiguration(ClientConfig clientConfig)
Sets the configuration for the clients.
|
Consul.Builder |
withClientEventCallback(ClientEventCallback callback)
Sets the event callback for the clients.
|
Consul.Builder |
withConnectTimeoutMillis(long timeoutMillis)
Connect timeout for OkHttpClient
|
Consul.Builder |
withConsulBookend(ConsulBookend consulBookend)
Attaches a
ConsulBookend to each Consul request. |
Consul.Builder |
withExecutorService(ExecutorService executorService)
Sets the ExecutorService to be used by the internal tasks dispatcher.
|
Consul.Builder |
withHeaders(Map<String,String> headers)
Sets headers to be included with each Consul request.
|
Consul.Builder |
withHostAndPort(com.google.common.net.HostAndPort hostAndPort)
Sets the URL from a
HostAndPort object. |
Consul.Builder |
withHostnameVerifier(HostnameVerifier hostnameVerifier)
Sets the
HostnameVerifier for the client. |
Consul.Builder |
withPing(boolean ping)
Instructs the builder that the AgentClient should attempt a ping before returning the Consul instance
|
Consul.Builder |
withProxy(Proxy proxy)
Sets the
Proxy for the client. |
Consul.Builder |
withReadTimeoutMillis(long timeoutMillis)
Read timeout for OkHttpClient
|
Consul.Builder |
withSslContext(SSLContext sslContext)
Sets the
SSLContext for the client. |
Consul.Builder |
withTrustManager(X509TrustManager trustManager)
Sets the
X509TrustManager for the client. |
Consul.Builder |
withUrl(String url)
Sets the URL from a string.
|
Consul.Builder |
withUrl(URL url)
Sets the URL from a
URL object. |
Consul.Builder |
withWriteTimeoutMillis(long timeoutMillis)
Write timeout for OkHttpClient
|
public Consul.Builder withUrl(URL url)
URL
object.url
- The Consul agent URL.public Consul.Builder withPing(boolean ping)
ping
- Whether the ping should be done or notpublic Consul.Builder withBasicAuth(String username, String password)
username
- the value of the usernamepassword
- the value of the passwordpublic Consul.Builder withAclToken(String token)
token
- the value of the tokenpublic Consul.Builder withHeaders(Map<String,String> headers)
headers
- Map of headers.public Consul.Builder withConsulBookend(ConsulBookend consulBookend)
ConsulBookend
to each Consul request. This can be used for gathering
metrics timings or debugging. ConsulBookend
consulBookend
- The bookend implementation.public Consul.Builder withHostAndPort(com.google.common.net.HostAndPort hostAndPort)
HostAndPort
object.hostAndPort
- The Consul agent host and port.public Consul.Builder withUrl(String url)
url
- The Consul agent URL.public Consul.Builder withSslContext(SSLContext sslContext)
SSLContext
for the client.sslContext
- The SSL context for HTTPS agents.public Consul.Builder withTrustManager(X509TrustManager trustManager)
X509TrustManager
for the client.trustManager
- The SSL trust manager for HTTPS agents.public Consul.Builder withHostnameVerifier(HostnameVerifier hostnameVerifier)
HostnameVerifier
for the client.hostnameVerifier
- The hostname verifier to use.public Consul.Builder withProxy(Proxy proxy)
Proxy
for the client.proxy
- The proxy to use.public Consul.Builder withConnectTimeoutMillis(long timeoutMillis)
timeoutMillis
- timeout values in millisecondspublic Consul.Builder withReadTimeoutMillis(long timeoutMillis)
timeoutMillis
- timeout value in millisecondspublic Consul.Builder withWriteTimeoutMillis(long timeoutMillis)
timeoutMillis
- timeout value in millisecondspublic Consul.Builder withExecutorService(ExecutorService executorService)
Consul.destroy()
method.
When an application needs to be able to customize the ExecutorService parameters, and/or manage its lifecycle,
it can provide an instance of ExecutorService to the Builder. In that case, this ExecutorService will be used instead of creating one internally.executorService
- The ExecutorService to be injected in the internal tasks dispatcher.public Consul.Builder withClientConfiguration(ClientConfig clientConfig)
clientConfig
- the configuration to use.public Consul.Builder withClientEventCallback(ClientEventCallback callback)
callback
- the callback to call.Copyright © 2018. All rights reserved.