1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
use std::ops::RangeInclusive;
use backoff_series::ParseError as BackoffParseError;
use openraft_macros::since;
use crate::impls::BoxedErrorSource;
/// Error variants related to configuration.
#[since]
#[since(version = "0.10.2", change = "added zero heartbeat interval error")]
#[since(version = "0.10.2", change = "added zero snapshot log threshold error")]
#[since(version = "0.10.2", change = "added zero snapshot chunk size error")]
#[since(
version = "0.10.2",
change = "added an error for a channel size the runtime does not accept"
)]
#[since(version = "0.10.2", change = "added an error for a value too large for the target")]
#[since(version = "0.10.2", change = "added zero log-stage capacity error")]
#[since(version = "0.10.0", change = "added quorum-loss inactivity validation error")]
#[derive(Debug, thiserror::Error)]
#[derive(PartialEq, Eq)]
pub enum ConfigError {
/// Failed to parse configuration from command-line arguments.
#[since(version = "0.10.0", change = "`source` from `AnyError` to `BoxedErrorSource`")]
#[error("ParseError: {source} while parsing ({args:?})")]
ParseError {
/// The underlying parse error.
source: BoxedErrorSource,
/// The arguments that failed to parse.
args: Vec<String>,
},
/// The min election timeout is not smaller than the max election timeout.
#[error("election timeout: min({min}) must be < max({max})")]
ElectionTimeout {
/// Minimum election timeout value.
min: u64,
/// Maximum election timeout value.
max: u64,
},
/// The `max_payload_entries` configuration must be greater than 0.
#[error("max_payload_entries must be > 0")]
MaxPayloadIs0,
/// The threshold of [`SnapshotPolicy::LogsSinceLast`](crate::SnapshotPolicy::LogsSinceLast)
/// must be greater than 0.
#[since(version = "0.10.2")]
#[error("snapshot_policy LogsSinceLast threshold must be > 0; use Never to disable automatic snapshots")]
SnapshotLogsSinceLastIs0,
/// The `snapshot_max_chunk_size` configuration must be greater than 0.
#[since(version = "0.10.2")]
#[error("snapshot_max_chunk_size must be > 0")]
SnapshotMaxChunkSizeIs0,
/// The `log_stage_capacity` configuration must be greater than 0.
#[since(version = "0.10.2")]
#[error("log_stage_capacity must be > 0")]
LogStageCapacityIs0,
/// A setting is larger than this target can hold, such as a size that does not fit in
/// `usize` on a 32-bit target.
#[since(version = "0.10.2")]
#[error("{field}({value}) must be <= {max} on this target")]
TooLarge {
/// The name of the setting.
field: &'static str,
/// The configured value.
value: u64,
/// The largest value this target accepts for the setting.
max: u64,
},
/// A channel size is outside the sizes that the runtime's channels accept, as given by
/// [`Mpsc::buffer_size_range()`](crate::async_runtime::Mpsc::buffer_size_range).
#[since(version = "0.10.2")]
#[error("{field}({size}) must be in {accepted:?}, the sizes the runtime's channels accept")]
ChannelSizeOutOfRange {
/// The name of the channel size setting.
field: &'static str,
/// The channel size that the runtime would build.
size: usize,
/// The sizes that the runtime's channels accept.
accepted: RangeInclusive<usize>,
},
/// Election timeout must be greater than heartbeat interval.
#[error("election_timeout_min({election_timeout_min}) must be > heartbeat_interval({heartbeat_interval})")]
ElectionTimeoutLTHeartBeat {
/// Minimum election timeout value.
election_timeout_min: u64,
/// Heartbeat interval value.
heartbeat_interval: u64,
},
/// The `heartbeat_interval` configuration must be greater than 0.
#[since(version = "0.10.2")]
#[error("heartbeat_interval must be > 0; use enable_heartbeat to turn heartbeats off")]
HeartbeatIntervalIs0,
/// Heartbeat suppression must not delay a heartbeat past a follower's election timeout.
#[since(version = "0.10.1", change = "the bound no longer adds a tick interval")]
#[since(version = "0.10.0")]
#[error(
"heartbeat_interval({heartbeat_interval}) + heartbeat_min_interval({heartbeat_min_interval}) must be < election_timeout_min({election_timeout_min})"
)]
HeartbeatMinIntervalTooLarge {
/// Minimum election timeout value.
election_timeout_min: u64,
/// Heartbeat interval value.
heartbeat_interval: u64,
/// Minimum interval between two heartbeats to the same follower.
heartbeat_min_interval: u64,
},
/// The probe interval must leave time for follower lease expiry and an election.
#[since(version = "0.10.0", change = "added quorum-loss inactivity validation")]
#[error(
"quorum_loss_probe_interval({probe_interval}) must be >= leader_lease({election_timeout_max}) + election_timeout_max({election_timeout_max})"
)]
QuorumLossProbeIntervalTooSmall {
/// Maximum election timeout in milliseconds.
election_timeout_max: u64,
/// Configured heartbeat phase interval in milliseconds.
probe_interval: u64,
},
/// Invalid snapshot policy string format.
#[error("snapshot policy string is invalid: '{invalid:?}' expect: '{syntax}'")]
InvalidSnapshotPolicy {
/// The invalid policy string provided.
invalid: String,
/// The expected syntax format.
syntax: String,
},
/// Failed to parse a number from string.
#[error("{reason} when parsing {invalid:?}")]
InvalidNumber {
/// The invalid number string.
invalid: String,
/// The reason for the parse failure.
reason: String,
},
/// Invalid backoff policy string.
///
/// See [`backoff_series::BackoffSeries::parse`] for the expected format.
#[since(version = "0.10.0")]
#[error(transparent)]
InvalidBackoff(#[from] BackoffParseError),
}