lib/mongo/cluster/sdam_flow.rb in mongo-2.13.0.beta1 vs lib/mongo/cluster/sdam_flow.rb in mongo-2.13.0.rc1

- old
+ new

@@ -23,16 +23,17 @@ # # @api private class SdamFlow extend Forwardable - def initialize(cluster, previous_desc, updated_desc) + def initialize(cluster, previous_desc, updated_desc, awaited: false) @cluster = cluster @topology = cluster.topology @original_desc = @previous_desc = previous_desc @updated_desc = updated_desc @servers_to_disconnect = [] + @awaited = !!awaited end attr_reader :cluster def_delegators :cluster, :servers_list, :seeds, @@ -49,10 +50,14 @@ attr_reader :previous_desc attr_reader :updated_desc attr_reader :original_desc + def awaited? + @awaited + end + def_delegators :topology, :replica_set_name # Updates descriptions on all servers whose address matches # updated_desc's address. def update_server_descriptions @@ -429,19 +434,16 @@ # 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 + # We used to not notify on Unknown -> Unknown server changes. + # Technically these are valid state changes (or at least as valid as + # other server description changes when the description has not + # changed meaningfully but the events are still published). + # The current version of the driver notifies on Unknown -> Unknown + # transitions. # 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. @@ -454,9 +456,10 @@ ::Mongo::Monitoring::Event::ServerDescriptionChanged.new( updated_desc.address, topology, previous_desc, updated_desc, + awaited: awaited?, ) ) @previous_desc = updated_desc @need_topology_changed_event = true end