@@ -33,13 +33,9 @@ public static BsonDocument GetReadConcernForFirstCommandInTransaction(ICoreSessi
33
33
return ToBsonDocument ( session , connectionDescription , readConcern ) ;
34
34
}
35
35
36
- // private static methods
37
- private static BsonDocument ToBsonDocument ( ICoreSession session , ConnectionDescription connectionDescription , ReadConcern readConcern )
36
+ public static BsonDocument GetReadConcernForSnapshotSesssion ( ICoreSession session , ConnectionDescription connectionDescription )
38
37
{
39
- var sessionsAreSupported = connectionDescription . IsMasterResult . LogicalSessionTimeout != null || connectionDescription . ServiceId . HasValue ;
40
-
41
- // snapshot
42
- if ( sessionsAreSupported && session . IsSnapshot )
38
+ if ( AreSessionsSupported ( connectionDescription ) && session . IsSnapshot )
43
39
{
44
40
Feature . SnapshotReads . ThrowIfNotSupported ( connectionDescription . ServerVersion ) ;
45
41
@@ -48,11 +44,18 @@ private static BsonDocument ToBsonDocument(ICoreSession session, ConnectionDescr
48
44
{
49
45
readConcernDocument . Add ( "atClusterTime" , session . SnapshotTime ) ;
50
46
}
47
+
51
48
return readConcernDocument ;
52
49
}
53
50
51
+ return null ;
52
+ }
53
+
54
+ // private static methods
55
+ private static BsonDocument ToBsonDocument ( ICoreSession session , ConnectionDescription connectionDescription , ReadConcern readConcern )
56
+ {
54
57
// causal consistency
55
- var shouldSendAfterClusterTime = sessionsAreSupported && session . IsCausallyConsistent && session . OperationTime != null ;
58
+ var shouldSendAfterClusterTime = AreSessionsSupported ( connectionDescription ) && session . IsCausallyConsistent && session . OperationTime != null ;
56
59
var shouldSendReadConcern = ! readConcern . IsServerDefault || shouldSendAfterClusterTime ;
57
60
58
61
if ( shouldSendReadConcern )
@@ -67,5 +70,8 @@ private static BsonDocument ToBsonDocument(ICoreSession session, ConnectionDescr
67
70
68
71
return null ;
69
72
}
73
+
74
+ private static bool AreSessionsSupported ( ConnectionDescription connectionDescription ) =>
75
+ connectionDescription ? . IsMasterResult . LogicalSessionTimeout != null || connectionDescription ? . ServiceId != null ;
70
76
}
71
77
}
0 commit comments