Class: EventRouter::DeliveryAdapters::Sidekiq

Inherits:
Base
  • Object
show all
Defined in:
lib/event_router/delivery_adapters/sidekiq.rb

Constant Summary collapse

REQUIRED_OPTIONS =
%i[queue retry].freeze

Class Method Summary collapse

Class Method Details

.deliver(event) ⇒ Object



26
27
28
# File 'lib/event_router/delivery_adapters/sidekiq.rb', line 26

def deliver(event)
  Helpers::Sidekiq.process_event(event)
end

.deliver_async(event) ⇒ Object



30
31
32
33
34
35
36
37
# File 'lib/event_router/delivery_adapters/sidekiq.rb', line 30

def deliver_async(event)
  serialized_event  = EventRouter.serialize(event)
  options           = EventRouter::Helpers::Event.event_options(event, self)

  Workers::SidekiqEventDeliveryWorker
    .set(queue: options[:queue], retry: options[:retry])
    .perform_async(serialized_event)
end

.validate_options!(options) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/event_router/delivery_adapters/sidekiq.rb', line 18

def validate_options!(options)
  missing_options = REQUIRED_OPTIONS - options.compact.keys

  return true if missing_options.empty?

  raise Errors::RequiredOptionError.new(options: missing_options, adapter: self)
end