Sha256: e91aff43f1a8a1b5d9c43d589cd3e2b8af1d74163acd5f1d1eb94eb5000d8738
Contents?: true
Size: 1.13 KB
Versions: 3
Compression:
Stored size: 1.13 KB
Contents
# Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details. # frozen_string_literal: true cs__scoped_require 'contrast/components/interface' module Contrast module Agent # The ServiceHeartbeat functions to keep the Contrast Service alive and # ensure that it maintains this Agent's ApplicationContext. class ServiceHeartbeat include Contrast::Components::Interface access_component :logging # Spec recommends 30 seconds, we're going with 15. REFRESH_INTERVAL_SEC = 15 def updater_thread @_updater_thread ||= Contrast::Agent::Thread.new do logger.info('Starting heartbeat thread.') loop do begin Contrast::Utils::ServiceSenderUtil.push_to_ready_queue(poll_message) end sleep REFRESH_INTERVAL_SEC end end end alias_method :start, :updater_thread def poll_message @_poll_message ||= Contrast::Api::Dtm::Poll.new end def stop Thread.kill(@_updater_thread) if @_updater_thread&.alive? end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
contrast-agent-3.12.2 | lib/contrast/agent/service_heartbeat.rb |
contrast-agent-3.12.1 | lib/contrast/agent/service_heartbeat.rb |
contrast-agent-3.12.0 | lib/contrast/agent/service_heartbeat.rb |