Class: Mongo::Server::Description::Inspector::PrimaryElected

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

Overview

Handles inspecting the result of an ismaster command to check if this server was elected primary.

Since:

  • 2.0.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) ⇒ PrimaryElected

Instantiate the primary elected inspection.

Examples:

Instantiate the inspection.

PrimaryElected.new(listeners)

Parameters:

Since:

  • 2.0.0



37
38
39
# File 'lib/mongo/server/description/inspector/primary_elected.rb', line 37

def initialize(event_listeners)
  @event_listeners = event_listeners
end

Instance Method Details

#run(description, updated) ⇒ Object

Run the primary elected inspection.

Examples:

Run the inspection.

PrimaryElected.run(description, {})

Parameters:

Since:

  • 2.0.0



50
51
52
53
54
55
# File 'lib/mongo/server/description/inspector/primary_elected.rb', line 50

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