github mongodb/mongo-rust-driver v2.1.0-beta

latest releases: v1.2.5, v2.1.0
pre-release2 years ago

Description

The MongoDB Rust driver team is pleased to announce the v2.1.0-beta release of the mongodb crate. This release is a preview of the upcoming v2.1.0 release, which will be functionally the same but may contain fixes for any bugs identified in this beta. This release contains a number of new features, bug fixes, and improvements, most notably support for Atlas Serverless.

Highlighted changes

The following sections detail some of the more important breaking changes included in this release. For a full list of changes, see the Full Release Notes section below.

Update dependency on bson to v2.1.0-beta

The exported version of bson was updated to v2.1.0-beta, which includes its own set of changes. Check out the bson release notes for more information.

Support for Atlas Serverless (RUST-653, RUST-983)

This release introduces load balancer support to the Rust driver, which enables it to be used with Atlas Serverless. As part of that, the test suite of the driver was updated to include testing against live Atlas Serverless instances to ensure full compatibility.

Wire protocol compression (RUST-54)

This release adds optional support for compressing the messages sent between the driver and the server. The available compression algorithms are zstd, snappy, and zlib, and they can be enabled via the zstd-compression, snappy-compression, and zlib-compression feature flags respectively. By default, none of the feature flags are enabled.

let mut options = ClientOptions::parse("mongodb://localhost:27017").await?;

// the server will select the algorithm it supports from the list provided by the driver
options.compressors = Some(vec![
    Compressor::Snappy,
    Compressor::Zlib {
        level: Default::default(),
    },
    Compressor::Zstd {
        level: Default::default(),
    },
]);
let client = Client::with_options(options)?;
let resp = client
    .database("admin")
    .run_command(
        doc! {
            "ping": 1
        },
        None,
    )
    .await?;
println!("{}", resp);

Causal consistency (RUST-48)

This release adds driver support for causal consistency and enables it by default on all ClientSessions. For more information on the guarantees provided by causal consistency, check out the MongoDB manual.

let options = SessionOptions::builder().causal_consistency(true).build();
let mut session = client.start_session(Some(options)).await?;

let coll_options = CollectionOptions::builder()
    .read_concern(ReadConcern::majority())
    .write_concern(WriteConcern::builder().w(Acknowledgment::Majority).build())
    .build();
let collection = client
    .database("foo")
    .collection_with_options("bar", coll_options);

collection
    .insert_one_with_session(doc! { "read": "me" }, None, &mut session)
    .await?;
collection
    .find_one_with_session(doc! { "read": "me" }, None, &mut session)
    .await?
    .expect("causal consistency guarantees we can read our own writes");

Full Release Notes

New Features

Bugfixes

  • RUST-856 Fix race between server selection and server monitoring (#460)
  • RUST-992 Fix default authSource for PLAIN authentication (#451)
  • RUST-1037 secondaryPreferred read preference is not forwarded to mongos (#480)
  • RUST-1046 Fix iteration of session cursors when batchSize doesn't divide result size (#483)
  • RUST-1047 Ensure TopologyClosedEvent is the last SDAM event emitted (#485)
  • RUST-1060 Omit non-pub fields from Debug output of ClientOptions (#512)

Improvements

Task

Don't miss a new mongo-rust-driver release

NewReleases is sending notifications on new releases.