Class: Workling::Invokers::EventmachineSubscriber
- Defined in:
- lib/workling/invokers/eventmachine_subscriber.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(routing, client_class) ⇒ EventmachineSubscriber
constructor
A new instance of EventmachineSubscriber.
-
#listen ⇒ Object
Starts EM loop and sets up subscription callbacks for workers.
- #stop ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(routing, client_class) ⇒ EventmachineSubscriber
Returns a new instance of EventmachineSubscriber.
10 11 12 |
# File 'lib/workling/invokers/eventmachine_subscriber.rb', line 10 def initialize(routing, client_class) super end |
Instance Method Details
#listen ⇒ Object
Starts EM loop and sets up subscription callbacks for workers.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/workling/invokers/eventmachine_subscriber.rb', line 17 def listen EM.run do connect do routes.each do |route| @client.subscribe(route) do |args| begin run(route, args) rescue logger.error("EventmachineSubscriber listen error on #{route}: #{$!}") end end end end end end |
#stop ⇒ Object
33 34 35 |
# File 'lib/workling/invokers/eventmachine_subscriber.rb', line 33 def stop EM.stop if EM.reactor_running? end |