Struct df_consul::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_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 !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 Twhere
    T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · 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 Twhere
    U: From<T>,

const: unstable · 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 Twhere
    T: Clone,

§

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 Twhere
    U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · 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