Sha256: eb1a728cba5f294c7fc4eb92e282d15ee5292e766d94967e3f820bfa3096cbdf
Contents?: true
Size: 1.6 KB
Versions: 2
Compression:
Stored size: 1.6 KB
Contents
module Katello module EventDaemon module Services class AgentEventReceiver STATUS_CACHE_KEY = 'katello_agent_events'.freeze class Handler attr_accessor :processed, :failed def initialize @processed = 0 @failed = 0 end def handle(message) ::Katello::Util::Support.with_db_connection do ::Katello::Agent::ClientMessageHandler.new(message).handle @processed += 1 rescue => e @failed += 1 Rails.logger.error("Error handling Katello Agent client message") Rails.logger.error(e.message) Rails.logger.error(e.backtrace.join("\n")) end end end def self.logger ::Foreman::Logging.logger('katello/agent') end def self.run fail("Katello agent event receiver already started") if running? @thread = Thread.new do @handler = Handler.new agent_connection = ::Katello::Agent::Connection.new agent_connection.fetch_agent_messages(@handler) end end def self.close @thread&.kill end def self.running? @thread&.status.present? end def self.status(refresh: true) Rails.cache.fetch(STATUS_CACHE_KEY, force: refresh) do { running: running?, processed_count: @handler&.processed || 0, failed_count: @handler&.failed || 0 } end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
katello-4.0.0.rc3 | app/lib/katello/event_daemon/services/agent_event_receiver.rb |
katello-4.0.0.rc2 | app/lib/katello/event_daemon/services/agent_event_receiver.rb |