Class: Distribot::MultiSubscription
- Inherits:
-
ConnectionSharer
- Object
- ConnectionSharer
- Distribot::MultiSubscription
- Defined in:
- lib/distribot/connector.rb
Instance Attribute Summary collapse
-
#queue ⇒ Object
Returns the value of attribute queue.
Attributes inherited from ConnectionSharer
Instance Method Summary collapse
Methods inherited from ConnectionSharer
Constructor Details
This class inherits a constructor from Distribot::ConnectionSharer
Instance Attribute Details
#queue ⇒ Object
Returns the value of attribute queue.
76 77 78 |
# File 'lib/distribot/connector.rb', line 76 def queue @queue end |
Instance Method Details
#start(topic, options = {}, &block) ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/distribot/connector.rb', line 77 def start(topic, = {}, &block) self.queue = channel.queue('', exclusive: true, auto_delete: true) exchange = channel.fanout(topic) queue.bind(exchange).subscribe() do |_delivery_info, _, payload| begin block.call(JSON.parse(payload, symbolize_names: true)) rescue StandardError => e logger.error "Error #{e} - #{payload} --- #{e.backtrace.join("\n")}" end end self end |