Module: EventRouter::Publisher

Defined in:
lib/event_router/publisher.rb

Constant Summary collapse

ADAPTERS =
{
  sync: { adapter_class: 'EventRouter::DeliveryAdapters::Sync', path: 'delivery_adapters/sync' },
  sidekiq: { adapter_class: 'EventRouter::DeliveryAdapters::Sidekiq', path: 'delivery_adapters/sidekiq' }
}.freeze

Class Method Summary collapse

Class Method Details

.publish(events, adapter:) ⇒ Object



12
13
14
15
16
# File 'lib/event_router/publisher.rb', line 12

def publish(events, adapter:)
  adapter_class = delivery_adapter(adapter)

  Array(events).each { |event| adapter_class.deliver(event) }
end

.publish_async(events, adapter:) ⇒ Object



18
19
20
21
22
# File 'lib/event_router/publisher.rb', line 18

def publish_async(events, adapter:)
  adapter_class = delivery_adapter(adapter)

  Array(events).each { |event| adapter_class.deliver_async(event) }
end