Class: Mammoth::FanoutDeliveryWorker
- Inherits:
-
Object
- Object
- Mammoth::FanoutDeliveryWorker
- Defined in:
- lib/mammoth/fanout_delivery_worker.rb
Overview
Delivers one CDC work item to multiple destination-specific workers.
Instance Attribute Summary collapse
-
#delivery_workers ⇒ Object
readonly
Returns the value of attribute delivery_workers.
Instance Method Summary collapse
-
#deliver(event) ⇒ Hash
Deliver an event to every configured destination.
-
#deliver_to(destination_name, event) ⇒ Hash
Deliver an event to one configured destination.
-
#deliver_transaction(envelope) ⇒ Hash
Deliver a transaction envelope to every configured destination.
-
#deliver_transaction_to(destination_name, envelope) ⇒ Hash
Deliver a transaction envelope to one configured destination.
-
#initialize(delivery_workers) ⇒ FanoutDeliveryWorker
constructor
A new instance of FanoutDeliveryWorker.
Constructor Details
#initialize(delivery_workers) ⇒ FanoutDeliveryWorker
Returns a new instance of FanoutDeliveryWorker.
9 10 11 12 13 |
# File 'lib/mammoth/fanout_delivery_worker.rb', line 9 def initialize(delivery_workers) raise ConfigurationError, "at least one destination is required" if delivery_workers.empty? @delivery_workers = delivery_workers end |
Instance Attribute Details
#delivery_workers ⇒ Object (readonly)
Returns the value of attribute delivery_workers.
6 7 8 |
# File 'lib/mammoth/fanout_delivery_worker.rb', line 6 def delivery_workers @delivery_workers end |
Instance Method Details
#deliver(event) ⇒ Hash
Deliver an event to every configured destination.
19 20 21 |
# File 'lib/mammoth/fanout_delivery_worker.rb', line 19 def deliver(event) fanout(:deliver, event) end |
#deliver_to(destination_name, event) ⇒ Hash
Deliver an event to one configured destination.
36 37 38 |
# File 'lib/mammoth/fanout_delivery_worker.rb', line 36 def deliver_to(destination_name, event) worker_for(destination_name).deliver(event) end |
#deliver_transaction(envelope) ⇒ Hash
Deliver a transaction envelope to every configured destination.
27 28 29 |
# File 'lib/mammoth/fanout_delivery_worker.rb', line 27 def deliver_transaction(envelope) fanout(:deliver_transaction, envelope) end |
#deliver_transaction_to(destination_name, envelope) ⇒ Hash
Deliver a transaction envelope to one configured destination.
45 46 47 |
# File 'lib/mammoth/fanout_delivery_worker.rb', line 45 def deliver_transaction_to(destination_name, envelope) worker_for(destination_name).deliver_transaction(envelope) end |