Sha256: f11f7820aa259fca03810ae0ebf0f9e536e56ab9f5016911ba61253b902f0995
Contents?: true
Size: 1.78 KB
Versions: 10
Compression:
Stored size: 1.78 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 ServerSettingsWorker 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 AgentStartup is complete. class ServerSettingsWorker < WorkerThread RESEND_INTERVAL_MS = 60_000.cs__freeze def start_thread! return unless attempt_to_start? return if running? @_thread = Contrast::Agent::Thread.new do logger.info('[ServerSettingsWorker] Starting thread.', sending_interval: server_settings_resend_ms) loop do break unless attempt_to_start? logger.info('[ServerSettingsWorker] Fetching Settings', sending_interval: server_settings_resend_ms) Contrast::Agent.reporter&.send_event(settings_message) sleep(server_settings_resend_ms / 1000) end end end private # Polling messages for this thread. Including Server settings: # # @return [Contrast::Agent::Reporting::ReportingEvent] def settings_message @_settings_message ||= Contrast::Agent::Reporting::ServerSettings.new end # Get the value from settings or use the default one. # # @return resend_ms [Integer] time to resend the message def server_settings_resend_ms @_server_settings_resend_ms ||= Contrast::AGENT.polling.server_settings_ms&.to_i || RESEND_INTERVAL_MS end end end end end
Version data entries
10 entries across 10 versions & 1 rubygems