-
Notifications
You must be signed in to change notification settings - Fork 0
Configurations
Those are set of options, the gem exposes to allow you customise the gem behaviour based on your needs. For the full list of options, please check supported options section
The gem exposes a configure
method on the EventRouter
module that yields the configuration instance. You can change the exposed options through their setters.
EventRouter.configure do |config|
# [TODO] Update config
end
EventRouter allows you to change the following configurations:
- Default delivery adapter
- Default serializer adapter
You can change the default delivery adapter through delivery_adapter
method on the configuration instance. For example:
EventRouter.configure do |config|
config.delivery_adapter = :sync
end
In order to use other adapters, e.g Sidekiq, you will need to install Sidekiq gem first, then configure EventRouter
to be able to use it:
EventRouter.configure do |config|
config.register_delivery_adapter :sidekiq, queue: :event_router, retry: 5
config.delivery_adapter = :sidekiq
end
Since each adapter has different setup requirements, configuration instance defines register_delivery_adapter
method to allow you to pass all the needed options to your adapter. EventRouter
already supports Sidekiq
out of the box and requires some attributes to be passed at setup time, e.g queue and retry policy. For other adapters options and to implement your own adapter, please check delivery adapters page
Similarly to delivery adapters, you can change the event serializer adapter through serializer_adapter
method:
EventRouter.configure do |config|
config.serializer_adapter = :json
end
You also can setup custom serializer adapters using config.register_serializer_adapter
, so to use Oj serializer please install Oj gem then:
EventRouter.configure do |config|
config.register_serializer_adapter :oj
config.serializer_adapter = :oj
end