class Mongo::Monitoring::Event::ServerDescriptionChanged

Event fired when a server’s description changes.

@since 2.4.0

Attributes

address[R]

@return [ Address ] address The server address.

new_description[R]

@return [ Server::Description ] new_description The new server

description.
previous_description[R]

@return [ Server::Description ] previous_description The previous server

description.
topology[R]

@return [ Topology ] topology The topology.

Public Class Methods

new(address, topology, previous_description, new_description, awaited: false ) click to toggle source

Create the event.

@example Create the event.

ServerDescriptionChanged.new(address, topology, previous, new)

@param [ Address ] address The server address. @param [ Integer ] topology The topology. @param [ Server::Description ] previous_description The previous description. @param [ Server::Description ] new_description The new description. @param [ true | false ] awaited Whether the server description was

a result of processing an awaited ismaster response.

@since 2.4.0 @api private

# File lib/mongo/monitoring/event/server_description_changed.rb, line 59
def initialize(address, topology, previous_description, new_description,
  awaited: false
)
  @address = address
  @topology = topology
  @previous_description = previous_description
  @new_description = new_description
  @awaited = !!awaited
end

Public Instance Methods

awaited?() click to toggle source

@return [ true | false ] Whether the heartbeat was awaited.

@api experimental

# File lib/mongo/monitoring/event/server_description_changed.rb, line 41
def awaited?
  @awaited
end
summary() click to toggle source

Returns a concise yet useful summary of the event.

@return [ String ] String summary of the event.

@note This method is experimental and subject to change.

@since 2.7.0 @api experimental

# File lib/mongo/monitoring/event/server_description_changed.rb, line 77
def summary
  "#<#{short_class_name}" +
  " address=#{address}" +
  # TODO Add summaries to descriptions and use them here
  " prev=#{previous_description.server_type.upcase} new=#{new_description.server_type.upcase}#{awaited_indicator}>"
end

Private Instance Methods

awaited_indicator() click to toggle source
# File lib/mongo/monitoring/event/server_description_changed.rb, line 86
def awaited_indicator
  if awaited?
    ' [awaited]'
  else
    ''
  end
end