Class: HasuraHandler::EventProcessor

Inherits:
Object
  • Object
show all
Defined in:
lib/hasura_handler/event_processor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(event) ⇒ EventProcessor

Returns a new instance of EventProcessor.



5
6
7
# File 'lib/hasura_handler/event_processor.rb', line 5

def initialize(event)
  @event = HasuraHandler::Event.new(event)
end

Instance Attribute Details

#eventObject

Returns the value of attribute event.



3
4
5
# File 'lib/hasura_handler/event_processor.rb', line 3

def event
  @event
end

Instance Method Details

#processObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/hasura_handler/event_processor.rb', line 13

def process
  event_handlers.each do |handler_class|
    if HasuraHandler.fanout_events
      HasuraHandler::EventHandlerJob.perform_later(handler_class.to_s, @event.raw_event)
    else
      handler = handler_class.new(@event)
      handler.run
    end
  end

  if event_handlers.size == 0
    Rails.logger.debug('[HasuraHandler] Received event with no matching handlers.')
  end
end

#process_laterObject



9
10
11
# File 'lib/hasura_handler/event_processor.rb', line 9

def process_later
  HasuraHandler::EventJob.perform_later(@event.raw_event)
end