Skip to content

Commit

Permalink
raft: add example in Log documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
erikgrinaker committed May 31, 2024
1 parent f80d0ab commit 191a8a6
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/raft/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,16 @@ impl encoding::Key<'_> for KeyPrefix {}
/// are replicated across nodes and applied sequentially to the local state
/// machine. Each entry contains an index, command, and the term in which the
/// leader proposed it. Commands may be noops (None), which are added when a
/// leader is elected (see section 5.4.2 in the Raft paper).
/// leader is elected (see section 5.4.2 in the Raft paper). For example:
///
/// Index | Term | Command
/// ------|------|------------------------------------------------------
/// 1 | 1 | None
/// 2 | 1 | CREATE TABLE table (id INT PRIMARY KEY, value STRING)
/// 3 | 1 | INSERT INTO table VALUES (1, 'foo')
/// 4 | 2 | None
/// 5 | 2 | UPDATE table SET value = 'bar' WHERE id = 1
/// 6 | 2 | DELETE FROM table WHERE id = 1
///
/// A key/value store is used to store the log entries on disk, keyed by index,
/// along with a few other metadata keys (e.g. who we voted for in this term).
Expand Down

0 comments on commit 191a8a6

Please sign in to comment.