-
Notifications
You must be signed in to change notification settings - Fork 157
/
mod.rs
52 lines (46 loc) · 1.63 KB
/
mod.rs
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
//! Raft metrics for observability.
//!
//! Applications may use this data in whatever way is needed. The obvious use cases are to expose
//! these metrics to a metrics collection system like Prometheus. Applications may also
//! use this data to trigger events within higher levels of the parent application.
//!
//! Metrics are observed on a running Raft node via the [`Raft::metrics() ->
//! watch::Receiver<RaftMetrics>`](`crate::Raft::metrics`) method, which will return a stream of
//! metrics.
//!
//!
//! ## [`RaftMetrics`]
//!
//! [`RaftMetrics`] contains useful information such as:
//!
//! - Server state(leader/follower/learner/candidate) of this raft node,
//! - The current leader,
//! - Last log and applied log.
//! - Replication state, if this node is a Leader,
//! - Snapshot state,
//! - etc.
//!
//! Metrics can be used as a trigger of application events, as a monitoring data
//! source, etc.
//!
//! Metrics is not a stream thus it only guarantees to provide the latest state but
//! not every change of the state.
//! Because internally, `watch::channel()` only stores one last state.
mod metric;
mod raft_metrics;
mod wait;
mod metric_display;
mod wait_condition;
#[cfg(test)] mod wait_test;
use std::collections::BTreeMap;
pub use metric::Metric;
pub use raft_metrics::is_data_metrics_changed;
pub use raft_metrics::is_server_metrics_changed;
pub use raft_metrics::RaftDataMetrics;
pub use raft_metrics::RaftMetrics;
pub use raft_metrics::RaftServerMetrics;
pub use wait::Wait;
pub use wait::WaitError;
pub(crate) use wait_condition::Condition;
use crate::LogId;
pub(crate) type ReplicationMetrics<NID> = BTreeMap<NID, Option<LogId<NID>>>;