Skip to content

Commit

Permalink
Chore: bump deps to new version
Browse files Browse the repository at this point in the history
  • Loading branch information
ariesdevil authored and drmingdrmer committed Aug 23, 2024
1 parent 5f5d7e9 commit 49d522f
Show file tree
Hide file tree
Showing 24 changed files with 67 additions and 41 deletions.
17 changes: 12 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version = "0.9.14"
edition = "2021"
authors = [
"Databend Authors <[email protected]>",
"Anthony Dodd <[email protected]>"
"Anthony Dodd <[email protected]>",
]
categories = ["algorithms", "asynchronous", "data-structures"]
description = "Advanced Raft consensus"
Expand All @@ -18,16 +18,16 @@ repository = "https://github.com/datafuselabs/openraft"
anyerror = { version = "0.1.10" }
anyhow = "1.0.63"
async-entry = "0.3.1"
byte-unit = "4.0.12"
byte-unit = "5.1.4"
bytes = "1.0"
chrono = { version = "0.4" }
clap = { version = "4.1.11", features = ["derive", "env"] }
derive_more = { version="0.99.9" }
derive_more = { version = "1.0", features = ["std", "from", "try_into", "display"] }
futures = "0.3"
lazy_static = "1.4.0"
maplit = "1.0.2"
pretty_assertions = "1.0.0"
proc-macro2 = { version = ">=1.0.0,<1.0.80", features = [] }
proc-macro2 = "1.0"
quote = "1.0"
rand = "0.8"
semver = "1.0.14"
Expand All @@ -36,7 +36,14 @@ serde_json = "1.0.57"
syn = "2.0"
tempfile = { version = "3.4.0" }
thiserror = "1.0.49"
tokio = { version="1.8", default-features=false, features=["fs", "io-util", "macros", "rt", "rt-multi-thread", "sync", "time"] }
tokio = { version = "1.22", default-features = false, features = [
"io-util",
"macros",
"rt",
"rt-multi-thread",
"sync",
"time",
] }
tracing = { version = "0.1.40" }
tracing-appender = "0.2.0"
tracing-futures = "0.2.4"
Expand Down
2 changes: 0 additions & 2 deletions examples/raft-kv-memstore-generic-snapshot-data/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ repository = "https://github.com/datafuselabs/openraft"
memstore = { path = "../memstore", features = [] }
openraft = { path = "../../openraft", features = ["serde", "storage-v2", "generic-snapshot-data"] }

clap = { version = "4.1.11", features = ["derive", "env"] }
reqwest = { version = "0.11.9", features = ["json"] }
serde = { version = "1.0.114", features = ["derive"] }
serde_json = "1.0.57"
tokio = { version = "1.0", default-features = false, features = ["sync"] }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::backtrace::Backtrace;
use std::collections::BTreeMap;
#[allow(deprecated)]
use std::panic::PanicInfo;
use std::time::Duration;

Expand All @@ -12,6 +13,7 @@ use tokio::task;
use tokio::task::LocalSet;
use tracing_subscriber::EnvFilter;

