Skip to content

Commit d1a97d3

Browse files
committed
Fixdoc: update README for store examples; fix memstore path
1 parent 895c859 commit d1a97d3

16 files changed

+79
-35
lines changed

memstore/Cargo.toml

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
[package]
2-
name = "memstore"
2+
name = "openraft-memstore"
3+
description = "A in-memory implementation of the `openraft::RaftStorage` trait."
4+
documentation = "https://docs.rs/openraft-memstore"
35
readme = "README.md"
46

57
version = { workspace = true }
68
edition = { workspace = true }
79
authors = { workspace = true }
810
categories = { workspace = true }
9-
description = { workspace = true }
10-
documentation = { workspace = true }
1111
homepage = { workspace = true }
1212
keywords = { workspace = true }
1313
license = { workspace = true }
1414
repository = { workspace = true }
1515

1616
[dependencies]
17-
openraft = { path= "../openraft", features=["serde"] }
17+
openraft = { path= "../openraft", version = "0.8.0", features=["serde"] }
1818

1919
serde = { workspace = true }
2020
serde_json = { workspace = true }

memstore/README.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# openraft-memstore
2+
3+
This is an in-memory example `RaftStorage` implementation based on [openraft-0.8](https://github.com/datafuselabs/openraft/tree/release-0.8).
4+
5+
This crate is built mainly for testing or demonstrating purpose.:)

openraft/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ tracing-futures = { workspace = true }
3535
or07 = { package = "openraft", version = "0.7.4", optional = true }
3636

3737
[dev-dependencies]
38-
memstore = { path="../memstore" }
38+
openraft-memstore = { path="../memstore" }
3939

4040
anyhow = { workspace = true }
4141
async-entry = { workspace = true }

openraft/tests/append_entries/t10_conflict_with_empty_entries.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use std::sync::Arc;
22

33
use anyhow::Result;
4-
use memstore::ClientRequest;
54
use openraft::raft::AppendEntriesRequest;
65
use openraft::CommittedLeaderId;
76
use openraft::Config;
@@ -11,6 +10,7 @@ use openraft::LogId;
1110
use openraft::RaftNetwork;
1211
use openraft::RaftNetworkFactory;
1312
use openraft::Vote;
13+
use openraft_memstore::ClientRequest;
1414

