From a00de24071f528c9f41845b16b46280ebf0bd477 Mon Sep 17 00:00:00 2001 From: Gyubong Date: Fri, 27 Sep 2024 17:58:38 +0900 Subject: [PATCH] WIP --- Cargo.lock | 140 ++++++++++++++++++++++++- Cargo.toml | 1 + examples/memstore/Cargo.toml | 4 +- examples/memstore/src/cli/main.rs | 5 +- examples/memstore/src/state_machine.rs | 3 - raftify-cli/Cargo.lock | 2 +- raftify-cli/Cargo.toml | 2 +- raftify-cli/src/commands/debug.rs | 4 +- 8 files changed, 147 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 481147ed..4169d19a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -262,6 +262,55 @@ dependencies = [ "winapi", ] +[[package]] +name = "anstream" +version = "0.6.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1" + +[[package]] +name = "anstyle-parse" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb47de1e80c2b463c735db5b217a0ddc39d612e7ac9e2e96a5aed1f57616c1cb" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a" +dependencies = [ + "windows-sys 0.52.0", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8" +dependencies = [ + "anstyle", + "windows-sys 0.52.0", +] + [[package]] name = "anyhow" version = "1.0.87" @@ -525,12 +574,52 @@ dependencies = [ "ansi_term", "atty", "bitflags 1.3.2", - "strsim", + "strsim 0.8.0", "textwrap", "unicode-width", "vec_map", ] +[[package]] +name = "clap" +version = "4.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0956a43b323ac1afaffc053ed5c4b7c1f1800bacd1683c353aabbb752515dd3" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d72166dd41634086d5803a47eb71ae740e61d84709c36f3c34110173db3961b" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim 0.11.1", +] + +[[package]] +name = "clap_derive" +version = "4.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab" +dependencies = [ + "heck 0.5.0", + "proc-macro2", + "quote", + "syn 2.0.77", +] + +[[package]] +name = "clap_lex" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" + [[package]] name = "color-backtrace" version = "0.6.1" @@ -541,6 +630,12 @@ dependencies = [ "termcolor", ] +[[package]] +name = "colorchoice" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" + [[package]] name = "const_format" version = "0.2.33" @@ -977,6 +1072,12 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + [[package]] name = "heed" version = "0.20.5" @@ -1185,6 +1286,12 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "is_terminal_polyfill" +version = "1.70.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" + [[package]] name = "itertools" version = "0.10.5" @@ -1361,6 +1468,7 @@ dependencies = [ "color-backtrace", "log", "raftify", + "raftify_cli", "serde", "serde_json", "tokio", @@ -1797,6 +1905,22 @@ dependencies = [ "tonic-build", ] +[[package]] +name = "raftify_cli" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89fca418beb04ff1d175598c386db1d8bc40b20b0f2a1e645fe9d5bb0789a7d6" +dependencies = [ + "built", + "clap 4.5.18", + "log", + "raftify", + "serde", + "serde_json", + "slog", + "tonic-build", +] + [[package]] name = "rand" version = "0.8.5" @@ -2121,13 +2245,19 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + [[package]] name = "structopt" version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c6b5c64445ba8094a6ab0c3cd2ad323e07171012d9c98b0b15651daf1787a10" dependencies = [ - "clap", + "clap 2.34.0", "lazy_static", "structopt-derive", ] @@ -2579,6 +2709,12 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + [[package]] name = "vec_map" version = "0.8.2" diff --git a/Cargo.toml b/Cargo.toml index a415dc18..d099eaed 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,3 +36,4 @@ memstore-example-harness = { path = "examples/memstore" } [patch.crates-io] jopemachine-raft = { path = "./raft-rs" } +raftify = { path = "./raftify" } diff --git a/examples/memstore/Cargo.toml b/examples/memstore/Cargo.toml index 40af1cc3..8daf2057 100644 --- a/examples/memstore/Cargo.toml +++ b/examples/memstore/Cargo.toml @@ -17,8 +17,6 @@ name = "raftify-client-example" path = "src/client/main.rs" [dependencies] -raftify.workspace = true - actix-rt = "2.10" actix-web = "4.9.0" async-trait = "0.1.82" @@ -28,6 +26,8 @@ serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" tokio = { version = "1.40", features = ["full"] } color-backtrace = "0.6.1" +raftify = { version = "0.1.78" } +raftify_cli = { version = "0.1.1" } [features] default = ["heed_storage"] diff --git a/examples/memstore/src/cli/main.rs b/examples/memstore/src/cli/main.rs index 50bf79bb..deef0b41 100644 --- a/examples/memstore/src/cli/main.rs +++ b/examples/memstore/src/cli/main.rs @@ -1,11 +1,10 @@ -// use raftify::{cli::cli_handler, Result}; use raftify::Result; +use raftify_cli::cli_handler; use memstore_example_harness::state_machine::{HashStore, LogEntry, StorageType}; #[tokio::main] async fn main() -> Result<()> { - // cli_handler::(None).await?; - + cli_handler::(None).await?; Ok(()) } diff --git a/examples/memstore/src/state_machine.rs b/examples/memstore/src/state_machine.rs index 05928b10..3f78c34c 100644 --- a/examples/memstore/src/state_machine.rs +++ b/examples/memstore/src/state_machine.rs @@ -7,9 +7,6 @@ use std::{ sync::{Arc, RwLock}, }; -#[cfg(feature = "inmemory_storage")] -pub use raftify::MemStorage as StorageType; - #[cfg(feature = "heed_storage")] pub use raftify::HeedStorage as StorageType; diff --git a/raftify-cli/Cargo.lock b/raftify-cli/Cargo.lock index 4402bdca..c682b77f 100644 --- a/raftify-cli/Cargo.lock +++ b/raftify-cli/Cargo.lock @@ -1237,7 +1237,7 @@ dependencies = [ [[package]] name = "raftify_cli" -version = "0.1.0" +version = "0.1.1" dependencies = [ "built", "clap", diff --git a/raftify-cli/Cargo.toml b/raftify-cli/Cargo.toml index 0c3394d4..9cae6bc1 100644 --- a/raftify-cli/Cargo.toml +++ b/raftify-cli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "raftify_cli" -version = "0.1.0" +version = "0.1.1" edition = "2021" description = "Raftify CLI tool" license = "MIT/Apache-2.0" diff --git a/raftify-cli/src/commands/debug.rs b/raftify-cli/src/commands/debug.rs index f307ec6d..b8b422b3 100644 --- a/raftify-cli/src/commands/debug.rs +++ b/raftify-cli/src/commands/debug.rs @@ -11,10 +11,9 @@ use raftify::{ }, raft_node::utils::format_debugging_info, raft_service, Config, Result, StableStorage, + HeedStorage, StorageType, }; -use raftify::{HeedStorage, StorageType}; - pub fn debug_persisted(path: &str, logger: slog::Logger) -> Result<()> { let config = Config { log_dir: path.to_string(), @@ -80,6 +79,7 @@ pub fn debug_persisted_all( dir_entries.sort(); for name in dir_entries { + println!("*----- {name} -----*"); debug_persisted::(&format!("{}/{}", path_str, name), logger.clone())?; println!(); }