pub struct Config {
pub probe_period: Duration,
pub probe_rtt: Duration,
pub num_indirect_probes: NonZeroUsize,
pub max_transmissions: NonZeroU8,
pub suspect_to_down_after: Duration,
pub remove_down_after: Duration,
pub max_packet_size: NonZeroUsize,
}Expand description
A Config specifies the parameters Foca will use for the SWIM protocol.
Fields
probe_period: DurationSpecifies how often a random member will be probed for activity.
At the end of this period, if the member didn’t reply (directly
or indirectly, see crate::Message) it’s declared
crate::State::Suspect.
Should be strictly larger than Self::probe_rtt. Preferably more
than twice its value since we need to wait for the indirect ping cycle.
If unsure, err on the safe side with probe_rtt * 3 and tune
later.
Must not be zero.
probe_rtt: DurationHow long to wait for a direct reply to a probe before starting the indirect probing cycle.
It should be set to a value that describes well your transport
round-trip time. A reasonable value would be a high quantile
(p99, for example) of your cluster-wide ICMP PING RTT.
Must be strictly smaller than Self::probe_period.
Must not be zero.
num_indirect_probes: NonZeroUsizeHow many members will be asked to perform an indirect ping in case the probed member takes too long to reply.
This doesn’t need to be a large number: we’re essentially fanning out to ensure a message actually reaches the original ping target in case of poor transmission quality or weird partitions.
Setting this to 3-5 should be more than enough for a “modern” network.
max_transmissions: NonZeroU8Specifies how many times a single update/broadcast will be sent along with a normal message.
A high value trades off bandwidth for higher chances of fully disseminating broadcasts throughout the cluster.
Reasonable values range from 5, for small clusters to 15 for very large clusters.
suspect_to_down_after: DurationHow long a Suspect member is considered active before being declared Down.
Here you want to give time for the member to realize it has been declared Suspect and notify the cluster that its actually active.
Higher values give more time for a member to recover from a false suspicion, but slows down detection of a failed state.
Very application-dependent. Smaller clusters likely want
this value to be a small multiplier of Self::probe_period
whereas large clusters can easily tolerate several seconds of
wait.
Must not be zero.
remove_down_after: DurationGoverns how long Foca will remember an identity as being Down.
A high value is recommended to avoid confusing cluster
members with partial joins. If in doubt use a high multiplier
over the probe period, like 10 * probe_period.
max_packet_size: NonZeroUsizeThe maximum packet size Foca will produce AND consume.
This is transport-dependent. The main goal is reducing fragmentation and congestion.
If using UDP as a transport, use rfc8085 guidelines and stick
to a value smaller than your network’s MTU. 1400 is a good
value for a in a non-ancient network.
Implementations
sourceimpl Config
impl Config
sourcepub fn new_lan(cluster_size: NonZeroU32) -> Self
pub fn new_lan(cluster_size: NonZeroU32) -> Self
Generate a configuration for a LAN cluster given an expected total number of active members.
The cluster_size parameter is used to define how many times updates
are disseminated (Config::max_transmissions) and how long Foca
will wait before declaring a suspected member as down
(Config::suspect_to_down_after).
Settings derived from memberlist’s DefaultLanConfig.
sourcepub fn new_wan(cluster_size: NonZeroU32) -> Self
pub fn new_wan(cluster_size: NonZeroU32) -> Self
Generate a configuration for a WAN cluster given an expected total number of active members.
Settings derived from memberlist’s DefaultWanConfig.
See Config::new_lan.
Trait Implementations
sourceimpl<'de> Deserialize<'de> for Config
impl<'de> Deserialize<'de> for Config
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnwindSafe for Config
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more