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
//! Engine is an abstracted, complete raft consensus algorithm implementation.
//!
//! The internal `state` inside `Engine` contains complete information to run raft, i.e., it is a in
//! memory shadow of the underlying storage state.
//! Every time `Engine` receives an event, such as handle-vote-request, or elect, it updates its
//! internal state and emits several `Command` to let the underlying `Runtime` to take place the
//! state changes, e.g. `AppendInputEntries` or `LeaderCommit`.
//! I.e., `Runtime` is an adaptor connecting raft algorithm and concrete storage/network
//! implementation.
//!
//! ```text
//! Runtime Engine
//! | |
//! Application ------> + ------------> + // event: app-write, change-membership
//! | |
//! Timer ------------> + ------------> + // event: election, heartbeat
//! | |
//! Storage <---------- + <------------ + // cmd: append, truncate, purge, commit
//! | |
//! .------------- + <------------ + // cmd: replicate-log, vote, install-snapshot
//! v | |
//! Network ----------> + ------------> + // event: replication result, vote result
//! | |
//!
//!
//! ------->: event to Engine
//! <-------: command to run
//! ```
pub
pub
pub
pub use Command;
pub use Condition;
pub use Respond;
pub use ValueSender;
pub use CommandKind;
pub use EngineConfig;
pub use Engine;
pub use EngineOutput;
pub use LogIdList;