class Mongo::Event::DescriptionChanged

This handles a change in description.

@since 2.0.6

Attributes

cluster[R]

@return [ Mongo::Cluster ] cluster The cluster.

monitoring[R]

@return [ Monitoring ] monitoring The monitoring.

options[R]

@return [ Hash ] options The options.

Public Class Methods

new(cluster) click to toggle source

Initialize the new host added event handler.

@example Create the new handler.

ServerAdded.new(cluster)

@param [ Mongo::Cluster ] cluster The cluster to publish from.

@since 2.0.0

# File lib/mongo/event/description_changed.rb, line 42
def initialize(cluster)
  @cluster = cluster
  @options = cluster.options
  @monitoring = cluster.monitoring
end

Public Instance Methods

handle(previous, updated) click to toggle source

This event publishes an event to add the cluster and logs the configuration change.

@example Handle the event.

server_added.handle('127.0.0.1:27018')

@param [ Server::Description ] updated The changed description.

@since 2.0.0

# File lib/mongo/event/description_changed.rb, line 57
def handle(previous, updated)
  publish_sdam_event(
    Monitoring::SERVER_DESCRIPTION_CHANGED,
    Monitoring::Event::ServerDescriptionChanged.new(
      updated.address,
      cluster.topology,
      previous,
      updated
    )
  )
  cluster.add_hosts(updated)
  cluster.remove_hosts(updated)
end