Package io.vertx.ext.consul
Interface Watch<T>
-
public interface Watch<T>
Watches are a way of specifying a view of data (e.g. list of nodes, KV pairs, health checks) which is monitored for updates. When an update is detected, anHandler
withWatchResult
is invoked. All errors, exceptjava.util.concurrent.TimeoutException
, will be handled, with resubscribing with a progressive delay. All timeout errors will be ignored, with resubscribing without any delay. As an example, you could watch the status of health checks and notify when a check is critical.- Author:
- Ruslan Sennov
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static Watch<EventList>
events(String event, Vertx vertx)
CreatesWatch
to monitoring the custom user events.static Watch<EventList>
events(String event, Vertx vertx, ConsulClientOptions options)
CreatesWatch
to monitoring the custom user events.static Watch<KeyValue>
key(String key, Vertx vertx)
CreatesWatch
to monitoring a specific key in the KV store.static Watch<KeyValue>
key(String key, Vertx vertx, ConsulClientOptions options)
CreatesWatch
to monitoring a specific key in the KV store.static Watch<KeyValueList>
keyPrefix(String keyPrefix, Vertx vertx)
CreatesWatch
to monitoring a prefix of keys in the KV store.static Watch<KeyValueList>
keyPrefix(String keyPrefix, Vertx vertx, ConsulClientOptions options)
CreatesWatch
to monitoring a prefix of keys in the KV store.static Watch<CheckList>
nodeHealthChecks(String node, CheckQueryOptions opt, Vertx vertx, ConsulClientOptions options)
CreatesWatch
to monitoring the health checks of the nodes.static Watch<NodeList>
nodes(Vertx vertx)
CreatesWatch
to monitoring the list of available nodes.static Watch<NodeList>
nodes(Vertx vertx, ConsulClientOptions options)
CreatesWatch
to monitoring the list of available nodes.static Watch<ServiceEntryList>
service(String service, Vertx vertx)
CreatesWatch
to monitoring the nodes providing the service.static Watch<ServiceEntryList>
service(String service, Vertx vertx, ConsulClientOptions options)
CreatesWatch
to monitoring the nodes providing the service.static Watch<CheckList>
serviceHealthChecks(String service, CheckQueryOptions checkQueryOptions, Vertx vertx, ConsulClientOptions options)
CreatesWatch
to monitoring the health checks of the nodes.static Watch<ServiceList>
services(Vertx vertx)
CreatesWatch
to monitoring the list of available services.static Watch<ServiceList>
services(Vertx vertx, ConsulClientOptions options)
CreatesWatch
to monitoring the list of available services.Watch<T>
setHandler(Handler<WatchResult<T>> handler)
Set the result handler.Watch<T>
start()
Start thisWatch
void
stop()
Stop the watch and release its resources
-
-
-
Method Detail
-
key
static Watch<KeyValue> key(String key, Vertx vertx)
CreatesWatch
to monitoring a specific key in the KV store. The underlying Consul client will be created with default options. This maps to the /v1/kv/ API internally.- Parameters:
key
- the keyvertx
- theVertx
instance- Returns:
- the
Watch
instance
-
key
static Watch<KeyValue> key(String key, Vertx vertx, ConsulClientOptions options)
CreatesWatch
to monitoring a specific key in the KV store. This maps to the /v1/kv/ API internally.- Parameters:
key
- the keyvertx
- theVertx
instanceoptions
- the options to create underlying Consul client- Returns:
- the
Watch
instance
-
keyPrefix
static Watch<KeyValueList> keyPrefix(String keyPrefix, Vertx vertx)
CreatesWatch
to monitoring a prefix of keys in the KV store. The underlying Consul client will be created with default options. This maps to the /v1/kv/ API internally.- Parameters:
keyPrefix
- the keyvertx
- theVertx
instance- Returns:
- the
Watch
instance
-
keyPrefix
static Watch<KeyValueList> keyPrefix(String keyPrefix, Vertx vertx, ConsulClientOptions options)
CreatesWatch
to monitoring a prefix of keys in the KV store. This maps to the /v1/kv/ API internally.- Parameters:
keyPrefix
- the keyvertx
- theVertx
instanceoptions
- the options to create underlying Consul client- Returns:
- the
Watch
instance
-
services
static Watch<ServiceList> services(Vertx vertx)
CreatesWatch
to monitoring the list of available services. The underlying Consul client will be created with default options. This maps to the /v1/catalog/services API internally.- Parameters:
vertx
- theVertx
instance- Returns:
- the
Watch
instance
-
services
static Watch<ServiceList> services(Vertx vertx, ConsulClientOptions options)
CreatesWatch
to monitoring the list of available services. This maps to the /v1/catalog/services API internally.- Parameters:
vertx
- theVertx
instanceoptions
- the options to create underlying Consul client- Returns:
- the
Watch
instance
-
service
static Watch<ServiceEntryList> service(String service, Vertx vertx)
CreatesWatch
to monitoring the nodes providing the service. Nodes will be sorted by distance from the consul agent. The underlying Consul client will be created with default options. This maps to the /v1/health/service/<service> API internally.- Parameters:
service
- the service namevertx
- theVertx
instance- Returns:
- the
Watch
instance
-
service
static Watch<ServiceEntryList> service(String service, Vertx vertx, ConsulClientOptions options)
CreatesWatch
to monitoring the nodes providing the service. Nodes will be sorted by distance from the consul agent. This maps to the /v1/health/service/<service> API internally.- Parameters:
service
- the service namevertx
- theVertx
instanceoptions
- the options to create underlying Consul client- Returns:
- the
Watch
instance
-
events
static Watch<EventList> events(String event, Vertx vertx)
CreatesWatch
to monitoring the custom user events. The underlying Consul client will be created with default options. This maps to the /v1/event/list API internally.- Parameters:
event
- the event namevertx
- theVertx
instance- Returns:
- the
Watch
instance
-
events
static Watch<EventList> events(String event, Vertx vertx, ConsulClientOptions options)
CreatesWatch
to monitoring the custom user events. This maps to the /v1/event/list API internally.- Parameters:
event
- the event namevertx
- theVertx
instanceoptions
- the options to create underlying Consul client- Returns:
- the
Watch
instance
-
nodes
static Watch<NodeList> nodes(Vertx vertx)
CreatesWatch
to monitoring the list of available nodes. The underlying Consul client will be created with default options. This maps to the /v1/catalog/nodes API internally.- Parameters:
vertx
- theVertx
instance- Returns:
- the
Watch
instance
-
nodes
static Watch<NodeList> nodes(Vertx vertx, ConsulClientOptions options)
CreatesWatch
to monitoring the list of available nodes. This maps to the /v1/catalog/nodes API internally.- Parameters:
vertx
- theVertx
instanceoptions
- the options to create underlying Consul client- Returns:
- the
Watch
instance
-
nodeHealthChecks
static Watch<CheckList> nodeHealthChecks(String node, CheckQueryOptions opt, Vertx vertx, ConsulClientOptions options)
CreatesWatch
to monitoring the health checks of the nodes.- Parameters:
node
- node name or IDopt
- options like namespace, datacenter and filtervertx
- theVertx
instanceoptions
- the options to create underlying Consul client- Returns:
- the
Watch
instance
-
serviceHealthChecks
static Watch<CheckList> serviceHealthChecks(String service, CheckQueryOptions checkQueryOptions, Vertx vertx, ConsulClientOptions options)
CreatesWatch
to monitoring the health checks of the nodes.- Parameters:
service
- the service namecheckQueryOptions
- options used to request checksvertx
- theVertx
instanceoptions
- the options to create underlying Consul client- Returns:
- the
Watch
instance
-
setHandler
Watch<T> setHandler(Handler<WatchResult<T>> handler)
Set the result handler. As data is changed, the handler will be called with the result.- Parameters:
handler
- the result handler- Returns:
- reference to this, for fluency
-
stop
void stop()
Stop the watch and release its resources
-
-