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
use std::sync::Arc;
use crate::state::{EventOf, LogEntryOf};
use crate::{NodeStatus, RoundNum, State};
#[non_exhaustive]
#[derive(Clone, Debug)]
pub enum Event<S: State, R: RoundNum> {
Init {
status: NodeStatus,
state: Option<Arc<S>>,
},
StatusChange {
old_status: NodeStatus,
new_status: NodeStatus,
},
/// A snapshot was installed.
Install { round: R, state: Arc<S> },
/// An entry has been committed to the log.
///
/// The event does not imply that the entry was applied to the shared state.
Commit {
/// The round for which `log_entry` was committed.
round: R,
/// The log entry which was committed.
log_entry: Arc<LogEntryOf<S>>,
},
/// The next log entry was applied to the state.
Apply {
round: R,
log_entry: Arc<LogEntryOf<S>>,
result: EventOf<S>,
},
/// A log entry was queued, preceeding entries are still missing.
///
/// Note: This event is emitted even when the queued entry is within the
/// concurrency bound or if this node created the gap itself. The second
/// case can arise when the leader tries to concurrently append multiple
/// entries and abandons some of the earlier appends.
Gaps(Vec<Gap<R>>),
}
#[derive(Clone, Debug)]
pub struct Gap<R: RoundNum> {
/// The point in time when the gap appeared.
pub since: std::time::Instant,
/// The locations of the gap within the log.
pub rounds: std::ops::Range<R>,
}
#[derive(Clone, Debug)]
pub enum ShutdownEvent<S: State, R: RoundNum> {
Regular(Event<S, R>),
#[non_exhaustive]
Last {
state: Option<Arc<S>>,
},
}