Class: Workling::Invokers::LoopedSubscriber

Inherits:
Base
  • Object
show all
Defined in:
lib/workling/invokers/looped_subscriber.rb

Instance Attribute Summary

Attributes inherited from Base

#reset_time, #sleep_time

Instance Method Summary collapse

Methods inherited from Base

#logger, #run

Constructor Details

#initialize(routing, client_class) ⇒ LoopedSubscriber

Returns a new instance of LoopedSubscriber.



8
9
10
# File 'lib/workling/invokers/looped_subscriber.rb', line 8

def initialize(routing, client_class)
  super
end

Instance Method Details

#listenObject

Starts EM loop and sets up subscription callbacks for workers.



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/workling/invokers/looped_subscriber.rb', line 15

def listen
  connect do
    routes.each do |route|
      @client.subscribe(route) do |args|
        run(route, args)
      end
    end
    
    loop do
      sleep 1
    end
  end
end

#stopObject



29
30
31
# File 'lib/workling/invokers/looped_subscriber.rb', line 29

def stop
  
end