Class: Mongo::Server::Description::Inspector::MemberDiscovered

Inherits:
Object
  • Object
show all
Includes:
Event::Publisher
Defined in:
lib/mongo/server/description/inspector/member_discovered.rb

Overview

Handles inspecting the result of an ismaster command to check if this a server is a member of a known topology.

Since:

  • 2.4.0

Instance Attribute Summary

Attributes included from Event::Publisher

#event_listeners

Instance Method Summary collapse

Methods included from Event::Publisher

#publish

Constructor Details

#initialize(event_listeners) ⇒ MemberDiscovered

Instantiate the member discovered inspection.

Examples:

Instantiate the inspection.

MemberDiscovered.new(listeners)

Parameters:

Since:

  • 2.4.0



35
36
37
# File 'lib/mongo/server/description/inspector/member_discovered.rb', line 35

def initialize(event_listeners)
  @event_listeners = event_listeners
end

Instance Method Details

#run(description, updated) ⇒ Object

Run the member discovered inspection.

Examples:

Run the inspection.

MemberDiscovered.run(description, {})

Parameters:

Since:

  • 2.4.0



48
49
50
51
52
53
54
# File 'lib/mongo/server/description/inspector/member_discovered.rb', line 48

def run(description, updated)
  if (!description.primary? && updated.primary?) ||
      (!description.mongos? && updated.mongos?) ||
      (description.unknown? && !updated.unknown?)
    publish(Event::MEMBER_DISCOVERED, description, updated)
  end
end