# File lib/mongo/cluster/sdam_flow.rb, line 364 def publish_description_change_event # updated_desc here may not be the description we received from # the server - in case of a stale primary, the server reported itself # as being a primary but updated_desc here will be unknown. # We do not notify on unknown -> unknown changes. # This can also be important for tests which have real i/o # happening against bogus addresses which yield unknown responses # and that also mock responses with the resulting race condition, # though tests should avoid performing real i/o with monitoring_io: false # option. if updated_desc.unknown? && previous_desc.unknown? return end # Avoid dispatching events when updated description is the same as # previous description. This allows this method to be called multiple # times in the flow when the events should be published, without # worrying about whether there are any unpublished changes. if updated_desc.object_id == previous_desc.object_id return end publish_sdam_event( ::Mongo::Monitoring::SERVER_DESCRIPTION_CHANGED, ::Mongo::Monitoring::Event::ServerDescriptionChanged.new( updated_desc.address, topology, previous_desc, updated_desc, ) ) @previous_desc = updated_desc @need_topology_changed_event = true end