SrvClient

Struct SrvClient 

Source
pub struct SrvClient<Resolver, Policy: Policy = Affinity> { /* private fields */ }
Expand description

Client for intelligently performing operations on a service located by SRV records.

§Usage

After being created by SrvClient::new or SrvClient::new_with_resolver, operations can be performed on the service pointed to by a SrvClient with the execute and execute_stream methods.

§DNS Resolvers

The resolver used to lookup SRV records is determined by a client’s SrvResolver, and can be set with SrvClient::resolver.

§SRV Target Selection Policies

SRV target selection order is determined by a client’s Policy, and can be set with SrvClient::policy.

Implementations§

Source§

impl<Resolver: Default, Policy: Policy + Default> SrvClient<Resolver, Policy>

Source

pub fn new( srv_name: impl ToString, fallback: Url, allowed_suffixes: Option<Vec<Host>>, ) -> Self

Creates a new client for communicating with services located by srv_name.

Source§

impl<Resolver, Policy: Policy + Default> SrvClient<Resolver, Policy>

Source

pub fn new_with_resolver( srv_name: impl ToString, fallback: Url, allowed_suffixes: Option<Vec<Host>>, resolver: Resolver, ) -> Self

Creates a new client for communicating with services located by srv_name.

Source§

impl<Resolver: SrvResolver, Policy: Policy> SrvClient<Resolver, Policy>

Source

pub async fn get_fresh_uri_candidates( &self, ) -> Result<(Vec<Url>, Instant), Error<Resolver::Error>>

Gets a fresh set of SRV records from a client’s DNS resolver and parses their target/port pairs into URIs, which are returned along with the time they’re valid until–i.e., the time a cache containing these URIs should expire.

Source

pub async fn execute<T, E, Fut>( &self, func: impl FnMut(Url) -> Fut, ) -> Result<T, E>
where E: Error, Fut: Future<Output = Result<T, E>>,

Performs an operation on a client’s SRV targets, producing the first successful result or the last error encountered if every execution of the operation was unsuccessful.

Source§

impl<Resolver, Policy: Policy> SrvClient<Resolver, Policy>

Source

pub fn srv_name(self, srv_name: impl ToString) -> Self

Sets the SRV name of the client.

Source

pub fn resolver<R>(self, resolver: R) -> SrvClient<R, Policy>

Sets the resolver of the client.

Source

pub fn policy<P: Policy>(self, policy: P) -> SrvClient<Resolver, P>

Sets the policy of the client.

Source

pub fn http_scheme(self, http_scheme: Scheme) -> Self

Sets the http scheme of the client.

Source

pub fn path_prefix(self, path_prefix: impl ToString) -> Self

Sets the path prefix of the client.

Trait Implementations§

Source§

impl<Resolver: Debug, Policy: Debug + Policy> Debug for SrvClient<Resolver, Policy>
where Policy::CacheItem: Debug,

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<Resolver, Policy = Affinity> !Freeze for SrvClient<Resolver, Policy>

§

impl<Resolver, Policy> RefUnwindSafe for SrvClient<Resolver, Policy>
where Resolver: RefUnwindSafe, Policy: RefUnwindSafe, <Policy as Policy>::CacheItem: RefUnwindSafe,

§

impl<Resolver, Policy> Send for SrvClient<Resolver, Policy>
where Resolver: Send, Policy: Send, <Policy as Policy>::CacheItem: Sync + Send,

§

impl<Resolver, Policy> Sync for SrvClient<Resolver, Policy>
where Resolver: Sync, Policy: Sync, <Policy as Policy>::CacheItem: Sync + Send,

§

impl<Resolver, Policy> Unpin for SrvClient<Resolver, Policy>
where Resolver: Unpin, Policy: Unpin,

§

impl<Resolver, Policy> UnwindSafe for SrvClient<Resolver, Policy>
where Resolver: UnwindSafe, Policy: UnwindSafe, <Policy as Policy>::CacheItem: RefUnwindSafe,

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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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