1515
use crate::fixtures::blank;
1616
use crate::fixtures::init_default_ut_tracing;
@@ -50,7 +50,7 @@ async fn conflict_with_empty_entries() -> Result<()> {
5050

5151
// Expect conflict even if the message contains no entries.
5252

53-
let rpc = AppendEntriesRequest::<memstore::Config> {
53+
let rpc = AppendEntriesRequest::<openraft_memstore::Config> {
5454
vote: Vote::new_committed(1, 1),
5555
prev_log_id: Some(LogId::new(CommittedLeaderId::new(1, 0), 5)),
5656
entries: vec![],
@@ -63,7 +63,7 @@ async fn conflict_with_empty_entries() -> Result<()> {
6363

6464
// Feed logs
6565

66-
let rpc = AppendEntriesRequest::<memstore::Config> {
66+
let rpc = AppendEntriesRequest::<openraft_memstore::Config> {
6767
vote: Vote::new_committed(1, 1),
6868
prev_log_id: None,
6969
entries: vec![blank(0, 0), blank(1, 1), Entry {
@@ -83,7 +83,7 @@ async fn conflict_with_empty_entries() -> Result<()> {
8383

8484
// Expect a conflict with prev_log_index == 3
8585

86-
let rpc = AppendEntriesRequest::<memstore::Config> {
86+
let rpc = AppendEntriesRequest::<openraft_memstore::Config> {
8787
vote: Vote::new_committed(1, 1),
8888
prev_log_id: Some(LogId::new(CommittedLeaderId::new(1, 0), 3)),
8989
entries: vec![],

openraft/tests/append_entries/t10_see_higher_vote.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use std::time::Duration;
33

44
use anyhow::Result;
55
use maplit::btreeset;
6-
use memstore::ClientRequest;
76
use openraft::raft::VoteRequest;
87
use openraft::CommittedLeaderId;
98
use openraft::Config;
@@ -12,6 +11,7 @@ use openraft::RaftNetwork;
1211
use openraft::RaftNetworkFactory;
1312
use openraft::ServerState;
1413
use openraft::Vote;
14+
use openraft_memstore::ClientRequest;
1515

1616
use crate::fixtures::init_default_ut_tracing;
1717
use crate::fixtures::RaftRouter;

openraft/tests/append_entries/t20_append_conflicts.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ where
225225
{
226226
let logs = StorageHelper::new(sto).get_log_entries(..).await?;
227227
let skip = 0;
228-
let want: Vec<Entry<memstore::Config>> = terms
228+
let want: Vec<Entry<openraft_memstore::Config>> = terms
229229
.iter()
230230
.skip(skip)
231231
.enumerate()

openraft/tests/append_entries/t50_append_entries_with_bigger_term.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ async fn append_entries_with_bigger_term() -> Result<()> {
4141
.await?;
4242

4343
// append entries with term 2 and leader_id, this MUST cause hard state changed in node 0
44-
let req = AppendEntriesRequest::<memstore::Config> {
44+
let req = AppendEntriesRequest::<openraft_memstore::Config> {
4545
vote: Vote::new_committed(2, 1),
4646
prev_log_id: Some(LogId::new(CommittedLeaderId::new(1, 0), log_index)),
4747
entries: vec![],

openraft/tests/fixtures/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ use anyerror::AnyError;
2121
use anyhow::Context;
2222
use lazy_static::lazy_static;
2323
use maplit::btreeset;
24-
use memstore::Config as MemConfig;
25-
use memstore::IntoMemClientRequest;
26-
use memstore::MemStore;
2724
use openraft::async_trait::async_trait;
2825
use openraft::error::CheckIsLeaderError;
2926
use openraft::error::ClientWriteError;
@@ -58,6 +55,9 @@ use openraft::RaftState;
5855
use openraft::RaftTypeConfig;
5956
use openraft::ServerState;
6057
use openraft::StoreExt;
58+
use openraft_memstore::Config as MemConfig;
59+
use openraft_memstore::IntoMemClientRequest;
60+
use openraft_memstore::MemStore;
6161
#[allow(unused_imports)] use pretty_assertions::assert_eq;
6262
#[allow(unused_imports)] use pretty_assertions::assert_ne;
6363
use tracing_appender::non_blocking::WorkerGuard;
@@ -132,7 +132,7 @@ pub fn log_panic(panic: &PanicInfo) {
132132
}
133133

134134
/// A type which emulates a network transport and implements the `RaftNetworkFactory` trait.
135-
pub struct TypedRaftRouter<C: RaftTypeConfig = memstore::Config, S: RaftStorage<C> = Arc<MemStore>>
135+
pub struct TypedRaftRouter<C: RaftTypeConfig = openraft_memstore::Config, S: RaftStorage<C> = Arc<MemStore>>
136136
where
137137
C::D: Debug + IntoMemClientRequest<C::D>,
138138
C::R: Debug,
@@ -153,7 +153,7 @@ where
153153
}
154154

155155
/// Default `RaftRouter` for memstore.
156-
pub type RaftRouter = TypedRaftRouter<memstore::Config, Arc<MemStore>>;
156+
pub type RaftRouter = TypedRaftRouter<openraft_memstore::Config, Arc<MemStore>>;
157157

158158
pub struct Builder<C: RaftTypeConfig, S: RaftStorage<C>> {
159159
config: Arc<Config>,

openraft/tests/membership/t16_change_membership_cases.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ use std::sync::Arc;
33
use std::time::Duration;
44

55
use maplit::btreeset;
6-
use memstore::MemNodeId;
76
use openraft::ChangeMembers;
87
use openraft::Config;
98
use openraft::ServerState;
9+
use openraft_memstore::MemNodeId;
1010

1111
use crate::fixtures::init_default_ut_tracing;
1212
use crate::fixtures::RaftRouter;

openraft/tests/membership/t30_remove_leader.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ use std::time::Duration;
33

44
use anyhow::Result;
55
use maplit::btreeset;
6-
use memstore::ClientRequest;
7-
use memstore::IntoMemClientRequest;
86
use openraft::error::ClientWriteError;
97
use openraft::CommittedLeaderId;
108
use openraft::Config;
119
use openraft::LogId;
1210
use openraft::ServerState;
11+
use openraft_memstore::ClientRequest;
12+
use openraft_memstore::IntoMemClientRequest;
1313

1414
use crate::fixtures::init_default_ut_tracing;
1515
use crate::fixtures::RaftRouter;

rocksstore-compat07/Cargo.toml

+14-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,21 @@
11
[package]
22
name = "openraft-rocksstore-compat07"
3-
version = "0.1.0"
4-
edition = "2021"
3+
description = "A example v07 compatible implementation of the `openraft::RaftStorage` trait."
4+
documentation = "https://docs.rs/openraft-rocksstore-copmat07"
5+
readme = "README.md"
6+
7+
version = { workspace = true }
8+
edition = { workspace = true }
9+
authors = { workspace = true }
10+
categories = { workspace = true }
11+
homepage = { workspace = true }
12+
keywords = { workspace = true }
13+
license = { workspace = true }
14+
repository = { workspace = true }
15+
516

617
[dependencies]
7-
openraft = { path = "../openraft", package = "openraft", features = ["compat-07"] }
18+
openraft = { path = "../openraft", package = "openraft", version = "0.8.0", features = ["compat-07"] }
819

920
async-std = { version = "1.12.0", features = ["attributes", "tokio1"] }
1021
byteorder = "1.4.3"

rocksstore-compat07/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# openraft-rockcsstore-0708
22

3-
This is an example `RaftStorage` implementation illustrating how to upgrade an application based on [openraft-0.7]() to [openraft-0.8]().
3+
This is an example `RaftStorage` implementation illustrating how to upgrade an application based on [openraft-0.7](https://github.com/datafuselabs/openraft/tree/release-0.7) to [openraft-0.8](https://github.com/datafuselabs/openraft/tree/release-0.8).
44

55
In this example, it assumes there is an on-disk rocksdb dir that backs an 0.7 application,
6-
and the compatible 0708 should be able to read data from this dir and write data to it.
6+
and the compatible 0708 should be able to read data from this dir and write data to it.

rocksstore/Cargo.toml

+13-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
11
[package]
22
name = "openraft-rocksstore"
3-
version = "0.1.0"
4-
edition = "2021"
3+
description = "A rocksdb based implementation of the `openraft::RaftStorage` trait."
4+
documentation = "https://docs.rs/openraft-rocksstore"
5+
readme = "README.md"
6+
7+
version = { workspace = true }
8+
edition = { workspace = true }
9+
authors = { workspace = true }
10+
categories = { workspace = true }
11+
homepage = { workspace = true }
12+
keywords = { workspace = true }
13+
license = { workspace = true }
14+
repository = { workspace = true }
515

616
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
717

818
[dependencies]
9-
openraft = { path = "../openraft", features = ["serde"] }
19+
openraft = { path= "../openraft", version = "0.8.0", features=["serde"] }
1020

1121
rocksdb = "0.20.1"
1222
byteorder = "1.4.3"

rocksstore/README.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# openraft-rocksstore
2+
3+
This is an example `RaftStorage` implementation with [`rocksdb`](https://docs.rs/rocksdb/latest/rocksdb/) based on [openraft-0.8](https://github.com/datafuselabs/openraft/tree/release-0.8).
4+
5+
This crate is built mainly for testing or demonstrating purpose.:)

sledstore/Cargo.toml

+15-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
[package]
2-
name = "sledstore"
3-
version = "0.1.0"
4-
edition = "2021"
2+
name = "openraft-sledstore"
3+
description = "A sled based implementation of the `openraft::RaftStorage` trait."
4+
documentation = "https://docs.rs/openraft-sledstore"
5+
readme = "README.md"
56

6-
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7+
version = { workspace = true }
8+
edition = { workspace = true }
9+
authors = { workspace = true }
10+
categories = { workspace = true }
11+
homepage = { workspace = true }
12+
keywords = { workspace = true }
13+
license = { workspace = true }
14+
repository = { workspace = true }
715

816
[dependencies]
9-
openraft = { path = "../openraft", features = ["serde"] }
17+
openraft = { path= "../openraft", version = "0.8.0", features=["serde"] }
1018

1119
sled = "0.34.7"
1220
byteorder = "1.4.3"
@@ -16,5 +24,5 @@ async-std = { version = "1.12.0", features = ["attributes", "tokio1"] }
1624
tracing = "0.1.29"
1725

1826
[dev-dependencies]
19-
tempdir = "*"
20-
async-trait = "*"
27+
tempdir = { version = "0.3.7" }
28+
async-trait = { version = "0.1.36" }

sledstore/README.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# openraft-sledstore
2+
3+
This is an example `RaftStorage` implementation with [`sled`](https://github.com/spacejam/sled) based on [openraft-0.8](https://github.com/datafuselabs/openraft/tree/release-0.8).
4+
5+
This crate is built mainly for testing or demonstrating purpose.:)

0 commit comments

Comments
 (0)