public class Consultant extends Object
| Modifier and Type | Class | Description |
|---|---|---|
static class |
Consultant.Builder |
Allows you to build a custom Consultant object.
|
| Modifier and Type | Method | Description |
|---|---|---|
void |
addConfigListener(ConfigListener listener) |
|
void |
addSettingListener(String key,
SettingListener listener) |
|
static Consultant.Builder |
builder() |
|
void |
deregisterService() |
|
String |
getConsulHost() |
|
Properties |
getProperties() |
|
ServiceIdentifier |
getServiceIdentifier() |
|
List<ServiceInstance> |
list(String serviceName) |
Deprecated.
|
Optional<InetSocketAddress> |
locate(String serviceName) |
Deprecated.
|
ServiceLocator |
locateAll(String serviceName) |
Returns a ServiceLocator with which services matching the specified service name can be found.
|
ServiceLocator |
locateAll(String serviceName,
RoutingStrategy routingStrategy) |
Returns a ServiceLocator with which services matching the specified service name can be found.
|
void |
registerService(int port) |
|
boolean |
removeConfigListener(ConfigListener listener) |
|
boolean |
removeSettingListener(String key,
SettingListener listener) |
|
boolean |
setConfig(String key,
String value) |
Updates a config in Consul's KV store.
|
boolean |
setConfig(ServiceIdentifier identifier,
String key,
String value) |
Updates a config in Consul's KV store.
|
void |
shutdown() |
Tears any outstanding resources down.
|
public static Consultant.Builder builder()
public void registerService(int port)
public void deregisterService()
@Deprecated public List<ServiceInstance> list(String serviceName)
serviceName - The name of the service to locate instances of.public ServiceLocator locateAll(String serviceName)
serviceName - The name of the service to locate instances of.public ServiceLocator locateAll(String serviceName, RoutingStrategy routingStrategy)
serviceName - The name of the service to locate instances of.routingStrategy - The RoutingStrategy to use to locate instances.@Deprecated public Optional<InetSocketAddress> locate(String serviceName)
serviceName - The name of the service to locate.public void addConfigListener(ConfigListener listener)
public boolean removeConfigListener(ConfigListener listener)
public void addSettingListener(String key, SettingListener listener)
public boolean removeSettingListener(String key, SettingListener listener)
public boolean setConfig(String key, String value)
key - The key to set/update/delete.value - The new value for the key. Specifying a NULL will delete it.public boolean setConfig(ServiceIdentifier identifier, String key, String value)
identifier - A qualifier for which this update should apply. Use this if you wish to limit the
config update to a specific datacenter, host, or instance.key - The key to set/update/delete.value - The new value for the key. Specifying a NULL will delete it.public void shutdown()
throws InterruptedException
InterruptedException - If it got interrupted while waiting for any open taskspublic String getConsulHost()
public ServiceIdentifier getServiceIdentifier()
public Properties getProperties()
Copyright © 2022. All rights reserved.