Class: Textus::Infra::EventBus
- Inherits:
-
Object
- Object
- Textus::Infra::EventBus
- Defined in:
- lib/textus/infra/event_bus.rb
Instance Method Summary collapse
-
#initialize(registry:) ⇒ EventBus
constructor
A new instance of EventBus.
- #publish(event, **payload) ⇒ Object
Constructor Details
#initialize(registry:) ⇒ EventBus
Returns a new instance of EventBus.
4 5 6 |
# File 'lib/textus/infra/event_bus.rb', line 4 def initialize(registry:) @registry = registry end |
Instance Method Details
#publish(event, **payload) ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/textus/infra/event_bus.rb', line 8 def publish(event, **payload) @registry.pubsub_handlers(event).each do |entry| next unless entry[:keys].nil? || matches?(entry[:keys], payload[:key]) entry[:callable].call(**payload) rescue StandardError => e warn "[textus] pub-sub handler #{entry[:name].inspect} for #{event.inspect} failed: #{e.class}: #{e.}" end end |