Class: Katello::Candlepin::EventHandler

Inherits:
Object
  • Object
show all
Defined in:
app/services/katello/candlepin/event_handler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(logger) ⇒ EventHandler

Returns a new instance of EventHandler.



6
7
8
# File 'app/services/katello/candlepin/event_handler.rb', line 6

def initialize(logger)
  @logger = logger
end

Instance Attribute Details

#message_handlerObject (readonly)

Returns the value of attribute message_handler.



4
5
6
# File 'app/services/katello/candlepin/event_handler.rb', line 4

def message_handler
  @message_handler
end

Instance Method Details

#handle(message) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/services/katello/candlepin/event_handler.rb', line 10

def handle(message)
  ::User.current = ::User.anonymous_admin

  Katello::Logging.time("candlepin event handled", logger: @logger) do |data|
    data[:subject] = message.subject
    @message_handler = ::Katello::Candlepin::MessageHandler.new(message)
    data[:entity_id] = @message_handler.entity_id
    case message_handler.subject
    when /pool\.created/
      message_handler.import_pool
    when /pool\.deleted/
      message_handler.delete_pool
    end
  end
end