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

RUST-995 Add tokio-sync feature flag #578

Merged
merged 12 commits into from
Mar 9, 2022

Conversation

isabelatkinson
Copy link
Contributor

No description provided.

@isabelatkinson isabelatkinson marked this pull request as ready for review February 24, 2022 15:29
///
/// This will panic if called from a sychronous context when tokio is being used.
#[cfg(any(feature = "sync", test))]
#[cfg(test)]
pub(crate) fn block_on<F, T>(self, fut: F) -> T
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This method is now just used for configuring a fail point -- the sync code now calls block_on directly on the static tokio runtime. It's possible we'll want to reconfigure this method but that can be done with a broader refactor in RUST-800.

TokioCallingContext::Sync => None,
},
Self::Tokio => {
let handle = tokio::runtime::Handle::current();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can call current directly because there should always be a tokio runtime going (either from the async caller or TOKIO_RUNTIME). We can assume TOKIO_RUNTIME has already been initialized here because the entry point for the execution of any async code is by calling TOKIO_RUNTIME.block_on.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that means the signature of this function can be changed to drop the Option wrapper for the return type entirely.

Copy link
Contributor

@abr-egn abr-egn left a comment

Choose a reason for hiding this comment

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

Looks good! A few smallish comments.

TokioCallingContext::Sync => None,
},
Self::Tokio => {
let handle = tokio::runtime::Handle::current();
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that means the signature of this function can be changed to drop the Option wrapper for the return type entirely.

src/runtime/mod.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@abr-egn abr-egn left a comment

Choose a reason for hiding this comment

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

LGTM!

src/lib.rs Outdated Show resolved Hide resolved
.evergreen/run-tokio-tests.sh Outdated Show resolved Hide resolved
Copy link
Contributor

@patrickfreed patrickfreed left a comment

Choose a reason for hiding this comment

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

Changes LGTM! Just need to sort out the lint failures and this should be good to go

@@ -5,4 +5,5 @@ set -o errexit
. ~/.cargo/env
cargo +nightly rustdoc -- -D warnings --cfg docsrs
cargo +nightly rustdoc --no-default-features --features async-std-runtime -- -D warnings --cfg docsrs
cargo +nightly rustdoc --no-default-features --features sync -- -D warnings --cfg docsrs
cargo +nightly rustdoc --features sync -- -D warnings --cfg docsrs
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we still need --no-default-features here for the async-std sync variant. It looks like the check-rustdoc.sh test is failing as a result.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh whoops, good catch

@isabelatkinson isabelatkinson changed the title RUST-995 Use the tokio runtime for the sync API RUST-995 Add tokio-sync feature flag Mar 9, 2022
@isabelatkinson isabelatkinson merged commit a77eea9 into mongodb:master Mar 9, 2022
@isabelatkinson isabelatkinson deleted the RUST-995 branch March 9, 2022 15:31
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.

3 participants