Class: Katello::CandlepinEventListener
- Inherits:
-
Object
- Object
- Katello::CandlepinEventListener
- Defined in:
- app/services/katello/candlepin_event_listener.rb
Overview
TODO: Move this class to app/lib/katello/event_daemon/services with other service definitions
Defined Under Namespace
Classes: Event
Class Method Summary collapse
- .close ⇒ Object
- .handle_message(message) ⇒ Object
- .logger ⇒ Object
- .reset ⇒ Object
- .run ⇒ Object
- .running? ⇒ Boolean
- .status ⇒ Object
Class Method Details
.close ⇒ Object
19 20 21 22 23 24 |
# File 'app/services/katello/candlepin_event_listener.rb', line 19 def self.close if @client&.close logger.info("Closed candlepin event listener") end reset end |
.handle_message(message) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'app/services/katello/candlepin_event_listener.rb', line 47 def self.() ::Katello::Util::Support.with_db_connection(logger) do subject = "#{message.headers['EVENT_TARGET']}.#{message.headers['EVENT_TYPE']}".downcase cp_event = Event.new(subject, .body) ::Katello::Candlepin::EventHandler.new(logger).handle(cp_event) end @processed_count += 1 rescue => e @failed_count += 1 logger.error("Error handling Candlepin event") logger.error(e.) logger.error(e.backtrace.join("\n")) end |
.logger ⇒ Object
11 12 13 |
# File 'app/services/katello/candlepin_event_listener.rb', line 11 def self.logger ::Foreman::Logging.logger('katello/candlepin_events') end |
.reset ⇒ Object
26 27 28 29 30 |
# File 'app/services/katello/candlepin_event_listener.rb', line 26 def self.reset @processed_count = 0 @failed_count = 0 @client = nil end |
.run ⇒ Object
32 33 34 35 36 37 |
# File 'app/services/katello/candlepin_event_listener.rb', line 32 def self.run @client = client_factory.call @client.subscribe do || () end end |
.running? ⇒ Boolean
15 16 17 |
# File 'app/services/katello/candlepin_event_listener.rb', line 15 def self.running? @client&.running? || false end |
.status ⇒ Object
39 40 41 42 43 44 45 |
# File 'app/services/katello/candlepin_event_listener.rb', line 39 def self.status { processed_count: @processed_count, failed_count: @failed_count, running: running? } end |