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
25
26
27
28
29
30
31
32
33
34
35
36
# 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 /entitlement\.created/
      message_handler.import_pool
      message_handler.create_pool_on_host
    when /entitlement\.deleted/
      message_handler.import_pool
      message_handler.remove_pool_from_host
    when /pool\.created/
      message_handler.import_pool
    when /pool\.deleted/
      message_handler.delete_pool
    when /^compliance\.created/
      reindex_subscription_status
    when /system_purpose_compliance\.created/
      reindex_purpose_status
    when /owner_content_access_mode\.modified/
      message_handler.handle_content_access_mode_modified
    end
  end
end