Class: NexusDomainEvents::Bus
- Inherits:
-
Object
- Object
- NexusDomainEvents::Bus
- Defined in:
- lib/nexus_domain_events/bus.rb
Overview
A domain events bus for dispatching events to
Instance Method Summary collapse
- #dispatch(domain_event) ⇒ Object
-
#initialize(bunny: nil, topic_name: 'domain_events') ⇒ Bus
constructor
A new instance of Bus.
Constructor Details
#initialize(bunny: nil, topic_name: 'domain_events') ⇒ Bus
Returns a new instance of Bus.
8 9 10 11 12 |
# File 'lib/nexus_domain_events/bus.rb', line 8 def initialize(bunny: nil, topic_name: 'domain_events') @mutex = Mutex.new @bunny = bunny @topic_name = topic_name end |
Instance Method Details
#dispatch(domain_event) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/nexus_domain_events/bus.rb', line 15 def dispatch(domain_event) ensure_connection! @exchange.publish( domain_event.to_json, routing_key: domain_event. ) end |