Class: Mongo::Server::RoundTripTimeAverager Private
- Inherits:
-
Object
- Object
- Mongo::Server::RoundTripTimeAverager
- Defined in:
- build/ruby-driver-v2.19/lib/mongo/server/round_trip_time_averager.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Attribute Summary collapse
- #average_round_trip_time ⇒ Object readonly private
- #last_round_trip_time ⇒ Object readonly private
Instance Method Summary collapse
-
#initialize ⇒ RoundTripTimeAverager
constructor
private
A new instance of RoundTripTimeAverager.
- #measure ⇒ Object private
Constructor Details
#initialize ⇒ RoundTripTimeAverager
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of RoundTripTimeAverager.
28 29 30 31 |
# File 'build/ruby-driver-v2.19/lib/mongo/server/round_trip_time_averager.rb', line 28 def initialize @last_round_trip_time = nil @average_round_trip_time = nil end |
Instance Attribute Details
#average_round_trip_time ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
34 35 36 |
# File 'build/ruby-driver-v2.19/lib/mongo/server/round_trip_time_averager.rb', line 34 def average_round_trip_time @average_round_trip_time end |
#last_round_trip_time ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
33 34 35 |
# File 'build/ruby-driver-v2.19/lib/mongo/server/round_trip_time_averager.rb', line 33 def last_round_trip_time @last_round_trip_time end |
Instance Method Details
#measure ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'build/ruby-driver-v2.19/lib/mongo/server/round_trip_time_averager.rb', line 36 def measure start = Utils.monotonic_time begin rv = yield rescue Error::SocketError, Error::SocketTimeoutError # If we encountered a network error, the round-trip is not # complete and thus RTT for it does not make sense. raise rescue Error, Error::AuthError => exc # For other errors, RTT is valid. end last_round_trip_time = Utils.monotonic_time - start # If hello fails, we need to return the last round trip time # because it is used in the heartbeat failed SDAM event, # but we must not update the round trip time recorded in the server. unless exc @last_round_trip_time = last_round_trip_time update_average_round_trip_time end if exc raise exc else rv end end |