Sha256: 742e4048d7995becc751aef4fa24e5b92b8c65fb09013b0df251d6800ee67b49
Contents?: true
Size: 1.2 KB
Versions: 8
Compression:
Stored size: 1.2 KB
Contents
require 'protobuf/rpc/servers/zmq/broker' require 'protobuf/rpc/servers/zmq/worker' require 'protobuf/rpc/servers/zmq/util' module Protobuf module Rpc module Zmq class Server include ::Protobuf::Rpc::Zmq::Util ## # Class Methods # def self.run(opts = {}) log_debug { sign_message("initializing broker") } @broker = ::Protobuf::Rpc::Zmq::Broker.new(opts) local_worker_threads = opts.fetch(:threads, 5) worker_options = opts.merge(:port => opts.fetch(:port, 9399) + 1) log_debug { sign_message("starting server workers") } local_worker_threads.times do @threads << Thread.new { ::Protobuf::Rpc::Zmq::Worker.new(worker_options).run } end @running = true log_debug { sign_message("server started") } while self.running? do @broker.poll end ensure @broker.teardown if @broker end def self.running? !!@running end def self.stop @running = false @threads.each do |t| t.join end end @threads ||= [] end end end end
Version data entries
8 entries across 8 versions & 1 rubygems