@@ -33,13 +33,9 @@ public static BsonDocument GetReadConcernForFirstCommandInTransaction(ICoreSessi
3333 return ToBsonDocument ( session , connectionDescription , readConcern ) ;
3434 }
3535
36- // private static methods
37- private static BsonDocument ToBsonDocument ( ICoreSession session , ConnectionDescription connectionDescription , ReadConcern readConcern )
36+ public static BsonDocument GetReadConcernForSnapshotSesssion ( ICoreSession session , ConnectionDescription connectionDescription )
3837 {
39- var sessionsAreSupported = connectionDescription . IsMasterResult . LogicalSessionTimeout != null || connectionDescription . ServiceId . HasValue ;
40-
41- // snapshot
42- if ( sessionsAreSupported && session . IsSnapshot )
38+ if ( AreSessionsSupported ( connectionDescription ) && session . IsSnapshot )
4339 {
4440 Feature . SnapshotReads . ThrowIfNotSupported ( connectionDescription . ServerVersion ) ;
4541
@@ -48,11 +44,18 @@ private static BsonDocument ToBsonDocument(ICoreSession session, ConnectionDescr
4844 {
4945 readConcernDocument . Add ( "atClusterTime" , session . SnapshotTime ) ;
5046 }
47+
5148 return readConcernDocument ;
5249 }
5350
51+ return null ;
52+ }
53+
54+ // private static methods
55+ private static BsonDocument ToBsonDocument ( ICoreSession session , ConnectionDescription connectionDescription , ReadConcern readConcern )
56+ {
5457 // causal consistency
55- var shouldSendAfterClusterTime = sessionsAreSupported && session . IsCausallyConsistent && session . OperationTime != null ;
58+ var shouldSendAfterClusterTime = AreSessionsSupported ( connectionDescription ) && session . IsCausallyConsistent && session . OperationTime != null ;
5659 var shouldSendReadConcern = ! readConcern . IsServerDefault || shouldSendAfterClusterTime ;
5760
5861 if ( shouldSendReadConcern )
@@ -67,5 +70,8 @@ private static BsonDocument ToBsonDocument(ICoreSession session, ConnectionDescr
6770
6871 return null ;
6972 }
73+
74+ private static bool AreSessionsSupported ( ConnectionDescription connectionDescription ) =>
75+ connectionDescription ? . IsMasterResult . LogicalSessionTimeout != null || connectionDescription ? . ServiceId != null ;
7076 }
7177}
0 commit comments