We are pleased to announce the second release candidate for our 1.0.0 release.
Please note that this release drops support for Swift 5.0. The driver officially supports Swift 5.1 and 5.2 on macOS, Ubuntu 16.04, and Ubuntu 18.04.
A full list of included tickets is available below, but here are some highlights:
New Feature: Transactions Support
The driver now provides an API for transactions! Note that MongoDB supports transactions in replica sets as of v4.0, and in sharded clusters as of v4.2.
Please see the Transactions Guide in our documentation for details and examples.
Work on the convenient API for transactions (i.e. a withTransaction
helper that includes helpful logic to automatically retry transactions on certain errors) is currently in progress.
Notable API Changes
-
MongoClient.shutdown()
andMongoClient.syncShutdown()
have been renamedMongoClient.close()
andMongoClient.syncClose()
, respectively, for consistency with other MongoDB drivers. (SWIFT-749) -
ReadPreference
is now astruct
rather than aclass
. It no longer has any public initializers, but is instead initializable via static properties and methods available on the type. This makes usages more succinct, particularly in the context of e.g. an options struct where the compiler can infer the type. (SWIFT-738)
Example:let rp = ReadPreference(.primary) // old let rp = ReadPreference.primary // new let rp = try ReadPreference(.secondary, maxStalenessSeconds: 100) // old let rp = try ReadPreference.secondary(maxStalenessSeconds: 100) // new let options = FindOptions(readPreference: ReadPreference(.primary)) // old let options = FindOptions(readPreference: .primary) // new
- All of the TLS options previously specifiable via the
TLSOptions
struct have been moved directly intoClientOptions
, and have been renamed for consistency with the names used when they are specified via a MongoDB connection string. (SWIFT-753) - The
maxScan
option which has been deprecated since MongoDB v4.0 has been removed fromFindOptions
andFindOneOptions
. (SWIFT-439) - Several previous usages of other integer types in the API have been updated to use
Int
instead (SWIFT-754). Please see this diff for a complete list.
Included Tickets
Bug
- [SWIFT-750] - fix potential for deadlock when all connections are in use
New Feature
- [SWIFT-746] - Implement
startTransaction
,commitTransaction
, andabortTransaction
in the asynchronous API - [SWIFT-747] - Implement
startTransaction
,commitTransaction
, andabortTransaction
in the synchronous API
Task
- [SWIFT-434] - Add a TLS guide
- [SWIFT-743] - Implement
TransactionOptions
struct - [SWIFT-752] - Implement Transactions Spec Test Runner
- [SWIFT-347] - Update error handling guide to include errorLabels information
- [SWIFT-439] - Remove maxScan query option
- [SWIFT-499] - Update benchmark suite to include multithreaded scenarios
- [SWIFT-595] - Bump libmongoc version to 1.16
- [SWIFT-618] - Bump minimum Swift version to 5.1, and start testing against Swift 5.2
- [SWIFT-636] - Stop filtering out SERVICE_NAME = mongodb from mechanism properties in GSSAPI auth tests
( [SWIFT-705] - Tune defaultNIOThreadPool
size - [SWIFT-731] - Update guides to focus on async API
- [SWIFT-735] - Make
ObjectId
work withJSONEncoder
/JSONDecoder
- [SWIFT-744] - Update
ClientSessionOptions
to support transactions - [SWIFT-745] - Implement
StartTransactionOperation
,CommitTransactionOperation
, andAbortTransactionOperation
- [SWIFT-784] - Disable BSON_EXTRA_ALIGN in vendored libbson
- [SWIFT-423] - Provide Transactions example for Docs
Improvement
- [SWIFT-224] - Avoid roundtripping values through Swift when copying values from one document to another
- [SWIFT-621] - Provide default values for enum associated values where appropriate
- [SWIFT-623] - Use
Self
rather thantype(of: self)
- [SWIFT-677] -
listIndexNames
should extract names fromDocument
s rather than decoding entireIndexModel
s - [SWIFT-753] - Condense
TLSOptions
intoClientOptions
struct, and make property names consistent with URI options spec - [SWIFT-754] - Use
Int
in public API as much as possible - [SWIFT-757] - Add RetryableWriteError error labels to retryable transaction tests
- [SWIFT-772] - Add
allowDiskUse
option to find command - [SWIFT-751] - Add
maxPoolSize
option for connection pool - [SWIFT-773] - Support for
authorizedDatabases
option - [SWIFT-749] - Improve
MongoClient
shutdown logic - [SWIFT-738] - Make
ReadPreference
a struct