Struct Config

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

Configuration of the router

It has a builder interface. You can create a router from Arc<Config> (made by Config::done) or a stream of configs.

Implementations§

Source§

impl Config

Source

pub fn new() -> Config

Create a new, empty config

Source

pub fn restart_delay(&mut self, delay: Duration) -> &mut Self

Sets delay after which router will restart any subscription stream

This works both when stream yields end-of-stream and when stream has returned error. Default value is 100 milliseconds.

Source

pub fn convergence_delay(&mut self, delay: Duration) -> &mut Self

Sets delay used by subscribe_many family of functions

The timeout is set when a new set of names arrives via stream or when configuration is updated. While the timer is active we don’t send name updates to the application unless all (new) names are resolved.

Good value is bigger than 90 or 99 percentile of name request latency, but small enough that delay of this long doesn’t introduce any hiccups on the application.

For example, if there are names [A, B, C] if C is resolved first we wait for the 100 millisecond (by default) timer to finish to let A and B also be resolved. If they aren’t within the period only names in C are returned.

Note if names are reloved later, they are added to the address set and update is delivered to the client. I.e. it’s only important something depends on the first address value.

The case where it’s important is following: Client establishes few persistent connections by picking random IP Addresses from the set. Once new addresses arrive connections are still hold until one of them is broken. In this case, the first address (or the one that can be resolved faster for any reason) would have more connections received in most cases which might be a problem.

Source

pub fn add_host<A>(&mut self, name: &Name, addr: A) -> &mut Self
where A: Into<IpList>,

Add a host that will be resolved to list of addreses

Hosts added by this host method overrides any other resolvers.

Source

pub fn add_service(&mut self, name: &Name, addr: Address) -> &mut Self

Add a service that will be resolved to an Address object

Service names added by this host method overrides any other resolvers.

Source

pub fn add_suffix<S, R>(&mut self, suffix: S, resolver: R) -> &mut Self
where S: Into<String>, R: Resolve + HostResolve + Subscribe + HostSubscribe + Debug + 'static,

Add a resolver for suffix

Note: you must supply a full resolver here, use null_resolver/null_host_resolver and interval_subscribe or frozen_subscriber and other combinators to fullfill needed type.

Source

pub fn remove_suffix<S>(&mut self, suffix: &str) -> &mut Self

Removes already configured suffix

Source

pub fn set_fallthrough<R>(&mut self, resolver: R) -> &mut Self
where R: Resolve + HostResolve + Subscribe + HostSubscribe + Debug + 'static,

Adds a host resolver used whenever no suffix matches

Source

pub fn done(&self) -> Arc<Config>

A convenience method that returns Arc’d config

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Config

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

impl Debug for Config

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Config

§

impl !RefUnwindSafe for Config

§

impl !Send for Config

§

impl !Sync for Config

§

impl Unpin for Config

§

impl !UnwindSafe for Config

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