public static class Consultant.Builder extends Object
| Modifier and Type | Class | Description |
|---|---|---|
static class |
Consultant.Builder.Agent |
|
static class |
Consultant.Builder.Config |
| Modifier and Type | Method | Description |
|---|---|---|
Consultant |
build() |
Builds a new instance of the Consultant class using the specified arguments.
|
Consultant.Builder |
identifyAs(String serviceName) |
States the identify of this application.
|
Consultant.Builder |
identifyAs(String serviceName,
String datacenter) |
States the identify of this application.
|
Consultant.Builder |
identifyAs(String serviceName,
String datacenter,
String hostname) |
States the identify of this application.
|
Consultant.Builder |
identifyAs(String serviceName,
String datacenter,
String hostname,
String instanceName) |
States the identify of this application.
|
Consultant.Builder |
onSettingUpdate(String key,
SettingListener listener) |
Specifies a callback listener which is notified of whenever the specified setting is updated.
|
Consultant.Builder |
onValidConfig(ConfigListener listener) |
Specifies a callback listener which is notified of whenever a new and valid configuration is detected
in Consul.
|
Consultant.Builder |
pullConfigFromConsul(boolean pullConfig) |
Specifies that Consultant should or should not fetch configuration from Consul.
|
Consultant.Builder |
setHealthEndpoint(String endpoint) |
States the endpoint used for checking the service's health.
|
Consultant.Builder |
startWith(Properties properties) |
Ensures that Consultant starts out with a default Properties object.
|
Consultant.Builder |
usingExecutor(ScheduledExecutorService executor) |
States that Consultant should use a specific executor service for listening to configuration updates.
|
Consultant.Builder |
usingObjectMapper(com.fasterxml.jackson.databind.ObjectMapper mapper) |
States that Consultant should use a specific ObjectMapper for serialization and deserialization of JSON.
|
Consultant.Builder |
validateConfigWith(ConfigValidator validator) |
Specifies the validator which is used to determine if a new configuration detected in Consul is valid,
and may be published through the ConfigListener callback.
|
Consultant.Builder |
whenLocatingServicesCacheResultsFor(long duration,
TimeUnit unit) |
Specifies that the results from calls being made to Consul to locate services are being cached for at
most the specified duration.
|
Consultant.Builder |
withConsulHost(String host) |
Specifies where the Consul REST API can be reached on.
|
Consultant.Builder |
withConsulToken(String token) |
Specifies that a token must be set using the
X-Consul-Token header to authenticate requests
directed at Consul with. |
Consultant.Builder |
withKvPrefix(String kvPrefix) |
Allows the caller to specify the prefix when looking up the key value properties.
|
public Consultant.Builder usingExecutor(ScheduledExecutorService executor)
executor - The ScheduledExecutorService to use to schedule jobs on.public Consultant.Builder usingObjectMapper(com.fasterxml.jackson.databind.ObjectMapper mapper)
mapper - The ObjectMapper to use when deserializing JSON and serializing objects.public Consultant.Builder withConsulHost(String host)
CONSUL_HOST=http://localhost. The default port (8500) is used.host - The host where the Consul REST API can be found.public Consultant.Builder withConsulToken(String token)
X-Consul-Token header to authenticate requests
directed at Consul with.token - The token to use when talking to Consul.public Consultant.Builder withKvPrefix(String kvPrefix)
config if not specified.kvPrefix - the path prefix to be used when looking-up the properties.public Consultant.Builder identifyAs(String serviceName)
SERVICE_NAME, and optionally SERVICE_DC and
SERVICE_HOST.serviceName - The name of this service.public Consultant.Builder identifyAs(String serviceName, String datacenter)
SERVICE_NAME, and optionally SERVICE_DC and
SERVICE_HOST. If the datacenter is not defined using environment variables either, this
value will default to the corresponding value of the Consul agent.serviceName - The name of this service.datacenter - The name of the datacenter where this service is running in.public Consultant.Builder identifyAs(String serviceName, String datacenter, String hostname)
SERVICE_NAME, and optionally SERVICE_DC and
SERVICE_HOST. If the datacenter and hostname are not defined using environment variables
either, these values will default to the corresponding values of the Consul agent.serviceName - The name of this service.datacenter - The name of the datacenter where this service is running in.hostname - The name of the host where this service is running on.public Consultant.Builder identifyAs(String serviceName, String datacenter, String hostname, String instanceName)
SERVICE_NAME, and optionally SERVICE_DC,
SERVICE_HOST, and SERVICE_INSTANCE. If the datacenter and hostname are not
defined using environment variables either, these values will default to the corresponding values of
the Consul agent.serviceName - The name of this service.datacenter - The name of the datacenter where this service is running in.hostname - The name of the host where this service is running on.instanceName - The name/role of this service instance.public Consultant.Builder setHealthEndpoint(String endpoint)
endpoint - The endpoint to use for health checking. Defaults to "/_health".public Consultant.Builder onValidConfig(ConfigListener listener)
listener - The listener to call when a new valid configuration is detected.public Consultant.Builder onSettingUpdate(String key, SettingListener listener)
key - The key of the setting to listen for.listener - The listener to call when the specified setting is updated.public Consultant.Builder validateConfigWith(ConfigValidator validator)
validator - The validator to call when a new configuration is detected.public Consultant.Builder pullConfigFromConsul(boolean pullConfig)
pullConfig - True if configuration should be retrieved from Consul, or false if it should not.public Consultant.Builder startWith(Properties properties)
properties - The Properties object to start Consultant with.public Consultant.Builder whenLocatingServicesCacheResultsFor(long duration, TimeUnit unit)
duration - The duration of time to cache locate call results for.unit - The unit of the specified duration.public Consultant build()
Copyright © 2024. All rights reserved.