class Mongo::Server::Description::Inspector
Handles inspection of an updated server description to determine if events should be fired.
@since 2.0.0
Constants
- INSPECTORS
Static list of inspections that are performed on the result of an ismaster command in order to generate the appropriate events for the changes.
@since 2.0.0
Attributes
inspectors[R]
@return [ Array ] inspectors The description inspectors.
Public Class Methods
new(listeners)
click to toggle source
Create the new inspector.
@example Create the new inspector.
Inspector.new(listeners)
@param [ Event::Listeners ] listeners The event listeners.
@since 2.0.0
# File lib/mongo/server/description/inspector.rb, line 51 def initialize(listeners) @inspectors = INSPECTORS.map do |inspector| inspector.new(listeners) end end
Public Instance Methods
run(description, ismaster, average_round_trip_time)
click to toggle source
Run the server description inspector.
@example Run the inspector.
inspector.run(description, { 'ismaster' => true })
@param [ Description ] description The old description. @param [ Hash ] ismaster The updated ismaster. @param [ Float ] average_round_trip_time The moving average round trip time (ms).
@return [ Description ] The new description.
@since 2.0.0
# File lib/mongo/server/description/inspector.rb, line 69 def run(description, ismaster, average_round_trip_time) new_description = Description.new(description.address, ismaster, average_round_trip_time) inspectors.each do |inspector| inspector.run(description, new_description) end new_description end