Sha256: dc5b377d5cf41ea11546e676c9fbbce601b771319f711e2767cfa82c6b21f871
Contents?: true
Size: 1.69 KB
Versions: 2
Compression:
Stored size: 1.69 KB
Contents
# Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details. # frozen_string_literal: true require 'contrast/agent/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 if running? @_thread = Contrast::Agent::Thread.new do logger.info('[ServerSettingsWorker] Starting thread.', sending_interval: server_settings_resend_ms) loop do 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
2 entries across 2 versions & 1 rubygems