public class KeyValueClient extends Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
KeyValueClient.Api
Retrofit API interface.
|
| Modifier and Type | Field and Description |
|---|---|
protected Http |
http |
static int |
NOT_FOUND_404 |
| Modifier and Type | Method and Description |
|---|---|
boolean |
acquireLock(String key,
String session)
Aquire a lock for a given key.
|
boolean |
acquireLock(String key,
String value,
String session)
Aquire a lock for a given key.
|
void |
deleteKey(String key)
Deletes a specified key.
|
void |
deleteKey(String key,
DeleteOptions deleteOptions)
Deletes a specified key.
|
void |
deleteKeys(String key)
Deletes a specified key and any below it.
|
ClientConfig |
getConfig() |
Optional<ConsulResponse<Value>> |
getConsulResponseWithValue(String key)
Retrieves a
ConsulResponse with the
Value for a spefici key from the
key/value store |
Optional<ConsulResponse<Value>> |
getConsulResponseWithValue(String key,
QueryOptions queryOptions)
Returns a
ConsulResponse for a specific key from the kv store. |
ConsulResponse<List<Value>> |
getConsulResponseWithValues(String key)
Retrieves a
ConsulResponse with a list of Value objects along with
consul response headers for a specific key from the key/value store. |
ConsulResponse<List<Value>> |
getConsulResponseWithValues(String key,
QueryOptions queryOptions)
Retrieves a
ConsulResponse with a list of Value objects along with
consul response headers for a specific key from the key/value store. |
ClientEventHandler |
getEventHandler() |
List<String> |
getKeys(String key)
Retrieves a list of matching keys for the given key.
|
List<String> |
getKeys(String key,
QueryOptions queryOptions)
Retrieves a list of matching keys for the given key.
|
Optional<String> |
getSession(String key)
Retrieves a session string for a specific key from the key/value store.
|
Optional<Value> |
getValue(String key)
Retrieves a
Value for a specific key
from the key/value store. |
Optional<Value> |
getValue(String key,
QueryOptions queryOptions)
Retrieves a
Value for a specific key
from the key/value store. |
void |
getValue(String key,
QueryOptions queryOptions,
ConsulResponseCallback<Optional<Value>> callback)
Asynchronously retrieves a
Value for a specific key
from the key/value store. |
Optional<String> |
getValueAsString(String key)
Retrieves a string value for a specific key from the key/value store.
|
Optional<String> |
getValueAsString(String key,
Charset charset)
Retrieves a string value for a specific key from the key/value store.
|
List<Value> |
getValues(String key)
Retrieves a list of
Value objects for a specific key
from the key/value store. |
List<Value> |
getValues(String key,
QueryOptions queryOptions)
Retrieves a list of
Value objects for a specific key
from the key/value store. |
void |
getValues(String key,
QueryOptions queryOptions,
ConsulResponseCallback<List<Value>> callback)
Asynchronously retrieves a list of
Value objects for a specific key
from the key/value store. |
List<String> |
getValuesAsString(String key)
Retrieves a list of string values for a specific key from the key/value
store.
|
List<String> |
getValuesAsString(String key,
Charset charset)
Retrieves a list of string values for a specific key from the key/value
store.
|
ConsulResponse<TxResponse> |
performTransaction(ConsistencyMode consistency,
Operation... operations)
Deprecated.
|
ConsulResponse<TxResponse> |
performTransaction(Operation... operations)
Performs a Consul transaction.
|
ConsulResponse<TxResponse> |
performTransaction(TransactionOptions transactionOptions,
Operation... operations)
Performs a Consul transaction.
|
boolean |
putValue(String key)
Puts a null value into the key/value store.
|
boolean |
putValue(String key,
byte[] value,
long flags,
PutOptions putOptions)
Puts a value into the key/value store.
|
boolean |
putValue(String key,
String value)
Puts a value into the key/value store.
|
boolean |
putValue(String key,
String value,
Charset charset)
Puts a value into the key/value store.
|
boolean |
putValue(String key,
String value,
long flags)
Puts a value into the key/value store.
|
boolean |
putValue(String key,
String value,
long flags,
Charset charset)
Puts a value into the key/value store.
|
boolean |
putValue(String key,
String value,
long flags,
PutOptions putOptions)
Puts a value into the key/value store.
|
boolean |
putValue(String key,
String value,
long flags,
PutOptions putOptions,
Charset charset)
Puts a value into the key/value store.
|
boolean |
releaseLock(String key,
String sessionId)
Releases the lock for a given service and session.
|
public static final int NOT_FOUND_404
protected final Http http
public Optional<Value> getValue(String key)
Value for a specific key
from the key/value store.
GET /v1/kv/{key}key - The key to retrieve.Optional containing the value or Optional.empty()()public Optional<ConsulResponse<Value>> getConsulResponseWithValue(String key)
ConsulResponse with the
Value for a spefici key from the
key/value storekey - The key to retrieveOptional containing the ConsulResponse or Optional.empty()()public Optional<Value> getValue(String key, QueryOptions queryOptions)
Value for a specific key
from the key/value store.
GET /v1/kv/{key}key - The key to retrieve.queryOptions - The query options.Optional containing the value or Optional.empty()()public Optional<ConsulResponse<Value>> getConsulResponseWithValue(String key, QueryOptions queryOptions)
ConsulResponse for a specific key from the kv store.
Contains the consul response headers along with the configuration value.
GET /v1/kv/{key}key - The key to retrieve.queryOptions - The query options.Optional containing the ConsulResponse or Optional.empty()public void getValue(String key, QueryOptions queryOptions, ConsulResponseCallback<Optional<Value>> callback)
Value for a specific key
from the key/value store.
GET /v1/kv/{key}key - The key to retrieve.queryOptions - The query options.callback - Callback implemented by callee to handle results.public List<Value> getValues(String key)
Value objects for a specific key
from the key/value store.
GET /v1/kv/{key}?recursekey - The key to retrieve.Value objects.public ConsulResponse<List<Value>> getConsulResponseWithValues(String key)
ConsulResponse with a list of Value objects along with
consul response headers for a specific key from the key/value store.
GET /v1/kv/{key}?recursekey - The key to retrieve.ConsulResponse with a list of zero to many Value objects and
consul response headers.public List<Value> getValues(String key, QueryOptions queryOptions)
Value objects for a specific key
from the key/value store.
GET /v1/kv/{key}?recursekey - The key to retrieve.queryOptions - The query options.Value objects.public ConsulResponse<List<Value>> getConsulResponseWithValues(String key, QueryOptions queryOptions)
ConsulResponse with a list of Value objects along with
consul response headers for a specific key from the key/value store.
GET /v1/kv/{key}?recursekey - The key to retrieve.queryOptions - The query options to use.ConsulResponse with a list of zero to many Value objects and
consul response headers.public void getValues(String key, QueryOptions queryOptions, ConsulResponseCallback<List<Value>> callback)
Value objects for a specific key
from the key/value store.
GET /v1/kv/{key}?recursekey - The key to retrieve.queryOptions - The query options.callback - Callback implemented by callee to handle results.public Optional<String> getValueAsString(String key)
key - The key to retrieve.Optional containing the value as a string or
Optional.empty()public Optional<String> getValueAsString(String key, Charset charset)
key - The key to retrieve.charset - The charset of the valueOptional containing the value as a string or
Optional.empty()public List<String> getValuesAsString(String key)
key - The key to retrieve.public List<String> getValuesAsString(String key, Charset charset)
key - The key to retrieve.charset - The charset of the valuepublic boolean putValue(String key)
key - The key to use as index.true if the value was successfully indexed.public boolean putValue(String key, String value)
key - The key to use as index.value - The value to index.true if the value was successfully indexed.public boolean putValue(String key, String value, Charset charset)
key - The key to use as index.value - The value to index.true if the value was successfully indexed.public boolean putValue(String key, String value, long flags)
key - The key to use as index.value - The value to index.flags - The flags for this key.true if the value was successfully indexed.public boolean putValue(String key, String value, long flags, Charset charset)
key - The key to use as index.value - The value to index.flags - The flags for this key.true if the value was successfully indexed.public boolean putValue(String key, String value, long flags, PutOptions putOptions)
key - The key to use as index.value - The value to index.putOptions - PUT options (e.g. wait, acquire).true if the value was successfully indexed.public boolean putValue(String key, String value, long flags, PutOptions putOptions, Charset charset)
key - The key to use as index.value - The value to index.putOptions - PUT options (e.g. wait, acquire).true if the value was successfully indexed.public boolean putValue(String key, byte[] value, long flags, PutOptions putOptions)
key - The key to use as index.value - The value to index.putOptions - PUT options (e.g. wait, acquire).true if the value was successfully indexed.public List<String> getKeys(String key)
key - The key to retrieve.public List<String> getKeys(String key, QueryOptions queryOptions)
key - The key to retrieve.queryOptions - The query options.public void deleteKey(String key)
key - The key to delete.public void deleteKeys(String key)
key - The key to delete.public void deleteKey(String key, DeleteOptions deleteOptions)
key - The key to delete.deleteOptions - DELETE options (e.g. recurse, cas)public boolean acquireLock(String key, String session)
key - The key to acquire the lock.session - The session to acquire lock.public boolean acquireLock(String key, String value, String session)
key - The key to acquire the lock.session - The session to acquire lock.value - key value (usually - application specific info about the lock requester)public Optional<String> getSession(String key)
key - The key to retrieve.Optional containing the value as a string or
Optional.empty()public boolean releaseLock(String key, String sessionId)
key - identifying the service.sessionId - SessionInfo.public ConsulResponse<TxResponse> performTransaction(Operation... operations)
operations - A list of KV operations.ConsulResponse containing results and potential errors.@Deprecated public ConsulResponse<TxResponse> performTransaction(ConsistencyMode consistency, Operation... operations)
performTransaction(TransactionOptions, Operation...)consistency - The consistency to use for the transaction.operations - A list of KV operations.ConsulResponse containing results and potential errors.public ConsulResponse<TxResponse> performTransaction(TransactionOptions transactionOptions, Operation... operations)
transactionOptions - transaction options (e.g. dc, consistency).operations - A list of KV operations.ConsulResponse containing results and potential errors.public ClientConfig getConfig()
public ClientEventHandler getEventHandler()
Copyright © 2019. All rights reserved.