Module: Omnes::Subscriber::Adapter::ActiveJob

Extended by:
Configurable
Defined in:
lib/omnes/subscriber/adapter/active_job.rb

Overview

ActiveJob adapter

Builds subscription to be processed as ActiveJob background jobs.

ActiveJob requires that the argument passed to #perform is serializable. By default, the result of calling #payload in the event is taken.

class MyJob < ActiveJob
  include Omnes::Subscriber

  handle :my_event, with: Adapter::ActiveJob

  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::ActiveJob[serializer: :serialized_payload.to_proc]

You can also globally configure the default serializer:

Omnes.config.subscriber.adapter.active_job.serializer = :serialized_payload.to_proc

Defined Under Namespace

Classes: Instance

Class Method Summary collapse

Class Method Details

.[](serializer: config.serializer) ⇒ Object

Parameters:

  • serializer (#call) (defaults to: config.serializer)


50
51
52
# File 'lib/omnes/subscriber/adapter/active_job.rb', line 50

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.



55
56
57
# File 'lib/omnes/subscriber/adapter/active_job.rb', line 55

def self.call(instance, event, publication_context)
  self.[].(instance, event, publication_context)
end

.configConfigurable::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

Yields:

See Also:

.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.