Skip to content

Delivery Adapters

Ahmad Elassuty edited this page Feb 2, 2021 · 2 revisions

EventRouter allows you to configure how your events are delivered to their destinations. EventRouter currently supports two different delivery adapters:

Sync (default)

Sync is the default delivery adapter because it does not require any dependencies. It will block the current thread, till all destinations perform their logic.

(Non-Atomic) If any of the destinations raised an exception, the event won't be delivered to the remaining destinations, and the ones that already processed won't be rolled-back.

Sidekiq adapter is for asynchronously processing your event destinations.

(Isolated Destinations) EventRouter will schedule one worker per each event destination. So if any of the destinations failed at process time, they won't affect the other destinations.

For configurations please check, change delivery adapter

Define your custom adapter

It is easy to add a new adapter for the backend of your choice. EventRouter will support more backends, e.g Sneakers.

To add your own custom adapter:

  • create a new class that inherits from EventRouter::DeliveryAdapters::Base
class SidekiqDeliveryAdapter < EventRouter::DeliveryAdapters::Base; end
  • Define deliver method that should accept an event.

  • Define deliver_async method that should accept an event and deliver it to its destinations without blocking the current thread.

  • Register your adapter as explained in the Configurations Wiki

You can check Sidekiq adapter implementation here.

Clone this wiki locally