Class: Contrast::Agent::ServiceHeartbeat

Inherits:
WorkerThread show all
Includes:
Components::Interface
Defined in:
lib/contrast/agent/service_heartbeat.rb

Overview

The ServiceHeartbeat functions to keep the Contrast Service alive and ensure that it maintains this Agent’s ApplicationContext.

Constant Summary collapse

REFRESH_INTERVAL_SEC =

Spec recommends 30 seconds, we’re going with 15.

15

Instance Method Summary collapse

Methods included from Components::Interface

included

Methods inherited from WorkerThread

#initialize, #running?, #stop!

Constructor Details

This class inherits a constructor from Contrast::Agent::WorkerThread

Instance Method Details

#poll_messageObject



32
33
34
# File 'lib/contrast/agent/service_heartbeat.rb', line 32

def poll_message
  @_poll_message ||= Contrast::Api::Dtm::Poll.new
end

#start_thread!Object



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/contrast/agent/service_heartbeat.rb', line 18

def start_thread!
  return if running?

  @_thread = Contrast::Agent::Thread.new do
    logger.info('Starting heartbeat thread.')
    loop do
      begin
        Contrast::Agent.messaging_queue.send_event_eventually(poll_message)
      end
      sleep REFRESH_INTERVAL_SEC
    end
  end
end