Struct Consul

Source
pub struct Consul { /* private fields */ }
Expand description

Client used to talk to a Consul server. All calls to the key/value API are automatically prefixed with an arbitrary string that is constructed at client creation.

Implementations§

Source§

impl Consul

Source

pub async fn catalog_node_list( &self, last_index: Option<usize>, ) -> Result<WithIndex<Vec<Node>>>

The “list nodes” API call of the Catalog API

https://developer.hashicorp.com/consul/api-docs/catalog#list-nodes

Source

pub async fn catalog_node( &self, host: &str, last_index: Option<usize>, ) -> Result<WithIndex<Option<CatalogNode>>>

The “retrieve map of services for a node” API call of the Catalog API

https://developer.hashicorp.com/consul/api-docs/catalog#retrieve-map-of-services-for-a-node

Source

pub async fn catalog_service_list( &self, last_index: Option<usize>, ) -> Result<WithIndex<ServiceList>>

The “list services” API call of the Catalog api

https://developer.hashicorp.com/consul/api-docs/catalog#list-services

Source

pub async fn catalog_service_nodes( &self, service: &str, last_index: Option<usize>, ) -> Result<WithIndex<Vec<ServiceNode>>>

The “list nodes for a service” API call of the Catalog api

https://developer.hashicorp.com/consul/api-docs/catalog#list-nodes-for-service

Source

pub async fn health_service_instances( &self, service: &str, last_index: Option<usize>, ) -> Result<WithIndex<Vec<HealthServiceNode>>>

The “list service instances for a service” API call of the Health api

https://developer.hashicorp.com/consul/api-docs/health#list-service-instances-for-service

Source

pub fn watch_all_service_health( &self, max_retry_interval: Duration, ) -> Receiver<AllServiceHealth>

Launches a background task that watches all services and the nodes that serve them, and make that info available in a tokio watch channel. The worker terminates when the channel is dropped.

Source§

impl Consul

Source

pub async fn kv_get(&self, key: &str) -> Result<Option<Bytes>>

Source

pub async fn kv_get_json<T: for<'de> Deserialize<'de>>( &self, key: &str, ) -> Result<Option<T>>

Source

pub async fn kv_get_prefix( &self, key_prefix: &str, last_index: Option<usize>, ) -> Result<WithIndex<HashMap<String, Bytes>>>

Source

pub async fn kv_put(&self, key: &str, bytes: Bytes) -> Result<()>

Source

pub async fn kv_put_json<T: Serialize>( &self, key: &str, value: &T, ) -> Result<()>

Source

pub async fn kv_delete(&self, key: &str) -> Result<()>

Source§

impl Consul

Source

pub async fn create_session(&self, req: &SessionRequest) -> Result<String>

Source

pub async fn acquire( &self, key: &str, bytes: Bytes, session: &str, ) -> Result<bool>

Source

pub async fn release( &self, key: &str, bytes: Bytes, session: &str, ) -> Result<()>

Source§

impl Consul

Source

pub fn new(config: Config, kv_prefix: &str) -> Result<Self>

Trait Implementations§

Source§

impl Clone for Consul

Source§

fn clone(&self) -> Consul

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

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>,

Source§

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
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T