Class: Contrast::Agent::ReactionProcessor
- Includes:
- Components::Interface
- Defined in:
- lib/contrast/agent/reaction_processor.rb
Overview
Because communication between the Agent/Service and TeamServer can only be initiated by outbound connections from the Agent/Service, we must provide a mechanism for the TeamServer to direct the Agent to take a specific action. This action is referred to as a Reaction. This class is how we handle those Reaction messages.
Class Method Summary collapse
-
.process(application_settings) ⇒ Object
Process the given Reactions from the application settings based on what TeamServer has indicated.
Methods included from Components::Interface
Class Method Details
.process(application_settings) ⇒ Object
Process the given Reactions from the application settings based on what TeamServer has indicated. Each Reaction will result in a log message and, optionally, an action.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/contrast/agent/reaction_processor.rb', line 24 def self.process application_settings return nil unless application_settings&.reactions&.any? application_settings.reactions.each do |reaction| # the enums are all uppercase, we need to downcase them before attempting to log level = reaction.log_level.nil? ? :error : reaction.log_level.name.downcase logger.with_level(level, reaction.) if reaction. case reaction.operation when Contrast::Api::Settings::Reaction::Operation::DISABLE Contrast::Agent::DisableReaction.run reaction, level when Contrast::Api::Settings::Reaction::Operation::NOOP # NOOP else logger.warn( 'ReactionProcessor received a reaction with an unknown operation', operation: reaction.operation) end end end |