# Copyright (c) 2023 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details. # frozen_string_literal: true require 'contrast/agent/reporting/reporting_utilities/resend' module Contrast module Agent module Reporting # This class will hold the mode state in which the reporter will send # event ot TS. class ResponseHandlerMode # Reader for the running mode type. # # @return [Symbol] Reporter's client and Response Handler are running # and responses are being processed. attr_reader :running # Reader for the disabled mode type. # # @return [Symbol] Reporter's client and Response Handler are disabled # due to received Error. The Reporting is disabled for this application. attr_reader :disabled # Reader for the resending/retry mode type. # # @return [Symbol] Reporter's client and Response Handler are suspended # for a TS received amount of time and will try to resend the previous # request after that. attr_reader :resending # Reader for all supported modes. # # @return [Array] Reporter's client and Response Handler all # available modes of operation. attr_reader :modes def initialize @running = :running @disabled = :disabled @resending = :resending @modes = [@running, @disabled, @resending].cs__freeze end # Current mode. # # @return [Symbol] Reporter's client and Response Handler # current mode of operation. def status @_status ||= running end # Resend Status tracker # # @return [Contrast::Agent::Reporting::Resend::Status] def resend @_resend ||= Contrast::Agent::Reporting::Resend::Status.new end def enter_resend_mode @_status = resending end # Set current mode. # # @return [Symbol] Reporter's client and Response Handler # current mode of operation. def status= mode @_status = mode if mode.cs__is_a?(Symbol) && modes.include?(mode) end # Reset mode # def enter_run_mode @_status = running end end end end end