@@ -187,7 +187,7 @@ def count(opts = {})
187187 session : session ,
188188 operation_timeouts : operation_timeouts ( opts )
189189 )
190- read_with_retry ( session , selector ) do |server |
190+ read_with_retry ( session , selector , context ) do |server |
191191 Operation ::Count . new (
192192 selector : cmd ,
193193 db_name : database . name ,
@@ -237,7 +237,7 @@ def count_documents(opts = {})
237237 pipeline << { :'$limit' => opts [ :limit ] } if opts [ :limit ]
238238 pipeline << { :'$group' => { _id : 1 , n : { :'$sum' => 1 } } }
239239
240- opts = opts . slice ( :hint , :max_time_ms , :read , :collation , :session , :comment )
240+ opts = opts . slice ( :hint , :max_time_ms , :read , :collation , :session , :comment , :timeout_ms )
241241 opts [ :collation ] ||= collation
242242
243243 first = aggregate ( pipeline , opts ) . first
@@ -279,12 +279,12 @@ def estimated_document_count(opts = {})
279279 read_pref = opts [ :read ] || read_preference
280280 selector = ServerSelector . get ( read_pref || server_selector )
281281 with_session ( opts ) do |session |
282- read_with_retry ( session , selector ) do | server |
283- context = Operation :: Context . new (
284- client : client ,
285- session : session ,
286- operation_timeouts : operation_timeouts ( opts )
287- )
282+ context = Operation :: Context . new (
283+ client : client ,
284+ session : session ,
285+ operation_timeouts : operation_timeouts ( opts )
286+ )
287+ read_with_retry ( session , selector , context ) do | server |
288288 cmd = { count : collection . name }
289289 cmd [ :maxTimeMS ] = opts [ :max_time_ms ] if opts [ :max_time_ms ]
290290 if read_concern
@@ -347,7 +347,12 @@ def distinct(field_name, opts = {})
347347 read_pref = opts [ :read ] || read_preference
348348 selector = ServerSelector . get ( read_pref || server_selector )
349349 with_session ( opts ) do |session |
350- read_with_retry ( session , selector ) do |server |
350+ context = Operation ::Context . new (
351+ client : client ,
352+ session : session ,
353+ operation_timeouts : operation_timeouts ( opts )
354+ )
355+ read_with_retry ( session , selector , context ) do |server |
351356 Operation ::Distinct . new (
352357 selector : cmd ,
353358 db_name : database . name ,
@@ -360,11 +365,7 @@ def distinct(field_name, opts = {})
360365 collation : opts [ :collation ] || opts [ 'collation' ] || collation ,
361366 ) . execute (
362367 server ,
363- context : Operation ::Context . new (
364- client : client ,
365- session : session ,
366- operation_timeouts : operation_timeouts ( opts )
367- )
368+ context : context
368369 )
369370 end . first [ 'values' ]
370371 end
0 commit comments