Skip to content

Commit 4e73164

Browse files
authored
refactor: Replace debug commands with describe commands (#168)
1 parent b129133 commit 4e73164

File tree

10 files changed

+170
-148
lines changed

10 files changed

+170
-148
lines changed

Cargo.lock

+6-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ default-members = [
1919
exclude = ["raft-rs", "raftify-cli"]
2020

2121
[workspace.package]
22-
version = "0.1.81"
22+
version = "0.1.82"
2323
authors = ["Lablup Inc."]
2424
edition = "2021"
2525
description = "Experimental High level Raft framework"

README.md

+49-11
Original file line numberDiff line numberDiff line change
@@ -184,17 +184,55 @@ raft.propose(LogEntry::Insert {
184184
You can use a collection of CLI commands that let you inspect the data persisted in stable storage and the status of Raft Servers.
185185

186186
```
187-
❯ raftify-cli debug persisted ./logs/node-1
188-
---- Persisted entries ----
189-
Key: 1, "Entry { context: [], data: [], entry_type: EntryNormal, index: 1, sync_log: false, term: 1 }"
190-
Key: 2, "Entry { context: [], data: ConfChange { change_type: AddNode, node_id: 2, context: [127.0.0.1:60062], id: 0 }, entry_type: EntryConfChange, index: 2, sync_log: false, term: 1 }"
191-
Key: 3, "Entry { context: [], data: ConfChange { change_type: AddNode, node_id: 3, context: [127.0.0.1:60063], id: 0 }, entry_type: EntryConfChange, index: 3, sync_log: false, term: 1 }"
192-
193-
---- Metadata ----
194-
HardState { term: 1, vote: 1, commit: 3 }
195-
ConfState { voters: [1, 2, 3], learners: [], voters_outgoing: [], learners_next: [], auto_leave: false }
196-
Snapshot { data: HashStore(RwLock { data: {}, poisoned: false, .. }), metadata: Some(SnapshotMetadata { conf_state: Some(ConfState { voters: [1, 2, 3], learners: [], voters_outgoing: [], learners_next: [], auto_leave: false }), index: 1, term: 1 }) }
197-
Last index: 3
187+
❯ raftify-cli describe logs ./logs/node-1
188+
┌───────┬────────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┬──────┐
189+
│ index ┆ type ┆ data ┆ term │
190+
╞═══════╪════════════╪══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╪══════╡
191+
│ 2 ┆ ConfChange ┆ ConfChangeV2 { transition: 0, changes: [ConfChangeSingle { change_type: AddNode, node_id: 2 }], context: [127.0.0.1:60062] } ┆ 1 │
192+
├╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌┤
193+
│ 3 ┆ ConfChange ┆ ConfChangeV2 { transition: 0, changes: [ConfChangeSingle { change_type: AddNode, node_id: 3 }], context: [127.0.0.1:60063] } ┆ 1 │
194+
└───────┴────────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┴──────┘
195+
```
196+
197+
```
198+
❯ raftify-cli describe metadata ./logs/node-1
199+
┌───────────┬─────────────────────────────────────┬──────────────────────────┐
200+
│ ┆ Field ┆ Value │
201+
╞═══════════╪═════════════════════════════════════╪══════════════════════════╡
202+
│ HardState ┆ term ┆ 1 │
203+
├╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
204+
│ ┆ vote ┆ 1 │
205+
├╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
206+
│ ┆ commit ┆ 3 │
207+
├╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
208+
│ ConfState ┆ voters ┆ {1, 2, 3} │
209+
├╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
210+
│ ┆ learners ┆ {} │
211+
├╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
212+
│ ┆ voters_outgoing ┆ {} │
213+
├╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
214+
│ ┆ learners_next ┆ {} │
215+
├╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
216+
│ ┆ auto_leave ┆ false │
217+
├╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
218+
│ Snapshot ┆ data ┆ [0, 0, 0, 0, 0, 0, 0, 0] │
219+
├╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
220+
│ ┆ metadata.index ┆ 3 │
221+
├╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
222+
│ ┆ metadata.term ┆ 1 │
223+
├╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
224+
│ ┆ metadata.conf_state.voters ┆ {1, 2, 3} │
225+
├╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
226+
│ ┆ metadata.conf_state.learners ┆ {} │
227+
├╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
228+
│ ┆ metadata.conf_state.voters_outgoing ┆ {} │
229+
├╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
230+
│ ┆ metadata.conf_state.learners_next ┆ {} │
231+
├╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
232+
│ ┆ metadata.conf_state.auto_leave ┆ false │
233+
├╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
234+
│ LastIndex ┆ last index ┆ 3 │
235+
└───────────┴─────────────────────────────────────┴──────────────────────────┘
198236
```
199237

200238
## Bootstrapping from WAL

examples/memstore/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ serde = { version = "1.0", features = ["derive"] }
2626
serde_json = "1.0"
2727
tokio = { version = "1.40", features = ["full"] }
2828
color-backtrace = "0.6.1"
29-
raftify = { version = "0.1.81" }
30-
raftify_cli = { version = "0.1.81" }
29+
raftify = { version = "0.1.82" }
30+
raftify_cli = { version = "0.1.82" }
3131

3232
[features]
3333
default = ["heed_storage"]

raftify-cli/Cargo.lock

+22-17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

raftify-cli/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ serde_json = "1.0"
1313
slog = "2"
1414
built = "0.5"
1515
clap = { version = "4.5.18", features = ["derive"] }
16-
raftify = { version = "=0.1.81", features = ["heed_storage", "inmemory_storage", "rocksdb_storage"] }
16+
raftify = { version = "=0.1.82", features = ["heed_storage", "inmemory_storage", "rocksdb_storage"] }
1717
comfy-table = "7.1.1"
1818
cfmt = { version = "0.1.0", package = "const_format" }
1919

raftify-cli/build.rs

+15-4
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,24 @@ use toml::Value;
44

55
fn main() -> Result<(), Box<dyn std::error::Error>> {
66
let path = Path::new("Cargo.toml");
7-
let read = fs::read_to_string(path)
8-
.expect("Failed to read Cargo.toml");
7+
let read = fs::read_to_string(path).expect("Failed to read Cargo.toml");
98
let toml: Value = read.parse::<Value>().expect("Failed to parse Cargo.toml");
109

11-
if let Some(raftify_dep) = toml.get("dependencies").and_then(|deps| deps.get("raftify")) {
10+
if let Some(raftify_dep) = toml
11+
.get("dependencies")
12+
.and_then(|deps| deps.get("raftify"))
13+
{
1214
let version = raftify_dep.get("version").unwrap().as_str().unwrap();
13-
let features = raftify_dep.get("features").unwrap().as_array().unwrap().iter().map(|f| f.as_str().unwrap()).collect::<Vec<_>>().join(", ");
15+
let features = raftify_dep
16+
.get("features")
17+
.unwrap()
18+
.as_array()
19+
.unwrap()
20+
.iter()
21+
.map(|f| f.as_str().unwrap())
22+
.collect::<Vec<_>>()
23+
.join(", ");
24+
1425
println!("cargo:rustc-env=RAFTIFY_VERSION={}", &version[1..]);
1526
println!("cargo:rustc-env=RAFTIFY_FEATURES={}", features);
1627
}

0 commit comments

Comments
 (0)