class Materialist::EventHandler

Constants

DEFAULT_SIDEKIQ_OPTIONS

Public Instance Methods

call(event) click to toggle source
# File lib/materialist/event_handler.rb, line 14
def call(event)
  worker(topic(event)).perform_async(event)
end
on_events_received(batch) click to toggle source
# File lib/materialist/event_handler.rb, line 10
def on_events_received(batch)
  batch.each { |event| call(event) if should_materialize?(topic(event)) }
end

Private Instance Methods

materializer_sidekiq_options(topic) click to toggle source
# File lib/materialist/event_handler.rb, line 40
def materializer_sidekiq_options(topic)
  Materialist::MaterializerFactory.class_from_topic(topic)._sidekiq_options
end
should_materialize?(topic) click to toggle source
# File lib/materialist/event_handler.rb, line 24
def should_materialize?(topic)
  Materialist.configuration.topics.include?(topic)
end
sidekiq_options(topic) click to toggle source
# File lib/materialist/event_handler.rb, line 28
def sidekiq_options(topic)
  [
    DEFAULT_SIDEKIQ_OPTIONS,
    Materialist.configuration.sidekiq_options,
    materializer_sidekiq_options(topic)
  ].inject(:merge)
end
topic(event) click to toggle source
# File lib/materialist/event_handler.rb, line 20
def topic(event)
  event['topic'].to_s
end
worker(topic) click to toggle source
# File lib/materialist/event_handler.rb, line 36
def worker(topic)
  Materialist::Workers::Event.set(sidekiq_options(topic))
end