Class: Mongo::Event::PrimaryElected

Inherits:
Object
  • Object
show all
Defined in:
lib/mongo/event/primary_elected.rb

Overview

This handles primary elected events for server descriptions.

Since:

  • 2.0.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cluster) ⇒ PrimaryElected

Initialize the new primary elected event handler.

Examples:

Create the new handler.

PrimaryElected.new(cluster)

Parameters:

Since:

  • 2.0.0



34
35
36
# File 'lib/mongo/event/primary_elected.rb', line 34

def initialize(cluster)
  @cluster = cluster
end

Instance Attribute Details

#clusterMongo::Cluster (readonly)

Returns cluster The event publisher.

Returns:

Since:

  • 2.0.0



24
25
26
# File 'lib/mongo/event/primary_elected.rb', line 24

def cluster
  @cluster
end

Instance Method Details

#handle(description) ⇒ Object

This event tells the cluster to take all previous primaries to an unknown state.

Examples:

Handle the event.

primary_elected.handle(description)

Parameters:

Since:

  • 2.0.0



48
49
50
# File 'lib/mongo/event/primary_elected.rb', line 48

def handle(description)
  cluster.elect_primary!(description)
end