Class: Mongo::Monitoring::Event::ServerHeartbeatFailed

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

Overview

Event fired when a server heartbeat is dispatched.

Since:

  • 2.7.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(address, round_trip_time, error, started_event:, awaited: false) ⇒ ServerHeartbeatFailed

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.

ServerHeartbeatSucceeded.new(address, duration)

Parameters:

  • address (Address)

    The server address.

  • round_trip_time (Float)

    Duration of hello call in seconds.

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

    Whether the heartbeat was awaited.

  • started_event (Monitoring::Event::ServerHeartbeatStarted)

    The corresponding started event.

Since:

  • 2.7.0



37
38
39
40
41
42
43
# File 'lib/mongo/monitoring/event/server_heartbeat_failed.rb', line 37

def initialize(address, round_trip_time, error, started_event:, awaited: false)
  @address = address
  @round_trip_time = round_trip_time
  @error = error
  @awaited = !!awaited
  @started_event = started_event
end

Instance Attribute Details

#addressAddress (readonly)

Returns address The server address.

Returns:

  • (Address)

    address The server address.

Since:

  • 2.7.0



46
47
48
# File 'lib/mongo/monitoring/event/server_heartbeat_failed.rb', line 46

def address
  @address
end

#errorException (readonly) Also known as: failure

Returns error The exception that occurred in hello call.

Returns:

  • (Exception)

    error The exception that occurred in hello call.

Since:

  • 2.7.0



55
56
57
# File 'lib/mongo/monitoring/event/server_heartbeat_failed.rb', line 55

def error
  @error
end

#round_trip_timeFloat (readonly) Also known as: duration

Returns round_trip_time Duration of hello call in seconds.

Returns:

  • (Float)

    round_trip_time Duration of hello call in seconds.

Since:

  • 2.7.0



49
50
51
# File 'lib/mongo/monitoring/event/server_heartbeat_failed.rb', line 49

def round_trip_time
  @round_trip_time
end

#started_eventMonitoring::Event::ServerHeartbeatStarted (readonly)

Returns The corresponding started event.

Returns:

Since:

  • 2.7.0



69
70
71
# File 'lib/mongo/monitoring/event/server_heartbeat_failed.rb', line 69

def started_event
  @started_event
end

Instance Method Details

#awaited?true | false

Returns Whether the heartbeat was awaited.

Returns:

  • (true | false)

    Whether the heartbeat was awaited.

Since:

  • 2.7.0



61
62
63
# File 'lib/mongo/monitoring/event/server_heartbeat_failed.rb', line 61

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



79
80
81
82
83
# File 'lib/mongo/monitoring/event/server_heartbeat_failed.rb', line 79

def summary
  "#<#{short_class_name}" +
    " address=#{address}" +
    " error=#{error.inspect}>"
end