Class: Buster::Worker
- Inherits:
-
Object
- Object
- Buster::Worker
- Defined in:
- lib/buster/worker.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(context) ⇒ Worker
constructor
A new instance of Worker.
- #run ⇒ Object
Constructor Details
#initialize(context) ⇒ Worker
Returns a new instance of Worker.
3 4 5 |
# File 'lib/buster/worker.rb', line 3 def initialize(context) @context = context end |
Class Method Details
Instance Method Details
#run ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/buster/worker.rb', line 7 def run worker = @context.socket(ZMQ::DEALER) worker.connect("inproc://workers") while true worker.recv_strings(msgs = []) return if msgs.length < 2 body = MessagePack.unpack(msgs.pop) = msgs.pop reply_id = msgs.pop handler = find_handler if handler.nil? puts "No handler found for #{}" return end handler.reply_action = lambda do |name,props| worker.send_strings([reply_id, name.to_s, MessagePack.pack(props)]) end handler.execute body end worker.close end |