Class: Materialist::Workers::Event

Inherits:
Object
  • Object
show all
Includes:
Sidekiq::Worker
Defined in:
lib/materialist/workers/event.rb

Direct Known Subclasses

EventWorker

Instance Method Summary collapse

Instance Method Details

#perform(event) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/materialist/workers/event.rb', line 9

def perform(event)
  topic = event['topic']
  action = event['type'].to_sym
  timestamp = event['t']

  materializer = Materialist::MaterializerFactory.class_from_topic(topic)
  materializer.perform(event['url'], action)

  report_latency(topic, timestamp) if timestamp
  report_stats(topic, action, :success)
rescue Exception => exception
  report_stats(topic, action, :failure)
  notice_error(exception, event)
  raise
end