Struct ns_router::Config
[−]
[src]
pub struct Config { /* fields omitted */ }
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.
Methods
impl Config
[src]
pub fn new() -> Config
[src]
Create a new, empty config
pub fn restart_delay(&mut self, delay: Duration) -> &mut Self
[src]
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.
pub fn convergence_delay(&mut self, delay: Duration) -> &mut Self
[src]
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.
pub fn add_host<A>(&mut self, name: &Name, addr: A) -> &mut Self where
A: Into<IpList>,
[src]
A: Into<IpList>,
Add a host that will be resolved to list of addreses
Hosts added by this host method overrides any other resolvers.
pub fn add_service(&mut self, name: &Name, addr: Address) -> &mut Self
[src]
Add a service that will be resolved to an Address object
Service names added by this host method overrides any other resolvers.
pub fn add_suffix<S, R>(&mut self, suffix: S, resolver: R) -> &mut Self where
S: Into<String>,
R: Resolve + HostResolve + Subscribe + HostSubscribe,
R: Debug + 'static,
[src]
S: Into<String>,
R: Resolve + HostResolve + Subscribe + HostSubscribe,
R: 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.
pub fn remove_suffix<S>(&mut self, suffix: &str) -> &mut Self
[src]
Removes already configured suffix
pub fn set_fallthrough<R>(&mut self, resolver: R) -> &mut Self where
R: Resolve + HostResolve + Subscribe + HostSubscribe,
R: Debug + 'static,
[src]
R: Resolve + HostResolve + Subscribe + HostSubscribe,
R: Debug + 'static,
Adds a host resolver used whenever no suffix matches
pub fn done(&self) -> Arc<Config>
[src]
A convenience method that returns Arc'd config
Trait Implementations
impl Clone for Config
[src]
fn clone(&self) -> Config
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more