class Mongo::Server::Description::Inspector::PrimaryElected

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

@since 2.0.0

@deprecated. Will be removed in 3.0

Public Class Methods

new(event_listeners) click to toggle source

Instantiate the primary elected inspection.

@example Instantiate the inspection.

PrimaryElected.new(listeners)

@param [ Event::Listeners ] event_listeners The event listeners.

@since 2.0.0

# File lib/mongo/server/description/inspector/primary_elected.rb, line 37
def initialize(event_listeners)
  @event_listeners = event_listeners
end

Public Instance Methods

run(description, updated) click to toggle source

Run the primary elected inspection.

@example Run the inspection.

PrimaryElected.run(description, {})

@param [ Description ] description The server description. @param [ Description ] updated The updated description.

@since 2.0.0

# 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