Interface ConsulOperations
- All Known Subinterfaces:
ConsulClient
- All Known Implementing Classes:
AbstractConsulClient
public interface ConsulOperations
API operations for Consul.
- Since:
- 1.0
- Author:
- graemerocher
-
Method Summary
Modifier and TypeMethodDescriptionorg.reactivestreams.Publisher<Boolean>
deregister
(@NotNull CatalogEntry entry) Deprecated, for removal: This API element is subject to removal in a future version.org.reactivestreams.Publisher<Boolean>
deregister
(@NotNull ConsulCatalogEntry entry) Register a newConsulCatalogEntry
.org.reactivestreams.Publisher<io.micronaut.http.HttpStatus>
deregister
(@NotNull String service) Deregister a service.default org.reactivestreams.Publisher<io.micronaut.http.HttpStatus>
Fail the TTL check.org.reactivestreams.Publisher<io.micronaut.http.HttpStatus>
Fail the TTL check.default org.reactivestreams.Publisher<List<ConsulHealthEntry>>
findHealthyServices
(@NotNull String service) Gets service health information.org.reactivestreams.Publisher<List<ConsulHealthEntry>>
findHealthyServices
(@NotNull String service, @Nullable Boolean passing, @Nullable String tag, @Nullable String dc) find healthy services that are passing health checks.org.reactivestreams.Publisher<Map<String,
ConsulServiceEntry>> Find every registered services.default org.reactivestreams.Publisher<List<HealthEntry>>
getHealthyServices
(@NotNull String service) Deprecated, for removal: This API element is subject to removal in a future version.UsefindHealthyServices(String)
instead.org.reactivestreams.Publisher<List<HealthEntry>>
getHealthyServices
(@NotNull String service, @Nullable Boolean passing, @Nullable String tag, @Nullable String dc) Deprecated, for removal: This API element is subject to removal in a future version.UsefindHealthyServices(String, Boolean, String, String)
instead.org.reactivestreams.Publisher<List<MemberEntry>>
Returns the members the agent sees in the cluster gossip pool.org.reactivestreams.Publisher<List<CatalogEntry>>
getNodes()
Gets all of the registered nodes.org.reactivestreams.Publisher<List<CatalogEntry>>
Gets all the nodes for the given data center.org.reactivestreams.Publisher<LocalAgentConfiguration>
getSelf()
Returns the configuration and member information of the local agent.Gets all of the service names and optional tags.org.reactivestreams.Publisher<Map<String,
ServiceEntry>> Deprecated, for removal: This API element is subject to removal in a future version.UsefindServices()
instead.default org.reactivestreams.Publisher<io.micronaut.http.HttpStatus>
Pass the TTL check.org.reactivestreams.Publisher<io.micronaut.http.HttpStatus>
Pass the TTL check.org.reactivestreams.Publisher<Boolean>
Writes a value for the given key to Consul.readValues
(String key) Reads a Key from Consul.readValues
(String key, @Nullable String datacenter, @Nullable Boolean raw, @Nullable String seperator) Reads a Key from Consul.org.reactivestreams.Publisher<Boolean>
register
(@NotNull CatalogEntry entry) Deprecated, for removal: This API element is subject to removal in a future version.Useregister(ConsulCatalogEntry)
instead.org.reactivestreams.Publisher<Boolean>
register
(@NotNull ConsulCatalogEntry entry) Register a newCatalogEntry
.org.reactivestreams.Publisher<io.micronaut.http.HttpStatus>
register
(@NotNull ConsulNewServiceEntry entry) Register a newCatalogEntry
.org.reactivestreams.Publisher<io.micronaut.http.HttpStatus>
register
(@NotNull NewServiceEntry entry) Deprecated, for removal: This API element is subject to removal in a future version.Useregister(ConsulNewServiceEntry)
instead.org.reactivestreams.Publisher<String>
status()
default org.reactivestreams.Publisher<io.micronaut.http.HttpStatus>
Warn the TTL check.org.reactivestreams.Publisher<io.micronaut.http.HttpStatus>
Warn the TTL check.
-
Method Details
-
putValue
@Put(value="/kv/{+key}", processes="text/plain", single=true) org.reactivestreams.Publisher<Boolean> putValue(String key, @Body String value) Writes a value for the given key to Consul.- Parameters:
key
- The keyvalue
- The value as a String- Returns:
- A
Publisher
that emits a boolean if the operation succeeded
-
readValues
@Get(uri="/kv/{+key}?recurse", single=true) org.reactivestreams.Publisher<List<KeyValue>> readValues(String key) Reads a Key from Consul. See https://www.consul.io/api/kv.html.- Parameters:
key
- The key to read- Returns:
- A
Publisher
that emits a list ofKeyValue
-
readValues
@Get(uri="/kv/{+key}?recurse=true{&dc}{&raw}{&seperator}", single=true) @Retryable(attempts="${consul.client.config.retry-count:3}", delay="${consul.client.config.retry-delay:1s}") org.reactivestreams.Publisher<List<KeyValue>> readValues(String key, @Nullable @QueryValue("dc") @Nullable String datacenter, @Nullable @Nullable Boolean raw, @Nullable @Nullable String seperator) Reads a Key from Consul. See https://www.consul.io/api/kv.html.- Parameters:
key
- The keydatacenter
- The data centerraw
- Whether the value should be raw without encoding or metadataseperator
- The separator to use- Returns:
- A
Publisher
that emits a list ofKeyValue
-
pass
@Put("/agent/check/pass/{checkId}{?note}") @Retryable(attempts="${consul.client.registration.retry-count:3}", delay="${consul.client.registration.retry-delay:3s}") org.reactivestreams.Publisher<io.micronaut.http.HttpStatus> pass(String checkId, @Nullable @Nullable String note) Pass the TTL check. See https://www.consul.io/api/agent/check.html.- Parameters:
checkId
- The check IDnote
- An optional note- Returns:
- An
HttpStatus
ofHttpStatus.OK
if all is well
-
warn
@Put("/agent/check/warn/{checkId}{?note}") org.reactivestreams.Publisher<io.micronaut.http.HttpStatus> warn(String checkId, @Nullable @Nullable String note) Warn the TTL check. See https://www.consul.io/api/agent/check.html.- Parameters:
checkId
- The check IDnote
- An optional note- Returns:
- An
HttpStatus
ofHttpStatus.OK
if all is well
-
fail
@Put("/agent/check/fail/{checkId}{?note}") @Retryable(attempts="${consul.client.registration.retry-count:3}", delay="${consul.client.registration.retry-delay:3s}") org.reactivestreams.Publisher<io.micronaut.http.HttpStatus> fail(String checkId, @Nullable @Nullable String note) Fail the TTL check. See https://www.consul.io/api/agent/check.html.- Parameters:
checkId
- The check IDnote
- An optional note- Returns:
- An
HttpStatus
ofHttpStatus.OK
if all is well
-
status
- Returns:
- The current leader address
-
register
@Put(uri="/catalog/register", single=true) @Deprecated(since="4.1.0", forRemoval=true) org.reactivestreams.Publisher<Boolean> register(@NotNull @Body @NotNull CatalogEntry entry) Deprecated, for removal: This API element is subject to removal in a future version.Useregister(ConsulCatalogEntry)
instead.Register a newCatalogEntry
. See https://www.consul.io/api/catalog.html.- Parameters:
entry
- The entry to register- Returns:
- A
Publisher
that emits a boolean true if the operation was successful
-
deregister
@Deprecated(since="4.1.0", forRemoval=true) org.reactivestreams.Publisher<Boolean> deregister(@NotNull @Body @NotNull CatalogEntry entry) Deprecated, for removal: This API element is subject to removal in a future version.Usederegister(ConsulCatalogEntry)
instead.Register a newCatalogEntry
. See https://www.consul.io/api/catalog.html.- Parameters:
entry
- The entry to register- Returns:
- A
Publisher
that emits a boolean true if the operation was successful
-
register
@Put(uri="/catalog/register", single=true) org.reactivestreams.Publisher<Boolean> register(@NotNull @Body @NotNull ConsulCatalogEntry entry) Register a newCatalogEntry
. See https://www.consul.io/api/catalog.html.- Parameters:
entry
- The entry to register- Returns:
- A
Publisher
that emits a boolean true if the operation was successful
-
deregister
@Put(uri="/catalog/deregister", single=true) org.reactivestreams.Publisher<Boolean> deregister(@NotNull @Body @NotNull ConsulCatalogEntry entry) Register a newConsulCatalogEntry
. See https://www.consul.io/api/catalog.html.- Parameters:
entry
- The entry to register- Returns:
- A
Publisher
that emits a boolean true if the operation was successful
-
register
@Put("/agent/service/register") @Retryable(attempts="${consul.client.registration.retry-count:3}", delay="${consul.client.registration.retry-delay:3s}") org.reactivestreams.Publisher<io.micronaut.http.HttpStatus> register(@NotNull @Body @NotNull ConsulNewServiceEntry entry) Register a newCatalogEntry
. See https://www.consul.io/api/catalog.html.- Parameters:
entry
- The entry to register- Returns:
- A
Publisher
that emits a boolean true if the operation was successful
-
register
@Retryable(attempts="${consul.client.registration.retry-count:3}", delay="${consul.client.registration.retry-delay:3s}") @Deprecated(forRemoval=true, since="4.1.0") org.reactivestreams.Publisher<io.micronaut.http.HttpStatus> register(@NotNull @Body @NotNull NewServiceEntry entry) Deprecated, for removal: This API element is subject to removal in a future version.Useregister(ConsulNewServiceEntry)
instead.Register a newNewServiceEntry
. See https://www.consul.io/api/catalog.html.- Parameters:
entry
- The entry to register- Returns:
- A
Publisher
that emits a boolean true if the operation was successful
-
deregister
@Put("/agent/service/deregister/{service}") @Retryable(attempts="${consul.client.registration.retry-count:3}", delay="${consul.client.registration.retry-delay:3s}") org.reactivestreams.Publisher<io.micronaut.http.HttpStatus> deregister(@NotNull @NotNull String service) Deregister a service.- Parameters:
service
- The service to register- Returns:
- A
Publisher
that emits a boolean true if the operation was successful
-
getServices
@Deprecated(forRemoval=true, since="4.1.0") org.reactivestreams.Publisher<Map<String,ServiceEntry>> getServices()Deprecated, for removal: This API element is subject to removal in a future version.UsefindServices()
instead.Gets all of the registered services.- Returns:
- The
ServiceEntry
instances
-
findServices
@Get(uri="/agent/services", single=true) org.reactivestreams.Publisher<Map<String,ConsulServiceEntry>> findServices()Find every registered services.- Returns:
- The
ConsulServiceEntry
instances
-
getMembers
@Get(uri="/agent/members", single=true) org.reactivestreams.Publisher<List<MemberEntry>> getMembers()Returns the members the agent sees in the cluster gossip pool.- Returns:
- the
MemberEntry
instances
-
getSelf
@Get(uri="/agent/self", single=true) org.reactivestreams.Publisher<LocalAgentConfiguration> getSelf()Returns the configuration and member information of the local agent.- Returns:
- the
LocalAgentConfiguration
instance
-
getHealthyServices
@Deprecated(forRemoval=true, since="4.1.0") org.reactivestreams.Publisher<List<HealthEntry>> getHealthyServices(@NotNull @NotNull String service, @Nullable @Nullable Boolean passing, @Nullable @Nullable String tag, @Nullable @Nullable String dc) Deprecated, for removal: This API element is subject to removal in a future version.UsefindHealthyServices(String, Boolean, String, String)
instead.Gets the healthy services that are passing health checks.- Parameters:
service
- The servicepassing
- The passing parametertag
- The tagdc
- The dc- Returns:
- The
HealthEntry
instances
-
findHealthyServices
@Get(uri="/health/service/{service}{?passing,tag,dc}", single=true) org.reactivestreams.Publisher<List<ConsulHealthEntry>> findHealthyServices(@NotNull @NotNull String service, @Nullable @Nullable Boolean passing, @Nullable @Nullable String tag, @Nullable @Nullable String dc) find healthy services that are passing health checks.- Parameters:
service
- The servicepassing
- The passing parametertag
- The tagdc
- The dc- Returns:
- The
ConsulHealthEntry
instances
-
getNodes
@Get(uri="/catalog/nodes", single=true) org.reactivestreams.Publisher<List<CatalogEntry>> getNodes()Gets all of the registered nodes.- Returns:
- All the nodes
-
getNodes
@Get(uri="/catalog/nodes?dc={datacenter}", single=true) org.reactivestreams.Publisher<List<CatalogEntry>> getNodes(@NotNull @NotNull String datacenter) Gets all the nodes for the given data center.- Parameters:
datacenter
- The data center- Returns:
- A publisher that emits the nodes
-
getServiceNames
@Get(uri="/catalog/services", single=true) org.reactivestreams.Publisher<Map<String,List<String>>> getServiceNames()Gets all of the service names and optional tags.- Returns:
- A Map where the keys are service names and the values are service tags
-
pass
Pass the TTL check. See https://www.consul.io/api/agent/check.html.- Parameters:
checkId
- The check ID- Returns:
- An
HttpStatus
ofHttpStatus.OK
if all is well
-
warn
Warn the TTL check. See https://www.consul.io/api/agent/check.html.- Parameters:
checkId
- The check ID- Returns:
- An
HttpStatus
ofHttpStatus.OK
if all is well
-
fail
Fail the TTL check. See https://www.consul.io/api/agent/check.html.- Parameters:
checkId
- The check ID- Returns:
- An
HttpStatus
ofHttpStatus.OK
if all is well
-
getHealthyServices
@Deprecated(forRemoval=true, since="4.1.0") default org.reactivestreams.Publisher<List<HealthEntry>> getHealthyServices(@NotNull @NotNull String service) Deprecated, for removal: This API element is subject to removal in a future version.UsefindHealthyServices(String)
instead.Gets service health information. Defaults to return both non-healthy and healthy services.- Parameters:
service
- The service- Returns:
- The
ConsulHealthEntry
instances
-
findHealthyServices
default org.reactivestreams.Publisher<List<ConsulHealthEntry>> findHealthyServices(@NotNull @NotNull String service) Gets service health information. Defaults to return both non-healthy and healthy services.- Parameters:
service
- The service- Returns:
- The
ConsulHealthEntry
instances
-
deregister(ConsulCatalogEntry)
instead.