Sha256: fb362c12f8430f3bbfda7ebb169b6caf9cb99621ed3b2410a8ce1be9f92e0128
Contents?: true
Size: 1.83 KB
Versions: 10
Compression:
Stored size: 1.83 KB
Contents
# Copyright (c) 2023 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details. # frozen_string_literal: true require 'contrast/agent/thread/worker_thread' require 'contrast/agent/reporting/report' module Contrast module Agent module ReportingWorkers # The ApplicationServerWorker will send request on interval, to make sure the Agent gets the settings it # need to operate, from TS. This Thead should be started after the ApplicationStartup is complete. class ApplicationServerWorker < WorkerThread RESEND_INTERVAL_MS = 30_000.cs__freeze def start_thread! return unless attempt_to_start? return if running? @_thread = Contrast::Agent::Thread.new do logger.info('[ApplicationSettingsWorker] Starting thread.', sending_interval: application_server_ms) loop do break unless attempt_to_start? logger.info('[ApplicationSettingsWorker] Fetching Settings', sending_interval: application_server_ms) Contrast::Agent.reporter&.send_event(application_settings_message) sleep(application_server_ms / 1000) end end end private # This method will generate the reporting event for the application settings # # @return [Contrast::Agent::Reporting::ReportingEvent] def application_settings_message @_application_settings_message ||= Contrast::Agent::Reporting::ApplicationSettings.new end # Get the value from settings or use the default one. # # @return resend_ms [Integer] time to resend the message def application_server_ms @_application_server_ms ||= Contrast::AGENT.polling.app_settings_ms&.to_i || RESEND_INTERVAL_MS end end end end end
Version data entries
10 entries across 10 versions & 1 rubygems