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



36
37
38
# File 'lib/mongo/event/primary_elected.rb', line 36

def initialize(cluster)
  @cluster = cluster
end

Instance Attribute Details

#clusterMongo::Cluster (readonly)

Returns cluster The cluster.

Returns:

Since:

  • 2.0.0



26
27
28
# File 'lib/mongo/event/primary_elected.rb', line 26

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



50
51
52
# File 'lib/mongo/event/primary_elected.rb', line 50

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