[][src]Module raft::storage

Represents the storage trait and example implementation.

The storage trait is used to house and eventually serialize the state of the system. Custom implementations of this are normal and this is likely to be a key integration point for your distributed storage.

Structs

MemStorage

MemStorage is a thread-safe implementation of Storage trait. It is mainly used for test purpose.

MemStorageCore

The Memory Storage Core instance holds the actual state of the storage struct. To access this value, use the rl and wl functions on the main MemStorage implementation.

RaftState

Holds both the hard state (commit index, vote leader, term) and the configuration state (Current node IDs)

Traits

Storage

Storage saves all the information about the current Raft implementation, including Raft Log, commit index, the leader to vote for, etc. Pay attention to what is returned when there is no Log but it needs to get the term at index first_index() - 1. To solve this, you can use a dummy Log entry to keep the last truncated Log entry. See entries: vec![Entry::new()] as a reference.