#[allow(deprecated)]
pub fn log_panic(panic: &PanicInfo) {
let backtrace = format!("{:?}", Backtrace::force_capture());

Expand Down
5 changes: 3 additions & 2 deletions examples/raft-kv-memstore-opendal-snapshot-data/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2021"
authors = [
"drdr xp <[email protected]>",
"Pedro Paulo de Amorim <[email protected]>",
"Xuanwo <[email protected]>"
"Xuanwo <[email protected]>",
]
categories = ["algorithms", "asynchronous", "data-structures"]
description = "An example distributed key-value store built upon `openraft`."
Expand All @@ -20,12 +20,13 @@ repository = "https://github.com/datafuselabs/openraft"
memstore = { path = "../memstore", features = [] }
openraft = { path = "../../openraft", features = ["serde", "storage-v2", "generic-snapshot-data"] }

bytes = "1.0"
serde = { version = "1.0.114", features = ["derive"] }
serde_json = "1.0.57"
tokio = { version = "1.0", default-features = false, features = ["sync"] }
tracing = "0.1.29"
tracing-subscriber = { version = "0.3.0", features = ["env-filter"] }
opendal = "0.45.0"
opendal = "0.48.0"

[dev-dependencies]
maplit = "1.0.2"
Expand Down
6 changes: 6 additions & 0 deletions examples/raft-kv-memstore-opendal-snapshot-data/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

use std::sync::Arc;

use bytes::Buf;
use opendal::Buffer;
use opendal::Operator;
use openraft::Config;

Expand Down Expand Up @@ -69,6 +71,10 @@ pub fn decode<T: serde::de::DeserializeOwned>(s: &str) -> T {
serde_json::from_str(s).unwrap()
}

pub fn decode_buffer<T: serde::de::DeserializeOwned>(b: Buffer) -> T {
serde_json::from_reader(b.reader()).unwrap()
}

pub async fn new_raft(node_id: NodeId, router: Router, op: Operator) -> (typ::Raft, App) {
// Create a configuration for the raft instance.
let config = Config {
Expand Down
4 changes: 2 additions & 2 deletions examples/raft-kv-memstore-opendal-snapshot-data/src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use openraft::StoredMembership;
use serde::Deserialize;
use serde::Serialize;

use crate::decode;
use crate::decode_buffer;
use crate::encode;
use crate::typ;
use crate::NodeId;
Expand Down Expand Up @@ -212,7 +212,7 @@ impl RaftStateMachine<TypeConfig> for Arc<StateMachineStore> {
// Update the state machine.
{
let bs = self.storage.read(&new_snapshot.data).await.unwrap();
let updated_state_machine: StateMachineData = decode(&String::from_utf8_lossy(&bs));
let updated_state_machine: StateMachineData = decode_buffer(bs);
let mut state_machine = self.state_machine.lock().unwrap();
*state_machine = updated_state_machine;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::backtrace::Backtrace;
use std::collections::BTreeMap;
use std::collections::HashMap;
#[allow(deprecated)]
use std::panic::PanicInfo;
use std::time::Duration;

Expand All @@ -13,6 +14,7 @@ use tokio::task;
use tokio::task::LocalSet;
use tracing_subscriber::EnvFilter;

#[allow(deprecated)]
pub fn log_panic(panic: &PanicInfo) {
let backtrace = format!("{:?}", Backtrace::force_capture());

Expand Down Expand Up @@ -57,7 +59,7 @@ async fn test_cluster() {

// This test only use memory service for simplicity.
// Feel free to test against fs or s3.
let op = opendal::Operator::via_map(opendal::Scheme::Memory, HashMap::default()).unwrap();
let op = opendal::Operator::via_iter(opendal::Scheme::Memory, HashMap::<String, String>::default()).unwrap();

let router = Router::default();

Expand Down
8 changes: 5 additions & 3 deletions examples/raft-kv-memstore-singlethreaded/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ license = "MIT OR Apache-2.0"
repository = "https://github.com/datafuselabs/openraft"

[dependencies]
openraft = { path = "../../openraft", features = ["serde", "storage-v2", "singlethreaded"] }
openraft = { path = "../../openraft", features = [
"serde",
"singlethreaded",
"storage-v2",
] }

clap = { version = "4.1.11", features = ["derive", "env"] }
reqwest = { version = "0.11.9", features = ["json"] }
serde = { version = "1.0.114", features = ["derive"] }
serde_json = "1.0.57"
tokio = { version = "1.0", default-features = false, features = ["sync"] }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::backtrace::Backtrace;
use std::collections::BTreeMap;
use std::collections::BTreeSet;
#[allow(deprecated)]
use std::panic::PanicInfo;
use std::time::Duration;

Expand All @@ -21,6 +22,7 @@ use tokio::task;
use tokio::task::LocalSet;
use tracing_subscriber::EnvFilter;

#[allow(deprecated)]
pub fn log_panic(panic: &PanicInfo) {
let backtrace = format!("{:?}", Backtrace::force_capture());

Expand Down
2 changes: 1 addition & 1 deletion examples/raft-kv-memstore/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ openraft = { path = "../../openraft", features = ["serde", "storage-v2"] }

actix-web = "4.0.0-rc.2"
clap = { version = "4.1.11", features = ["derive", "env"] }
reqwest = { version = "0.11.9", features = ["json"] }
reqwest = { version = "0.12.5", features = ["json"] }
serde = { version = "1.0.114", features = ["derive"] }
serde_json = "1.0.57"
tokio = { version = "1.0", default-features = false, features = ["sync"] }
Expand Down
2 changes: 2 additions & 0 deletions examples/raft-kv-memstore/tests/cluster/test_cluster.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::backtrace::Backtrace;
use std::collections::BTreeMap;
#[allow(deprecated)]
use std::panic::PanicInfo;
use std::thread;
use std::time::Duration;
Expand All @@ -13,6 +14,7 @@ use raft_kv_memstore::store::Request;
use tokio::runtime::Runtime;
use tracing_subscriber::EnvFilter;

#[allow(deprecated)]
pub fn log_panic(panic: &PanicInfo) {
let backtrace = {
format!("{:?}", Backtrace::force_capture())
Expand Down
10 changes: 5 additions & 5 deletions examples/raft-kv-rocksdb/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ readme = "README.md"

edition = "2021"
authors = [
"drdr xp <[email protected]>",
"Pedro Paulo de Amorim <[email protected]>",
"The Tremor Team",
"drdr xp <[email protected]>",
"Pedro Paulo de Amorim <[email protected]>",
"The Tremor Team",
]
categories = ["algorithms", "asynchronous", "data-structures"]
description = "An example distributed key-value store built upon `openraft`."
Expand All @@ -26,14 +26,14 @@ openraft = { path = "../../openraft", features = ["serde", "storage-v2"] }
tokio = { version = "1.35.1", features = ["full"] }
byteorder = "1.4.3"
clap = { version = "4.1.11", features = ["derive", "env"] }
reqwest = { version = "0.11.9", features = ["json"] }
reqwest = { version = "0.12.5", features = ["json"] }
rocksdb = "0.22.0"
serde = { version = "1.0.114", features = ["derive"] }
serde_json = "1.0.57"
tide = { version = "0.16" }
# for toy-rpc, use `serde_json` instead of the default `serde_bincode`:
# bincode which enabled by default by toy-rpc, does not support `#[serde(flatten)]`: https://docs.rs/bincode/2.0.0-alpha.1/bincode/serde/index.html#known-issues
toy-rpc = { version = "0.8.6", features = [
toy-rpc = { version = "0.10.0", features = [
"ws_tokio",
"server",
"client",
Expand Down
2 changes: 2 additions & 0 deletions examples/raft-kv-rocksdb/tests/cluster/test_cluster.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::backtrace::Backtrace;
use std::collections::BTreeMap;
#[allow(deprecated)]
use std::panic::PanicInfo;
use std::thread;
use std::time::Duration;
Expand All @@ -13,6 +14,7 @@ use raft_kv_rocksdb::Node;
use tokio::runtime::Handle;
use tracing_subscriber::EnvFilter;

#[allow(deprecated)]
pub fn log_panic(panic: &PanicInfo) {
let backtrace = { format!("{:?}", Backtrace::force_capture()) };

Expand Down
3 changes: 0 additions & 3 deletions openraft/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,12 @@ maplit = { workspace = true }
rand = { workspace = true }
serde = { workspace = true, optional = true }
serde_json = { workspace = true, optional = true }
tempfile = { workspace = true, optional = true }
thiserror = { workspace = true }
tokio = { workspace = true }
tracing = { workspace = true }
tracing-futures = { workspace = true }
validit = { workspace = true }

or07 = { package = "openraft", version = "0.7.4", optional = true }

[dev-dependencies]
anyhow = { workspace = true }
async-entry = { workspace = true }
Expand Down
3 changes: 2 additions & 1 deletion openraft/src/config/config.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Raft runtime configuration.
use std::ops::Deref;
use std::str::FromStr;
use std::sync::atomic::AtomicBool;
use std::time::Duration;

Expand Down Expand Up @@ -54,7 +55,7 @@ fn parse_bytes_with_unit(src: &str) -> Result<u64, ConfigError> {
reason: e.to_string(),
})?;

Ok(res.get_bytes() as u64)
Ok(res.as_u64())
}

fn parse_snapshot_policy(src: &str) -> Result<SnapshotPolicy, ConfigError> {
Expand Down
2 changes: 1 addition & 1 deletion openraft/src/docs/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ Contributors who want to understand the internals of Openraft can find relevant
Finally, the archived and discarded documents:
- [`obsolete`](crate::docs::obsolete) describes obsolete design documents and why they are discarded;
- [`blank-log-heartbeeat`](`crate::docs::obsolete::heartbeat`);
- [`fast-commit`](`crate::docs::obsolete::fast_commit`);
- [`fast-commit`](`crate::docs::obsolete::fast_commit`);
1 change: 1 addition & 0 deletions openraft/src/docs/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(rustdoc::redundant_explicit_links)]
#![doc = include_str!("docs.md")]

#[rustfmt::skip]
Expand Down
3 changes: 1 addition & 2 deletions openraft/src/docs/protocol/snapshot_replication.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ Installing snapshot includes two steps:
The final step is to purge logs up to [`snapshot_meta.last_log_id`].
This step is necessary because:

- 1) A local log that is <= [`snapshot_meta.last_log_id`] may conflict with the leader, and can not be used
anymore.
- 1) A local log that is <= [`snapshot_meta.last_log_id`] may conflict with the leader, and can not be used anymore.

- 2) There may be a hole in the logs, if `snapshot_last_log_id > local_last_log_id`:

Expand Down
1 change: 1 addition & 0 deletions openraft/src/error/streaming_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ impl<C: RaftTypeConfig> From<StreamingError<C, Fatal<C::NodeId>>> for Replicatio

impl<C: RaftTypeConfig> From<StreamingError<C>> for ReplicationError<C::NodeId, C::Node> {
fn from(e: StreamingError<C>) -> Self {
#[allow(unreachable_patterns)]
match e {
StreamingError::Closed(e) => ReplicationError::Closed(e),
StreamingError::StorageError(e) => ReplicationError::StorageError(e),
Expand Down
4 changes: 1 addition & 3 deletions openraft/src/raft/message/append_entries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ pub struct AppendEntriesRequest<C: RaftTypeConfig> {
pub leader_commit: Option<LogId<C::NodeId>>,
}

impl<C: RaftTypeConfig> fmt::Debug for AppendEntriesRequest<C>
where C::D: fmt::Debug
{
impl<C: RaftTypeConfig> fmt::Debug for AppendEntriesRequest<C> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("AppendEntriesRequest")
.field("vote", &self.vote)
Expand Down
4 changes: 2 additions & 2 deletions openraft/src/raft/message/install_snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl<C: RaftTypeConfig> MessageSummary<InstallSnapshotRequest<C>> for InstallSna
#[derive(Debug)]
#[derive(PartialEq, Eq)]
#[derive(derive_more::Display)]
#[display(fmt = "{{vote:{}}}", vote)]
#[display("{{vote:{}}}", vote)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize), serde(bound = ""))]
pub struct InstallSnapshotResponse<NID: NodeId> {
pub vote: Vote<NID>,
Expand All @@ -59,7 +59,7 @@ pub struct InstallSnapshotResponse<NID: NodeId> {
#[derive(Debug)]
#[derive(PartialEq, Eq)]
#[derive(derive_more::Display)]
#[display(fmt = "SnapshotResponse{{vote:{}}}", vote)]
#[display("SnapshotResponse{{vote:{}}}", vote)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize), serde(bound = ""))]
pub struct SnapshotResponse<NID: NodeId> {
pub vote: Vote<NID>,
Expand Down
7 changes: 2 additions & 5 deletions openraft/src/raft/raft_inner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,8 @@ where C: RaftTypeConfig
message_summary.unwrap_or_default()
);

match core_res {
// A normal quit is still an unexpected "stop" to the caller.
Ok(_) => Fatal::Stopped,
Err(e) => e,
}
// Safe unwrap: Infallible is unreachable
core_res.unwrap_err()
}

/// Wait for `RaftCore` task to finish and record the returned value from the task.
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nightly-2024-03-20
nightly-2024-08-14
Loading

0 comments on commit 49d522f

Please sign in to comment.