@@ -46,7 +46,7 @@ use crate::{
4646 SessionOptions ,
4747 } ,
4848 results:: DatabaseSpecification ,
49- sdam:: { server_selection, SelectedServer , SessionSupportStatus , Topology } ,
49+ sdam:: { server_selection, SelectedServer , Topology } ,
5050 ClientSession ,
5151} ;
5252
@@ -56,8 +56,6 @@ pub(crate) use session::{ClusterTime, SESSIONS_UNSUPPORTED_COMMANDS};
5656use session:: { ServerSession , ServerSessionPool } ;
5757
5858const 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" ;
6159
6260/// This is the main entry point for the API. A `Client` is used to connect to a MongoDB cluster.
6361/// By default, it will monitor the topology of the cluster, keeping track of any changes, such
@@ -367,14 +365,7 @@ impl Client {
367365 if let Some ( ref options) = options {
368366 options. validate ( ) ?;
369367 }
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 )
378369 }
379370
380371 /// Starts a new [`ChangeStream`] that receives events for all changes in the cluster. The
@@ -428,42 +419,11 @@ impl Client {
428419 . await
429420 }
430421
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.
434424 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 ;
467427 }
468428
469429 #[ cfg( test) ]
@@ -601,7 +561,7 @@ impl Client {
601561 }
602562
603563 #[ cfg( test) ]
604- pub ( crate ) fn topology ( & self ) -> & crate :: sdam :: Topology {
564+ pub ( crate ) fn topology ( & self ) -> & Topology {
605565 & self . inner . topology
606566 }
607567
0 commit comments