Struct rs_consul::Consul

source ·
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

source

pub fn new(config: Config) -> Self

Creates a new instance of Consul. This is the entry point for this crate. #Arguments:

source

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:
§Errors:

ConsulError describes all possible errors returned by this api.

source

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:
§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.

source

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:
§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.

source

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:
§Errors:

ConsulError describes all possible errors returned by this api.

source

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:
§Errors:

ConsulError describes all possible errors returned by this api.

source

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:
§Errors:

ConsulError describes all possible errors returned by this api.

source

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:
§Errors:

ConsulError describes all possible errors returned by this api.

source

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:
§Errors:

ConsulError describes all possible errors returned by this api.

source

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:
§Errors:

ConsulError describes all possible errors returned by this api.

source

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:
§Errors:

ConsulError describes all possible errors returned by this api.

source

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.

Trait Implementations§

source§

impl Debug for Consul

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Consul

§

impl !RefUnwindSafe for Consul

§

impl Send for Consul

§

impl Sync for Consul

§

impl Unpin for Consul

§

impl !UnwindSafe for Consul

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more