Module: Omnes::Subscriber::Adapter::Sidekiq
- Extended by:
- Configurable
- Defined in:
- lib/omnes/subscriber/adapter/sidekiq.rb
Overview
Sidekiq adapter
Builds subscription to be processed as Sidekiq's background jobs.
Sidekiq requires that the argument passed to #perform
is serializable.
By default, the result of calling #payload
in the event is taken.
class MySubscriber
include Omnes::Subscriber
include Sidekiq::Job
handle :my_event, with: Adapter::Sidekiq
def perform(payload)
# do_something
end
end
bus = Omnes::Bus.new
bus.register(:my_event)
bus.publish(:my_event, "foo" => "bar")
However, you can configure how the event is serialized thanks to the
serializer:
option. It needs to be something callable taking the
event as argument:
handle :my_event, with: Adapter::Sidekiq[serializer: :serialized_payload.to_proc]
You can also globally configure the default serializer:
Omnes.config.subscriber.adapter.sidekiq.serializer = :serialized_payload.to_proc
You can delay the callback execution from the publication time with the Sidekiq.in method (analogous to Sidekiq::Job.perform_in).
Defined Under Namespace
Classes: Instance
Class Method Summary collapse
- .[](serializer: config.serializer) ⇒ Object
- .call(instance, event, publication_context) ⇒ Object private
-
.config ⇒ Configurable::Config
extended
from Configurable
Returns the configuration class.
-
.configure {|@config| ... } ⇒ Object
extended
from Configurable
Yields the configuration class.
- .in(seconds) ⇒ Object
- .nest_config(constant, name: default_nesting_name(constant)) ⇒ Object extended from Configurable private
- .setting(name, default:) ⇒ Object extended from Configurable private
Class Method Details
.[](serializer: config.serializer) ⇒ Object
57 58 59 |
# File 'lib/omnes/subscriber/adapter/sidekiq.rb', line 57 def self.[](serializer: config.serializer) Instance.new(serializer: serializer) end |
.call(instance, event, publication_context) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
62 63 64 |
# File 'lib/omnes/subscriber/adapter/sidekiq.rb', line 62 def self.call(instance, event, publication_context) self.[].(instance, event, publication_context) end |
.config ⇒ Configurable::Config Originally defined in module Configurable
Returns the configuration class
Use this class to access readers and writers for the defined settings or nested configurations
.configure {|@config| ... } ⇒ Object Originally defined in module Configurable
Yields the configuration class
.in(seconds) ⇒ Object
67 68 69 |
# File 'lib/omnes/subscriber/adapter/sidekiq.rb', line 67 def self.in(seconds) self.[].in(seconds) end |
.nest_config(constant, name: default_nesting_name(constant)) ⇒ Object Originally defined in module Configurable
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
.setting(name, default:) ⇒ Object Originally defined in module Configurable
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.