11import Foundation
22import mongoc
33
4- /// Options to use when creating a ClientSession.
4+ /// Options to use when creating a ` ClientSession` or `SyncClientSession` .
55public struct ClientSessionOptions {
66 /// Whether to enable causal consistency for this session. By default, causal consistency is enabled.
77 ///
@@ -31,7 +31,7 @@ private func withSessionOpts<T>(wrapping options: ClientSessionOptions?,
3131 * A MongoDB client session.
3232 * This class represents a logical session used for ordering sequential operations.
3333 *
34- * To create a client session, use `startSession` or `withSession` on a `MongoClient`.
34+ * To create a client session, use `startSession` or `withSession` on a `MongoClient` or a `SyncMongoClient` .
3535 *
3636 * If `causalConsistency` is not set to `false` when starting a session, read and write operations that use the session
3737 * will be provided causal consistency guarantees depending on the read and write concerns used. Using "majority"
@@ -55,12 +55,12 @@ private func withSessionOpts<T>(wrapping options: ClientSessionOptions?,
5555 * - https://docs.mongodb.com/manual/core/read-isolation-consistency-recency/#sessions
5656 * - https://docs.mongodb.com/manual/core/causal-consistency-read-write-concerns/
5757 */
58- public final class ClientSession {
58+ public final class SyncClientSession {
5959 /// Error thrown when an inactive session is used.
6060 internal static let SessionInactiveError = UserError . logicError ( message: " Tried to use an inactive session " )
6161 /// Error thrown when a user attempts to use a session with a client it was not created from.
6262 internal static let ClientMismatchError = UserError . invalidArgumentError (
63- message: " Sessions may only be used with the MongoClient used to create them " )
63+ message: " Sessions may only be used with the client used to create them " )
6464
6565 /// Enum for tracking the state of a session.
6666 internal enum State {
@@ -83,7 +83,7 @@ public final class ClientSession {
8383 }
8484
8585 /// The client used to start this session.
86- public let client : MongoClient
86+ public let client : SyncMongoClient
8787
8888 /// The session ID of this session.
8989 public let id : Document
@@ -122,7 +122,7 @@ public final class ClientSession {
122122 public let options : ClientSessionOptions ?
123123
124124 /// Initializes a new client session.
125- internal init ( client: MongoClient , options: ClientSessionOptions ? = nil ) throws {
125+ internal init ( client: SyncMongoClient , options: ClientSessionOptions ? = nil ) throws {
126126 self . options = options
127127 self . client = client
128128
@@ -144,12 +144,12 @@ public final class ClientSession {
144144
145145 /// Retrieves this session's underlying connection. Throws an error if the provided client was not the client used
146146 /// to create this session, or if this session has been ended.
147- internal func getConnection( forUseWith client: MongoClient ) throws -> Connection {
147+ internal func getConnection( forUseWith client: SyncMongoClient ) throws -> Connection {
148148 guard case let . active( _, connection) = self . state else {
149- throw ClientSession . SessionInactiveError
149+ throw SyncClientSession . SessionInactiveError
150150 }
151151 guard self . client == client else {
152- throw ClientSession . ClientMismatchError
152+ throw SyncClientSession . ClientMismatchError
153153 }
154154 return connection
155155 }
@@ -202,7 +202,7 @@ public final class ClientSession {
202202 /// - `UserError.logicError` if this session is inactive
203203 internal func append( to doc: inout Document ) throws {
204204 guard case let . active( session, _) = self . state else {
205- throw ClientSession . SessionInactiveError
205+ throw SyncClientSession . SessionInactiveError
206206 }
207207
208208 var error = bson_error_t ( )
0 commit comments