Skip to content
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

Merged
merged 3 commits into from
Jun 27, 2023
Merged

Feature: add 'singlethreaded' raft mode #878

merged 3 commits into from
Jun 27, 2023

Conversation

wvwwvwwv
Copy link
Contributor

@wvwwvwwv wvwwvwwv commented Jun 26, 2023

  • '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 calls to tokio::spawn_local when using the tokio asynchronous runtime. In case the application wants to use a different type of asynchronous runtimes, the spawn method has to be appropriately implemented.

  • Additional change included.

openraft::Instant is implemented for std::time::Instant to simplify the usage.

FYI: @schreter

Checklist

  • Updated guide with pertinent info (may not always apply).
  • Squash down commits to one or two logical commits which clearly describe the work you've done.
  • Unittest is a friend:)

This change is Reviewable

- '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:)
@wvwwvwwv wvwwvwwv marked this pull request as ready for review June 27, 2023 01:28
drmingdrmer
drmingdrmer previously approved these changes Jun 27, 2023
Copy link
Member

@drmingdrmer drmingdrmer left a 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: :shipit: complete! all files reviewed, all discussions resolved (waiting on @schreter)

schreter
schreter previously approved these changes Jun 27, 2023
Copy link
Collaborator

@schreter schreter left a 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: :shipit: 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]?

Copy link
Contributor Author

@wvwwvwwv wvwwvwwv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: 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!

@wvwwvwwv wvwwvwwv dismissed stale reviews from schreter and drmingdrmer via 15aa47f June 27, 2023 09:52
Copy link
Contributor Author

@wvwwvwwv wvwwvwwv left a 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)

Copy link
Member

@drmingdrmer drmingdrmer left a 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: :shipit: complete! all files reviewed, all discussions resolved (waiting on @wvwwvwwv)

@drmingdrmer drmingdrmer merged commit 104983d into databendlabs:main Jun 27, 2023
22 of 24 checks passed
@drmingdrmer drmingdrmer mentioned this pull request Mar 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature: Allow creating !Send storage, log and network components
3 participants