@@ -288,19 +288,36 @@ public class MongoClient {
288288 assert ( self . isClosed, " MongoClient was not closed before deinitialization " )
289289 }
290290
291- /// Closes this `MongoClient`. Call this method exactly once when you are finished using the client. You must
292- /// ensure that all operations using the client have completed before calling this. The returned future must be
293- /// fulfilled before the `EventLoopGroup` provided to this client's constructor is shut down.
294- public func close( ) -> EventLoopFuture < Void > {
291+ /// Shuts this `MongoClient` down, closing all connection to the server and cleaning up internal state.
292+ /// Call this method exactly once when you are finished using the client. You must ensure that all operations
293+ /// using the client have completed before calling this. The returned future must be fulfilled before the
294+ /// `EventLoopGroup` provided to this client's constructor is shut down.
295+ public func shutdown( ) -> EventLoopFuture < Void > {
295296 return self . operationExecutor. execute {
296- self . connectionPool. close ( )
297+ self . connectionPool. shutdown ( )
297298 self . isClosed = true
298299 }
299300 . flatMap {
300301 self . operationExecutor. close ( )
301302 }
302303 }
303304
305+ /**
306+ * Shuts this `MongoClient` down in a blocking fashion, closing all connections to the server and cleaning up
307+ * internal state.
308+ *
309+ * Call this method exactly once when you are finished using the client. You must ensure that all operations
310+ * using the client have completed before calling this.
311+ *
312+ * This method must complete before the `EventLoopGroup` provided to this client's constructor is shut down.
313+ */
314+ public func syncShutdown( ) {
315+ self . connectionPool. shutdown ( )
316+ self . isClosed = true
317+ // TODO: SWIFT-349 log any errors encountered here.
318+ try ? self . operationExecutor. syncClose ( )
319+ }
320+
304321 /// Starts a new `ClientSession` with the provided options. When you are done using this session, you must call
305322 /// `ClientSession.end()` on it.
306323 public func startSession( options: ClientSessionOptions ? = nil ) -> ClientSession {
0 commit comments