pub struct Consul { /* private fields */ }
Expand description
This struct defines the consul client and allows access to the consul api via method syntax.
Implementations§
source§impl Consul
impl Consul
sourcepub async fn read_key(
&self,
request: ReadKeyRequest<'_>
) -> Result<Vec<ReadKeyResponse>, ConsulError>
pub async fn read_key( &self, request: ReadKeyRequest<'_> ) -> Result<Vec<ReadKeyResponse>, ConsulError>
Reads a key from Consul’s KV store. See the consul docs for more information.
§Arguments:
- request - the ReadKeyRequest
§Errors:
ConsulError describes all possible errors returned by this api.
sourcepub async fn create_or_update_key(
&self,
request: CreateOrUpdateKeyRequest<'_>,
value: Vec<u8>
) -> Result<(bool, u64), ConsulError>
pub async fn create_or_update_key( &self, request: CreateOrUpdateKeyRequest<'_>, value: Vec<u8> ) -> Result<(bool, u64), ConsulError>
Creates or updates a key in Consul’s KV store. See the consul docs for more information.
§Arguments:
- request - the CreateOrUpdateKeyRequest
- value - the data to store as Bytes
§Returns:
A tuple of a boolean and a 64 bit unsigned integer representing whether the operation was successful and the index for a subsequent blocking query.
§Errors:
ConsulError describes all possible errors returned by this api.
sourcepub fn create_or_update_key_sync(
&self,
request: CreateOrUpdateKeyRequest<'_>,
value: Vec<u8>
) -> Result<bool, ConsulError>
pub fn create_or_update_key_sync( &self, request: CreateOrUpdateKeyRequest<'_>, value: Vec<u8> ) -> Result<bool, ConsulError>
Creates or updates a key in Consul’s KV store. See the consul docs for more information. This is the synchronous version of create_or_update_key
§Arguments:
- request - the CreateOrUpdateKeyRequest
- value - the data to store as Bytes
§Returns:
A tuple of a boolean and a 64 bit unsigned integer representing whether the operation was successful and the index for a subsequent blocking query.
§Errors:
ConsulError describes all possible errors returned by this api.
sourcepub async fn delete_key(
&self,
request: DeleteKeyRequest<'_>
) -> Result<bool, ConsulError>
pub async fn delete_key( &self, request: DeleteKeyRequest<'_> ) -> Result<bool, ConsulError>
Deletes a key from Consul’s KV store. See the consul docs for more information.
§Arguments:
- request - the DeleteKeyRequest
§Errors:
ConsulError describes all possible errors returned by this api.
sourcepub async fn get_lock(
&self,
request: LockRequest<'_>,
value: &[u8]
) -> Result<Lock<'_>, ConsulError>
pub async fn get_lock( &self, request: LockRequest<'_>, value: &[u8] ) -> Result<Lock<'_>, ConsulError>
Obtains a lock against a specific key in consul. See the consul docs for more information.
§Arguments:
- request - the LockRequest
§Errors:
ConsulError describes all possible errors returned by this api.
sourcepub async fn watch_lock<'a>(
&self,
request: LockWatchRequest<'_>
) -> Result<Vec<ReadKeyResponse>, ConsulError>
pub async fn watch_lock<'a>( &self, request: LockWatchRequest<'_> ) -> Result<Vec<ReadKeyResponse>, ConsulError>
Watches lock against a specific key in consul. See the consul docs for more information.
§Arguments:
- request - the LockWatchRequest
§Errors:
ConsulError describes all possible errors returned by this api.
sourcepub async fn register_entity(
&self,
payload: &RegisterEntityPayload
) -> Result<(), ConsulError>
pub async fn register_entity( &self, payload: &RegisterEntityPayload ) -> Result<(), ConsulError>
Registers or updates entries in consul’s global catalog. See https://www.consul.io/api-docs/catalog#register-entity for more information.
§Arguments:
- payload: The
RegisterEntityPayload
to provide the register entity API.
§Errors:
ConsulError describes all possible errors returned by this api.
sourcepub async fn deregister_entity(
&self,
payload: &DeregisterEntityPayload
) -> Result<(), ConsulError>
pub async fn deregister_entity( &self, payload: &DeregisterEntityPayload ) -> Result<(), ConsulError>
Removes entries from consul’s global catalog. See https://www.consul.io/api-docs/catalog#deregister-entity for more information.
§Arguments:
- payload: The
DeregisterEntityPayload
to provide the register entity API.
§Errors:
ConsulError describes all possible errors returned by this api.
sourcepub async fn get_all_registered_service_names(
&self,
query_opts: Option<QueryOptions>
) -> Result<ResponseMeta<Vec<String>>, ConsulError>
pub async fn get_all_registered_service_names( &self, query_opts: Option<QueryOptions> ) -> Result<ResponseMeta<Vec<String>>, ConsulError>
Returns all services currently registered with consul. See https://www.consul.io/api-docs/catalog#list-services for more information.
§Arguments:
- query_opts: The
QueryOptions
to apply for this endpoint.
§Errors:
ConsulError describes all possible errors returned by this api.
sourcepub async fn get_service_nodes(
&self,
request: GetServiceNodesRequest<'_>,
query_opts: Option<QueryOptions>
) -> Result<ResponseMeta<Vec<ServiceNode>>, ConsulError>
pub async fn get_service_nodes( &self, request: GetServiceNodesRequest<'_>, query_opts: Option<QueryOptions> ) -> Result<ResponseMeta<Vec<ServiceNode>>, ConsulError>
returns the nodes providing the service indicated on the path. Users can also build in support for dynamic load balancing and other features by incorporating the use of health checks. See the consul docs for more information.
§Arguments:
- request - the GetServiceNodesRequest
§Errors:
ConsulError describes all possible errors returned by this api.
sourcepub async fn get_service_addresses_and_ports(
&self,
service_name: &str,
query_opts: Option<QueryOptions>
) -> Result<Vec<(String, u16)>, ConsulError>
pub async fn get_service_addresses_and_ports( &self, service_name: &str, query_opts: Option<QueryOptions> ) -> Result<Vec<(String, u16)>, ConsulError>
Queries consul for a service and returns the Address:Port of all instances registered for that service.