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; and MTBF 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 than MTBF 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

Generate a new random election timeout within the configured min & max.

Validate the state of this config.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Deserialize this value from the given Serde deserializer. Read more

Serialize this value into the given Serde serializer. Read more

Returns clap::App corresponding to the struct.

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

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

Gets the struct from any iterator such as a Vec of your making. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

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