@@ -46,7 +46,7 @@ use crate::{
46
46
SessionOptions ,
47
47
} ,
48
48
results:: DatabaseSpecification ,
49
- sdam:: { server_selection, SelectedServer , SessionSupportStatus , Topology } ,
49
+ sdam:: { server_selection, SelectedServer , Topology } ,
50
50
ClientSession ,
51
51
} ;
52
52
@@ -56,8 +56,6 @@ pub(crate) use session::{ClusterTime, SESSIONS_UNSUPPORTED_COMMANDS};
56
56
use session:: { ServerSession , ServerSessionPool } ;
57
57
58
58
const DEFAULT_SERVER_SELECTION_TIMEOUT : Duration = Duration :: from_secs ( 30 ) ;
59
- // TODO: RUST-1585 Remove this constant.
60
- pub ( crate ) const SESSIONS_SUPPORT_OP_NAME : & str = "Check sessions support status" ;
61
59
62
60
/// This is the main entry point for the API. A `Client` is used to connect to a MongoDB cluster.
63
61
/// By default, it will monitor the topology of the cluster, keeping track of any changes, such
@@ -367,14 +365,7 @@ impl Client {
367
365
if let Some ( ref options) = options {
368
366
options. validate ( ) ?;
369
367
}
370
- match self . get_session_support_status ( ) . await ? {
371
- SessionSupportStatus :: Supported {
372
- logical_session_timeout,
373
- } => Ok ( self
374
- . start_session_with_timeout ( logical_session_timeout, options, false )
375
- . await ) ,
376
- _ => Err ( ErrorKind :: SessionsNotSupported . into ( ) ) ,
377
- }
368
+ Ok ( ClientSession :: new ( self . clone ( ) , options, false ) . await )
378
369
}
379
370
380
371
/// Starts a new [`ChangeStream`] that receives events for all changes in the cluster. The
@@ -428,42 +419,11 @@ impl Client {
428
419
. await
429
420
}
430
421
431
- /// Check in a server session to the server session pool.
432
- /// If the session is expired or dirty, or the topology no longer supports sessions, the session
433
- /// will be discarded.
422
+ /// Check in a server session to the server session pool. The session will be discarded if it is
423
+ /// expired or dirty.
434
424
pub ( crate ) async fn check_in_server_session ( & self , session : ServerSession ) {
435
- let session_support_status = self . inner . topology . session_support_status ( ) ;
436
- if let SessionSupportStatus :: Supported {
437
- logical_session_timeout,
438
- } = session_support_status
439
- {
440
- self . inner
441
- . session_pool
442
- . check_in ( session, logical_session_timeout)
443
- . await ;
444
- }
445
- }
446
-
447
- /// Starts a `ClientSession`.
448
- ///
449
- /// This method will attempt to re-use server sessions from the pool which are not about to
450
- /// expire according to the provided logical session timeout. If no such sessions are
451
- /// available, a new one will be created.
452
- pub ( crate ) async fn start_session_with_timeout (
453
- & self ,
454
- logical_session_timeout : Option < Duration > ,
455
- options : Option < SessionOptions > ,
456
- is_implicit : bool ,
457
- ) -> ClientSession {
458
- ClientSession :: new (
459
- self . inner
460
- . session_pool
461
- . check_out ( logical_session_timeout)
462
- . await ,
463
- self . clone ( ) ,
464
- options,
465
- is_implicit,
466
- )
425
+ let timeout = self . inner . topology . logical_session_timeout ( ) ;
426
+ self . inner . session_pool . check_in ( session, timeout) . await ;
467
427
}
468
428
469
429
#[ cfg( test) ]
@@ -601,7 +561,7 @@ impl Client {
601
561
}
602
562
603
563
#[ cfg( test) ]
604
- pub ( crate ) fn topology ( & self ) -> & crate :: sdam :: Topology {
564
+ pub ( crate ) fn topology ( & self ) -> & Topology {
605
565
& self . inner . topology
606
566
}
607
567
0 commit comments