class Mongo::Event::MemberDiscovered
This handles member discovered events for server descriptions.
@since 2.4.0
Attributes
cluster[R]
@return [ Mongo::Cluster ] cluster The cluster.
monitoring[R]
@return [ Monitoring ] monitoring The monitoring.
options[R]
@return [ Hash ] options The options.
Public Class Methods
new(cluster)
click to toggle source
Initialize the new member discovered event handler.
@example Create the new handler.
MemberDiscovered.new(cluster)
@param [ Mongo::Cluster ] cluster The cluster to publish from.
@since 2.0.0
# File lib/mongo/event/member_discovered.rb, line 43 def initialize(cluster) @cluster = cluster @options = cluster.options @monitoring = cluster.monitoring end
Public Instance Methods
handle(previous, updated)
click to toggle source
This event tells the cluster that a member of a topology is discovered.
@example Handle the event.
member_discovered.handle(previous_description, description)
@param [ Server::Description ] previous The previous description of the server. @param [ Server::Description ] updated The updated description of the server.
@since 2.4.0
# File lib/mongo/event/member_discovered.rb, line 58 def handle(previous, updated) if updated.primary? || updated.mongos? cluster.elect_primary!(updated) else cluster.member_discovered end end