Class: Mongo::Monitoring::Event::ServerDescriptionChanged

Inherits:
Event::Base
  • Object
show all
Defined in:
lib/mongo/monitoring/event/server_description_changed.rb

Overview

Event fired when a server’s description changes.

Since:

  • 2.4.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(address, topology, previous_description, new_description, awaited: false) ⇒ ServerDescriptionChanged

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Create the event.

Examples:

Create the event.

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

Parameters:

  • address (Address)

    The server address.

  • topology (Integer)

    The topology.

  • previous_description (Server::Description)

    The previous description.

  • new_description (Server::Description)

    The new description.

  • awaited (true | false) (defaults to: false)

    Whether the server description was a result of processing an awaited hello response.

Since:

  • 2.4.0



62
63
64
65
66
67
68
69
70
# File 'lib/mongo/monitoring/event/server_description_changed.rb', line 62

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

Instance Attribute Details

#addressAddress (readonly)

Returns address The server address.

Returns:

  • (Address)

    address The server address.

Since:

  • 2.4.0



28
29
30
# File 'lib/mongo/monitoring/event/server_description_changed.rb', line 28

def address
  @address
end

#new_descriptionServer::Description (readonly)

Returns new_description The new server description.

Returns:

Since:

  • 2.4.0



39
40
41
# File 'lib/mongo/monitoring/event/server_description_changed.rb', line 39

def new_description
  @new_description
end

#previous_descriptionServer::Description (readonly)

Returns previous_description The previous server description.

Returns:

Since:

  • 2.4.0



35
36
37
# File 'lib/mongo/monitoring/event/server_description_changed.rb', line 35

def previous_description
  @previous_description
end

#topologyTopology (readonly)

Returns topology The topology.

Returns:

  • (Topology)

    topology The topology.

Since:

  • 2.4.0



31
32
33
# File 'lib/mongo/monitoring/event/server_description_changed.rb', line 31

def topology
  @topology
end

Instance Method Details

#awaited?true | false

Returns Whether the heartbeat was awaited.

Returns:

  • (true | false)

    Whether the heartbeat was awaited.

Since:

  • 2.4.0



44
45
46
# File 'lib/mongo/monitoring/event/server_description_changed.rb', line 44

def awaited?
  @awaited
end

#summaryString

Note:

This method is experimental and subject to change.

Returns a concise yet useful summary of the event.

Returns:

  • (String)

    String summary of the event.

Since:

  • 2.7.0



80
81
82
83
84
85
# File 'lib/mongo/monitoring/event/server_description_changed.rb', line 80

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