-
Notifications
You must be signed in to change notification settings - Fork 178
RUST-2217 Optionally support bson crate 3.0 #1380
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
Conversation
@@ -29,7 +29,10 @@ exclude = [ | |||
|
|||
[features] | |||
default = ["compat-3-0-0", "rustls-tls", "dns-resolver"] | |||
compat-3-0-0 = [] | |||
compat-3-0-0 = ["compat-3-3-0", "bson-2"] | |||
compat-3-3-0 = [] |
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.
Keeping a rolling compat-VERSION
feature allows us to do this again for other things if we need to, e.g. if we need to go back to supporting multiple async runtimes.
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.
Nice. That seems like a good precaution in case there is a future need to make a required feature optional.
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.
LGTM! Testing scenarios locally match the PR description.
cc7ba19
to
4358d38
Compare
Update: the msrv and cargo-deny failures were because I needed to rebase. cargo-deny is now happy but there's a new msrv failure that's actually directly related and needs fixing. |
@@ -17,7 +17,7 @@ license = "Apache-2.0" | |||
readme = "README.md" | |||
name = "mongodb" | |||
version = "3.2.3" | |||
rust-version = "1.74" | |||
rust-version = "1.81" |
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.
This needed to change because bson's msrv at head is 1.81; when doing an msrv compile against 2.x it would work because the crates.io published version had an msrv of 1.48, but there's no published version for 3.x so it needs to use the one from git.
@@ -9,9 +9,6 @@ source ./.evergreen/env.sh | |||
if [ "$RUST_VERSION" != "" ]; then | |||
rustup toolchain install $RUST_VERSION | |||
TOOLCHAIN="+${RUST_VERSION}" | |||
# Remove the local git dependencies for bson and mongocrypt, which don't work properly with the MSRV resolver. | |||
sed -i "s/bson =.*/bson = \"2\"/" Cargo.toml |
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.
I accidentally broke these by changing the formatting of Cargo.toml
to no longer match, but AFAICT the MSRV resolver is working fine with the git dependencies now.
I'm not sure if this would have been a viable solution as we progress with bson 3.0 since there's no published version yet to fall back on, so hopefully I'm not missing a failure mode here :)
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.
@isabelatkinson I'd like your input here - I can't find any brokenness but I'm deeply wary of things that work when I don't expect them to :)
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.
This originally had to be fixed when the driver's MSRV (1.74) was less than bson's (1.81) - the MSRV resolver couldn't look back for an older MSRV-compatible version with a git dependency instead of a published version dependency. That problem goes away with the driver's MSRV being >= bson's MSRV (which is done in this PR) since an older version doesn't need to be selected, but it will come up again if we bump bson without bumping the driver. I think we can just figure that out if/when it comes up again, though - we should be able to do something similar once 3.0 is actually published.
git = "https://github.com/mongodb/bson-rust" | ||
branch = "main" | ||
package = "bson" | ||
version = "3.0.0" |
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.
Mostly out of curiosity: will this break if we try to release the driver before bson 3.0 is released?
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.
cargo publish
will fail since there's no non-git version, yeah. If we do need to do a driver release before 3.0 we can either push a patch to the release branch that strips out the bson-3
feature entirely or we could push an alpha release of the bson crate to cargo.
@@ -9,9 +9,6 @@ source ./.evergreen/env.sh | |||
if [ "$RUST_VERSION" != "" ]; then | |||
rustup toolchain install $RUST_VERSION | |||
TOOLCHAIN="+${RUST_VERSION}" | |||
# Remove the local git dependencies for bson and mongocrypt, which don't work properly with the MSRV resolver. | |||
sed -i "s/bson =.*/bson = \"2\"/" Cargo.toml |
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.
This originally had to be fixed when the driver's MSRV (1.74) was less than bson's (1.81) - the MSRV resolver couldn't look back for an older MSRV-compatible version with a git dependency instead of a published version dependency. That problem goes away with the driver's MSRV being >= bson's MSRV (which is done in this PR) since an older version doesn't need to be selected, but it will come up again if we bump bson without bumping the driver. I think we can just figure that out if/when it comes up again, though - we should be able to do something similar once 3.0 is actually published.
RUST-2217
This adds the
bson-2
andbson-3
features, allowing users to select which version of the bson crate they'd like the driver crate to work with.bson-2
remains the default for compatibility reasons, we can't change that until driver 4.0.There are actually quite a few user scenarios here and I think we managed to cover them nicely:
bson
2.x continues to be used.compat-3-0-0
feature (compile error otherwise), which at the time did nothing; now that feature enablesbson-2
, so this user will also continue to getbson
2.x.bson-3
feature flag: The driver API will switch over to usingbson
3.x, nothing else will change. Under the hood, thebson
2.x crate will continue to be pulled in as a dependency; this is a consequence of Rust features needing to be additive. If the user cares about the compile time/binary size, they can go with:bson-3
feature flag: They'll get justbson
3.x, no 2.x pulled in.