-
Notifications
You must be signed in to change notification settings - Fork 154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: add 'singlethreaded' raft mode #878
Conversation
- 'singlethreaded' compile-time feature gate. The new feature gate forces the raft instance to be used by a single thread by not implementing `Send` for certain data structures and substituting calls to `tokio::spawn` with `tokio::spawn_local` when using the `tokio` asynchronous runtime. - Fix: [datafuselabs#862](datafuselabs#862) **Checklist** - [x] Updated guide with pertinent info (may not always apply). <!-- Mark complete if nothing to do. --> - [o] Squash down commits to one or two logical commits which clearly describe the work you've done. - [o] Unittest is a friend:)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neat. Thank you for your contribution on this issue.
Reviewed 21 of 21 files at r1, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @schreter)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, looks very good!
Reviewed 21 of 21 files at r1, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @wvwwvwwv)
macros/src/lib.rs
line 11 at r1 (raw file):
/// in the same thread. #[proc_macro_attribute] pub fn add_async_trait(_attr: TokenStream, item: TokenStream) -> TokenStream {
BTW, should this macro be re-exported from openraft
crate, so the user would then also use #[add_async_trait]
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @wvwwvwwv)
macros/src/lib.rs
line 11 at r1 (raw file):
Previously, schreter wrote…
BTW, should this macro be re-exported from
openraft
crate, so the user would then also use#[add_async_trait]
?
Good idea!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@drmingdrmer uploaded a new commit, but the change is very small :-)
Reviewable status: 19 of 21 files reviewed, all discussions resolved (waiting on @drmingdrmer and @schreter)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 2 of 2 files at r2, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @wvwwvwwv)
The new feature gate forces the raft instance to be used by a single thread by not implementing
Send
for certain data structures and substituting calls totokio::spawn
with calls totokio::spawn_local
when using thetokio
asynchronous runtime. In case the application wants to use a different type of asynchronous runtimes, thespawn
method has to be appropriately implemented.openraft::Instant
is implemented forstd::time::Instant
to simplify the usage.FYI: @schreter
Checklist
This change is