File tree 15 files changed +47
-16
lines changed
15 files changed +47
-16
lines changed Original file line number Diff line number Diff line change 1
1
[package ]
2
- name = " macros"
2
+ name = " openraft- macros"
3
3
4
4
version = { workspace = true }
5
5
edition = { workspace = true }
Original file line number Diff line number Diff line change
1
+ #![ doc = include_str ! ( "lib_readme.md" ) ]
2
+
1
3
use proc_macro:: TokenStream ;
2
4
use quote:: quote;
3
5
use syn:: parse2;
@@ -11,7 +13,7 @@ use syn::Type;
11
13
12
14
/// This proc macro attribute optionally adds `Send` bounds to a trait.
13
15
///
14
- /// By default, `Send` bounds will be added to the trait and to the return bounds of any async
16
+ /// By default, `Send` bounds will be added to the trait and to the return bounds of any async
15
17
/// functions defined withing the trait.
16
18
///
17
19
/// If the `singlethreaded` feature is enabled, the trait definition remains the same without any
@@ -20,14 +22,22 @@ use syn::Type;
20
22
/// # Example
21
23
///
22
24
/// ```
23
- /// use macros ::add_async_trait;
25
+ /// use openraft_macros ::add_async_trait;
24
26
///
25
27
/// #[add_async_trait]
26
28
/// trait MyTrait {
27
29
/// async fn my_method(&self) -> Result<(), String>;
28
30
/// }
29
31
/// ```
30
32
///
33
+ /// The above code will be transformed into:
34
+ ///
35
+ /// ```ignore
36
+ /// trait MyTrait {
37
+ /// fn my_method(&self) -> impl Future<Output=Result<(), String>> + Send;
38
+ /// }
39
+ /// ```
40
+ ///
31
41
/// Note: This proc macro can only be used with traits.
32
42
///
33
43
/// # Panics
Original file line number Diff line number Diff line change
1
+ Supporting utils for [ Openraft] ( https://crates.io/crates/openraft ) .
2
+
3
+ ` #[add_async_trait] ` adds ` Send ` bounds to an async trait.
4
+
5
+ # Example
6
+
7
+ ```
8
+ #[openraft_macros::add_async_trait]
9
+ trait MyTrait {
10
+ async fn my_method(&self) -> Result<(), String>;
11
+ }
12
+ ```
13
+
14
+ The above code will be transformed into:
15
+
16
+ ``` ignore
17
+ trait MyTrait {
18
+ fn my_method(&self) -> impl Future<Output=Result<(), String>> + Send;
19
+ }
20
+ ```
Original file line number Diff line number Diff line change 1
1
# openraft-memstore
2
2
3
- This is an in-memory example ` RaftStorage ` implementation based on [ openraft-0.8 ] ( https://github.com/datafuselabs/openraft/tree/release-0.8 ) .
3
+ This is an in-memory example ` RaftLogStorage ` and ` RaftStateMachine ` implementation based on [ openraft] ( https://github.com/datafuselabs/openraft/ ) .
4
4
5
5
This crate is built mainly for testing or demonstrating purpose.:)
Original file line number Diff line number Diff line change @@ -13,14 +13,15 @@ keywords = { workspace = true }
13
13
license = { workspace = true }
14
14
repository = { workspace = true }
15
15
16
+
16
17
[dependencies ]
17
18
anyerror = { workspace = true }
18
19
anyhow = { workspace = true , optional = true }
19
20
byte-unit = { workspace = true }
20
21
clap = { workspace = true }
21
22
derive_more = { workspace = true }
22
23
futures = { workspace = true }
23
- macros = { path = " ../macros" }
24
+ openraft- macros = { path = " ../macros" , version = " 0.9.0 " }
24
25
maplit = { workspace = true }
25
26
rand = { workspace = true }
26
27
serde = { workspace = true , optional = true }
@@ -80,7 +81,7 @@ compat = []
80
81
storage-v2 = []
81
82
82
83
# Disallows applications to share a raft instance with multiple threads.
83
- singlethreaded = [" macros/singlethreaded" ]
84
+ singlethreaded = [" openraft- macros/singlethreaded" ]
84
85
85
86
86
87
# Permit the follower's log to roll back to an earlier state without causing the
Original file line number Diff line number Diff line change @@ -68,10 +68,10 @@ mod try_as_ref;
68
68
69
69
pub use anyerror;
70
70
pub use anyerror:: AnyError ;
71
- pub use macros:: add_async_trait;
72
71
pub use network:: RPCTypes ;
73
72
pub use network:: RaftNetwork ;
74
73
pub use network:: RaftNetworkFactory ;
74
+ pub use openraft_macros:: add_async_trait;
75
75
pub use type_config:: RaftTypeConfig ;
76
76
77
77
pub use crate :: async_runtime:: AsyncRuntime ;
Original file line number Diff line number Diff line change 1
- use macros :: add_async_trait;
1
+ use openraft_macros :: add_async_trait;
2
2
3
3
use crate :: network:: RaftNetwork ;
4
4
use crate :: OptionalSend ;
Original file line number Diff line number Diff line change 1
1
use std:: future:: Future ;
2
2
use std:: time:: Duration ;
3
3
4
- use macros :: add_async_trait;
4
+ use openraft_macros :: add_async_trait;
5
5
6
6
use crate :: error:: Fatal ;
7
7
use crate :: error:: RPCError ;
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ use std::io::SeekFrom;
6
6
use std:: time:: Duration ;
7
7
8
8
use futures:: FutureExt ;
9
- use macros :: add_async_trait;
9
+ use openraft_macros :: add_async_trait;
10
10
use tokio:: io:: AsyncReadExt ;
11
11
use tokio:: io:: AsyncSeekExt ;
12
12
use tokio:: io:: AsyncWriteExt ;
Original file line number Diff line number Diff line change 1
- use macros :: add_async_trait;
1
+ use openraft_macros :: add_async_trait;
2
2
3
3
use crate :: engine:: Command ;
4
4
use crate :: RaftTypeConfig ;
Original file line number Diff line number Diff line change 1
1
use std:: fmt:: Debug ;
2
2
use std:: ops:: RangeBounds ;
3
3
4
- use macros :: add_async_trait;
4
+ use openraft_macros :: add_async_trait;
5
5
6
6
use crate :: defensive:: check_range_matches_entries;
7
7
use crate :: LogId ;
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ use std::ops::RangeBounds;
14
14
#[ cfg( not( feature = "storage-v2" ) ) ] pub use adapter:: Adaptor ;
15
15
pub use helper:: StorageHelper ;
16
16
pub use log_store_ext:: RaftLogReaderExt ;
17
- use macros :: add_async_trait;
17
+ use openraft_macros :: add_async_trait;
18
18
pub use snapshot_signature:: SnapshotSignature ;
19
19
pub use v2:: RaftLogStorage ;
20
20
pub use v2:: RaftLogStorageExt ;
Original file line number Diff line number Diff line change 4
4
5
5
mod raft_log_storage_ext;
6
6
7
- use macros :: add_async_trait;
7
+ use openraft_macros :: add_async_trait;
8
8
pub use raft_log_storage_ext:: RaftLogStorageExt ;
9
9
10
10
use crate :: storage:: callback:: LogFlushed ;
Original file line number Diff line number Diff line change 1
1
use anyerror:: AnyError ;
2
- use macros :: add_async_trait;
2
+ use openraft_macros :: add_async_trait;
3
3
4
4
use crate :: storage:: LogFlushed ;
5
5
use crate :: storage:: RaftLogStorage ;
Original file line number Diff line number Diff line change 1
1
#[ cfg( not( feature = "storage-v2" ) ) ] use std:: future:: Future ;
2
2
3
- use macros :: add_async_trait;
3
+ use openraft_macros :: add_async_trait;
4
4
5
5
#[ cfg( not( feature = "storage-v2" ) ) ] use crate :: storage:: Adaptor ;
6
6
use crate :: storage:: RaftLogStorage ;
You can’t perform that action at this time.
0 commit comments