@@ -38,6 +38,7 @@ public class ClusterSettings
38
38
private readonly ClusterConnectionMode _connectionMode ;
39
39
private readonly IReadOnlyList < EndPoint > _endPoints ;
40
40
private readonly IReadOnlyDictionary < string , IReadOnlyDictionary < string , object > > _kmsProviders ;
41
+ private readonly TimeSpan _localThreshold ;
41
42
private readonly int _maxServerSelectionWaitQueueSize ;
42
43
private readonly string _replicaSetName ;
43
44
private readonly IReadOnlyDictionary < string , BsonDocument > _schemaMap ;
@@ -53,6 +54,7 @@ public class ClusterSettings
53
54
/// <param name="connectionMode">The connection mode.</param>
54
55
/// <param name="endPoints">The end points.</param>
55
56
/// <param name="kmsProviders">The kms providers.</param>
57
+ /// <param name="localThreshold">The local threshold.</param>
56
58
/// <param name="maxServerSelectionWaitQueueSize">Maximum size of the server selection wait queue.</param>
57
59
/// <param name="replicaSetName">Name of the replica set.</param>
58
60
/// <param name="serverSelectionTimeout">The server selection timeout.</param>
@@ -64,6 +66,7 @@ public ClusterSettings(
64
66
Optional < ClusterConnectionMode > connectionMode = default ( Optional < ClusterConnectionMode > ) ,
65
67
Optional < IEnumerable < EndPoint > > endPoints = default ( Optional < IEnumerable < EndPoint > > ) ,
66
68
Optional < IReadOnlyDictionary < string , IReadOnlyDictionary < string , object > > > kmsProviders = default ( Optional < IReadOnlyDictionary < string , IReadOnlyDictionary < string , object > > > ) ,
69
+ Optional < TimeSpan > localThreshold = default ,
67
70
Optional < int > maxServerSelectionWaitQueueSize = default ( Optional < int > ) ,
68
71
Optional < string > replicaSetName = default ( Optional < string > ) ,
69
72
Optional < TimeSpan > serverSelectionTimeout = default ( Optional < TimeSpan > ) ,
@@ -75,6 +78,7 @@ public ClusterSettings(
75
78
_connectionMode = connectionMode . WithDefault ( ClusterConnectionMode . Automatic ) ;
76
79
_endPoints = Ensure . IsNotNull ( endPoints . WithDefault ( __defaultEndPoints ) , "endPoints" ) . ToList ( ) ;
77
80
_kmsProviders = kmsProviders . WithDefault ( null ) ;
81
+ _localThreshold = Ensure . IsGreaterThanOrEqualToZero ( localThreshold . WithDefault ( TimeSpan . FromMilliseconds ( 15 ) ) , "localThreshold" ) ;
78
82
_maxServerSelectionWaitQueueSize = Ensure . IsGreaterThanOrEqualToZero ( maxServerSelectionWaitQueueSize . WithDefault ( 500 ) , "maxServerSelectionWaitQueueSize" ) ;
79
83
_replicaSetName = replicaSetName . WithDefault ( null ) ;
80
84
_serverSelectionTimeout = Ensure . IsGreaterThanOrEqualToZero ( serverSelectionTimeout . WithDefault ( TimeSpan . FromSeconds ( 30 ) ) , "serverSelectionTimeout" ) ;
@@ -118,6 +122,17 @@ public IReadOnlyDictionary<string, IReadOnlyDictionary<string, object>> KmsProvi
118
122
get { return _kmsProviders ; }
119
123
}
120
124
125
+ /// <summary>
126
+ /// Gets the local threshold.
127
+ /// </summary>
128
+ /// <value>
129
+ /// The local threshold.
130
+ /// </value>
131
+ public TimeSpan LocalThreshold
132
+ {
133
+ get { return _localThreshold ; }
134
+ }
135
+
121
136
/// <summary>
122
137
/// Gets the maximum size of the server selection wait queue.
123
138
/// </summary>
@@ -202,6 +217,7 @@ public IServerSelector PostServerSelector
202
217
/// <param name="connectionMode">The connection mode.</param>
203
218
/// <param name="endPoints">The end points.</param>
204
219
/// <param name="kmsProviders">The kms providers.</param>
220
+ /// <param name="localThreshold">The local threshold.</param>
205
221
/// <param name="maxServerSelectionWaitQueueSize">Maximum size of the server selection wait queue.</param>
206
222
/// <param name="replicaSetName">Name of the replica set.</param>
207
223
/// <param name="serverSelectionTimeout">The server selection timeout.</param>
@@ -214,6 +230,7 @@ public ClusterSettings With(
214
230
Optional < ClusterConnectionMode > connectionMode = default ( Optional < ClusterConnectionMode > ) ,
215
231
Optional < IEnumerable < EndPoint > > endPoints = default ( Optional < IEnumerable < EndPoint > > ) ,
216
232
Optional < IReadOnlyDictionary < string , IReadOnlyDictionary < string , object > > > kmsProviders = default ( Optional < IReadOnlyDictionary < string , IReadOnlyDictionary < string , object > > > ) ,
233
+ Optional < TimeSpan > localThreshold = default ( Optional < TimeSpan > ) ,
217
234
Optional < int > maxServerSelectionWaitQueueSize = default ( Optional < int > ) ,
218
235
Optional < string > replicaSetName = default ( Optional < string > ) ,
219
236
Optional < TimeSpan > serverSelectionTimeout = default ( Optional < TimeSpan > ) ,
@@ -226,6 +243,7 @@ public ClusterSettings With(
226
243
connectionMode : connectionMode . WithDefault ( _connectionMode ) ,
227
244
endPoints : Optional . Enumerable ( endPoints . WithDefault ( _endPoints ) ) ,
228
245
kmsProviders : Optional . Create ( kmsProviders . WithDefault ( _kmsProviders ) ) ,
246
+ localThreshold : localThreshold . WithDefault ( _localThreshold ) ,
229
247
maxServerSelectionWaitQueueSize : maxServerSelectionWaitQueueSize . WithDefault ( _maxServerSelectionWaitQueueSize ) ,
230
248
replicaSetName : replicaSetName . WithDefault ( _replicaSetName ) ,
231
249
serverSelectionTimeout : serverSelectionTimeout . WithDefault ( _serverSelectionTimeout ) ,
0 commit comments