Struct openraft::config::Config [−][src]
pub struct Config {
pub cluster_name: String,
pub election_timeout_min: u64,
pub election_timeout_max: u64,
pub heartbeat_interval: u64,
pub install_snapshot_timeout: u64,
pub max_payload_entries: u64,
pub replication_lag_threshold: u64,
pub snapshot_policy: SnapshotPolicy,
pub snapshot_max_chunk_size: u64,
pub max_applied_log_to_keep: u64,
}
Expand description
The runtime configuration for a Raft node.
The default values used by this type should generally work well for Raft clusters which will be running with nodes in multiple datacenter availability zones with low latency between zones. These values should typically be made configurable from the perspective of the application which is being built on top of Raft.
When building the Raft configuration for your application, remember this inequality from the
Raft spec: broadcastTime ≪ electionTimeout ≪ MTBF
.
In this inequality
broadcastTime
is the average time it takes a server to send RPCs in parallel to every server in the cluster and receive their responses;electionTimeout
is the election timeout described in Section 5.2; andMTBF
is the average time between failures for a single server. The broadcast time should be an order of magnitude less than the election timeout so that leaders can reliably send the heartbeat messages required to keep followers from starting elections; given the randomized approach used for election timeouts, this inequality also makes split votes unlikely. The election timeout should be a few orders of magnitude less thanMTBF
so that the system makes steady progress. When the leader crashes, the system will be unavailable for roughly the election timeout; we would like this to represent only a small fraction of overall time.
What does all of this mean? Simply keep your election timeout settings high enough that the performance of your network will not cause election timeouts, but don’t keep it so high that a real leader crash would cause prolonged downtime. See the Raft spec §5.6 for more details.
Fields
cluster_name: String
The application specific name of this Raft cluster
election_timeout_min: u64
The minimum election timeout in milliseconds
election_timeout_max: u64
The maximum election timeout in milliseconds
heartbeat_interval: u64
The heartbeat interval in milliseconds at which leaders will send heartbeats to followers
install_snapshot_timeout: u64
The timeout for sending a snapshot segment, in millisecond
max_payload_entries: u64
The maximum number of entries per payload allowed to be transmitted during replication
If this is too low, it will take longer for the nodes to be brought up to consistency with the rest of the cluster.
replication_lag_threshold: u64
The distance behind in log replication a follower must fall before it is considered lagging
Once a replication stream transition into line-rate state, the target node will be considered safe to join a cluster.
snapshot_policy: SnapshotPolicy
The snapshot policy to use for a Raft node.
snapshot_max_chunk_size: u64
The maximum snapshot chunk size allowed when transmitting snapshots (in bytes)
max_applied_log_to_keep: u64
The maximum number of applied logs to keep before purging
Implementations
Trait Implementations
fn 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
Builds the struct from clap::ArgMatches
. It’s guaranteed to succeed
if matches
originates from an App
generated by StructOpt::clap
called on
the same type, otherwise it must panic. Read more
Builds the struct from the command line arguments (std::env::args_os
).
Calls clap::Error::exit
on failure, printing the error message and aborting the program. Read more
Builds the struct from the command line arguments (std::env::args_os
).
Unlike StructOpt::from_args
, returns clap::Error
on failure instead of aborting the program,
so calling .exit
is up to you. Read more
fn from_iter<I>(iter: I) -> Self where
I: IntoIterator,
<I as IntoIterator>::Item: Into<OsString>,
<I as IntoIterator>::Item: Clone,
fn from_iter<I>(iter: I) -> Self where
I: IntoIterator,
<I as IntoIterator>::Item: Into<OsString>,
<I as IntoIterator>::Item: Clone,
Gets the struct from any iterator such as a Vec
of your making.
Print the error message and quit the program in case of failure. Read more
fn from_iter_safe<I>(iter: I) -> Result<Self, Error> where
I: IntoIterator,
<I as IntoIterator>::Item: Into<OsString>,
<I as IntoIterator>::Item: Clone,
fn from_iter_safe<I>(iter: I) -> Result<Self, Error> where
I: IntoIterator,
<I as IntoIterator>::Item: Into<OsString>,
<I as IntoIterator>::Item: Clone,
Gets the struct from any iterator such as a Vec
of your making. Read more
Auto Trait Implementations
impl RefUnwindSafe for Config
impl UnwindSafe for Config
Blanket Implementations
Mutably borrows from an owned value. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
pub fn vzip(self) -> V
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more