Class: Eventsimple::ReactorWorker

Inherits:
Object
  • Object
show all
Includes:
Sidekiq::Worker
Defined in:
lib/eventsimple/reactor_worker.rb

Instance Method Summary collapse

Instance Method Details

#perform(event_global_id, reactor_class) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/eventsimple/reactor_worker.rb', line 8

def perform(event_global_id, reactor_class)
  gid = GlobalID.parse(event_global_id)

  event = Retriable.with_context(:reactor) do
    gid.model_class.uncached { GlobalID::Locator.locate event_global_id }
  end
rescue ActiveRecord::RecordNotFound
  Rails.logger.error("Event #{event_global_id} not found for reactor: #{reactor_class}")
else
  reactor = reactor_class.constantize
  reactor.new.call(event)
end