Module: Omnes

Extended by:
Configurable
Defined in:
lib/omnes.rb,
lib/omnes/bus.rb,
lib/omnes/event.rb,
lib/omnes/errors.rb,
lib/omnes/version.rb,
lib/omnes/registry.rb,
lib/omnes/execution.rb,
lib/omnes/subscriber.rb,
lib/omnes/publication.rb,
lib/omnes/configurable.rb,
lib/omnes/subscription.rb,
lib/omnes/subscriber/state.rb,
lib/omnes/subscriber/errors.rb,
lib/omnes/subscriber/adapter.rb,
lib/omnes/unstructured_event.rb,
lib/omnes/publication_context.rb,
lib/omnes/subscriber/adapter/method.rb,
lib/omnes/subscriber/adapter/sidekiq.rb,
lib/omnes/subscriber/adapter/active_job.rb,
lib/omnes/subscriber/adapter/method/errors.rb

Overview

Pub/sub library for Ruby.

There're two ways to make use of the pub/sub features Omnes provides:

  • Standalone, through an Bus instance.
  • Mixing in the behavior in another class by including the Omnes module.

Refer to Bus documentation for the available methods. The only difference for the mixing use case is that the methods are directly called in the including instance.

class MyClass
  include Omnes

  def initialize
    register(:foo)
  end

  def call
    publish(:foo, bar: :baz)
  end
end

Refer to Subscriber for how to provide event handlers through methods defined in a class.

Defined Under Namespace

Modules: Configurable, Event, Subscriber Classes: AlreadyRegisteredEventError, Bus, DuplicateSubscriptionIdError, Error, Execution, InvalidEventNameError, InvalidSubscriptionNameError, Publication, PublicationContext, Registry, Subscription, UnknownEventError, UnknownSubscriptionError, UnstructuredEvent

Constant Summary collapse

VERSION =
"0.2.2"

Class Method Summary collapse

Class Method Details

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

.included(klass) ⇒ 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.



43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/omnes.rb', line 43

def self.included(klass)
  klass.define_method(:omnes_bus) { @omnes_bus ||= Bus.new(cal_loc_start: 2) }
  Bus.instance_methods(false).each do |method|
    klass.define_method(method) do |*args, **kwargs, &block|
      # TODO: Forward with ... once we deprecate ruby 2.5 & 2.6
      if kwargs.any?
        omnes_bus.send(method, *args, **kwargs, &block)
      else
        omnes_bus.send(method, *args, &block)
      end
    end
  end
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.