protobuf 2.1.0 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,10 +7,10 @@ require 'active_support/all'
7
7
  module Protobuf
8
8
 
9
9
  # See Protobuf#connector_type documentation.
10
- VALID_CONNECTOR_TYPES = [ :socket, :zmq, :evented ].freeze
10
+ CONNECTORS = [ :socket, :zmq, :evented ].freeze
11
11
 
12
12
  # Default is Socket as it has no external dependencies.
13
- DEFAULT_CONNECTOR_TYPE = :socket
13
+ DEFAULT_CONNECTOR = :socket
14
14
 
15
15
  module_function
16
16
 
@@ -21,15 +21,14 @@ module Protobuf
21
21
  # Symbol value which denotes the type of connector to use
22
22
  # during client requests to an RPC server.
23
23
  def self.connector_type
24
- @_connector_type ||= DEFAULT_CONNECTOR_TYPE
24
+ @_connector_type ||= DEFAULT_CONNECTOR
25
25
  end
26
26
 
27
27
  def self.connector_type=(type)
28
- raise ArgumentError, 'Invalid connector type given' unless VALID_CONNECTOR_TYPES.include?(type)
28
+ raise ArgumentError, 'Invalid connector type given' unless CONNECTORS.include?(type)
29
29
  @_connector_type = type
30
30
  end
31
31
 
32
-
33
32
  # GC Pause during server requests
34
33
  #
35
34
  # Default: false
@@ -70,4 +69,18 @@ end
70
69
 
71
70
  require 'protobuf/rpc/client'
72
71
  require 'protobuf/rpc/service'
73
- require 'protobuf/socket'
72
+
73
+ env_connector_type = ENV.fetch('PB_CLIENT_TYPE') {
74
+ ::Protobuf::DEFAULT_CONNECTOR
75
+ }.to_s.downcase.strip.to_sym
76
+
77
+ if ::Protobuf::CONNECTORS.include?(env_connector_type)
78
+ require "protobuf/#{env_connector_type}"
79
+ else
80
+ $stderr.puts <<-WARN
81
+ [WARNING] Require attempted on an invalid connector type '#{env_connector_type}'.
82
+ Falling back to default '#{::Protobuf::DEFAULT_CONNECTOR}' connector.
83
+ WARN
84
+
85
+ require "protobuf/#{::Protobuf::DEFAULT_CONNECTOR}"
86
+ end
@@ -16,7 +16,7 @@ module Protobuf
16
16
  desc 'start APP_FILE', 'Run the RPC server in the given mode, preloading the given APP_FILE. This is the default task.'
17
17
 
18
18
  option :host, :type => :string, :default => '127.0.0.1', :aliases => %w(-o), :desc => 'Host to bind.'
19
- option :port, :type => :numeric, :default => 9595, :aliases => %w(-p), :desc => 'Port to bind.'
19
+ option :port, :type => :numeric, :default => 9399, :aliases => %w(-p), :desc => 'Master Port to bind.'
20
20
 
21
21
  option :backlog, :type => :numeric, :default => 100, :aliases => %w(-b), :desc => 'Backlog for listening socket when using Socket Server.'
22
22
  option :threshold, :type => :numeric, :default => 100, :aliases => %w(-t), :desc => 'Multi-threaded Socket Server cleanup threshold.'
@@ -107,19 +107,15 @@ module Protobuf
107
107
  # TODO add signal handling for hot-reloading the application.
108
108
  def configure_traps
109
109
  debug_say 'Configuring traps'
110
- trap_block = proc {
111
- ::Protobuf::Logger.info { 'RPC Server shutting down...' }
112
- @start_aborted = true
113
- @runner.stop
114
- ::Protobuf::Logger.info { 'Shutdown complete' }
115
- }
116
-
117
- debug_say 'Registering INT', :blue
118
- trap(:INT, &trap_block)
119
- debug_say 'Registering QUIT', :blue
120
- trap(:QUIT, &trap_block)
121
- debug_say 'Registering TERM', :blue
122
- trap(:TERM, &trap_block)
110
+ [:INT, :QUIT, :TERM].each do |signal|
111
+ debug_say "Registering signal trap for #{signal}", :blue
112
+ trap(signal) do
113
+ ::Protobuf::Logger.info { 'RPC Server shutting down...' }
114
+ @start_aborted = true
115
+ @runner.stop
116
+ ::Protobuf::Logger.info { 'Shutdown complete' }
117
+ end
118
+ end
123
119
  end
124
120
 
125
121
  # Say something if we're in debug mode.
@@ -41,7 +41,7 @@ module Protobuf
41
41
  ::Protobuf::Field::BoolField
42
42
  ].freeze
43
43
 
44
- def self.build(message_class, rule, type, name, tag, options={})
44
+ def self.build(message_class, rule, type, name, tag, options = {})
45
45
  field_class = type_message_or_enum(type)
46
46
  field_class.new(message_class, rule, type, name, tag, options)
47
47
  end
@@ -29,17 +29,17 @@ module Protobuf
29
29
  end
30
30
 
31
31
  # Define a required field. Don't use this method directly.
32
- def self.required(type, name, tag, options={})
32
+ def self.required(type, name, tag, options = {})
33
33
  define_field(:required, type, name, tag, options)
34
34
  end
35
35
 
36
36
  # Define a optional field. Don't use this method directly.
37
- def self.optional(type, name, tag, options={})
37
+ def self.optional(type, name, tag, options = {})
38
38
  define_field(:optional, type, name, tag, options)
39
39
  end
40
40
 
41
41
  # Define a repeated field. Don't use this method directly.
42
- def self.repeated(type, name, tag, options={})
42
+ def self.repeated(type, name, tag, options = {})
43
43
  define_field(:repeated, type, name, tag, options)
44
44
  end
45
45
 
@@ -111,7 +111,7 @@ module Protobuf
111
111
  ##
112
112
  # Constructor
113
113
  #
114
- def initialize(values={})
114
+ def initialize(values = {})
115
115
  values = values.to_hash
116
116
  @values = {}
117
117
 
@@ -26,10 +26,10 @@ module Protobuf
26
26
  # :request => request
27
27
  # })
28
28
  #
29
- def initialize(opts={})
30
- raise "Invalid client configuration. Service must be defined." if opts[:service].nil?
31
- @connector = Connector.connector_for_client.new(opts)
32
- log_debug { sign_message("Initialized with options: #{opts.inspect}") }
29
+ def initialize(options = {})
30
+ raise "Invalid client configuration. Service must be defined." if options[:service].nil?
31
+ @connector = Connector.connector_for_client.new(options)
32
+ log_debug { sign_message("Initialized with options: #{options.inspect}") }
33
33
  end
34
34
 
35
35
  def log_signature
@@ -3,19 +3,15 @@ module Protobuf
3
3
  class Connector
4
4
 
5
5
  # Returns a connector class for the pre-defined connector_type.
6
- def self.connector_for_client(reload = false)
7
- if reload || @_connector.nil?
8
- @_connector = case ::Protobuf.connector_type
9
- when :evented then
10
- ::Protobuf::Rpc::Connectors::EventMachine
11
- when :zmq then
12
- ::Protobuf::Rpc::Connectors::Zmq
13
- else
14
- ::Protobuf::Rpc::Connectors::Socket
15
- end
6
+ def self.connector_for_client
7
+ case ::Protobuf.connector_type
8
+ when :evented then
9
+ ::Protobuf::Rpc::Connectors::EventMachine
10
+ when :zmq then
11
+ ::Protobuf::Rpc::Connectors::Zmq
12
+ else
13
+ ::Protobuf::Rpc::Connectors::Socket
16
14
  end
17
-
18
- return @_connector
19
15
  end
20
16
 
21
17
  end
@@ -13,7 +13,7 @@ module Protobuf
13
13
  ##
14
14
  # Constructor
15
15
  #
16
- def initialize(options={}, &failure_cb)
16
+ def initialize(options = {}, &failure_cb)
17
17
  @failure_cb = failure_cb
18
18
  @options = DEFAULT_OPTIONS.merge(options)
19
19
  @response_buffer = ::Protobuf::Rpc::Buffer.new(:read)
@@ -27,7 +27,7 @@ module Protobuf
27
27
  ##
28
28
  # Class Methods
29
29
  #
30
- def self.connect(options={})
30
+ def self.connect(options = {})
31
31
  options = DEFAULT_OPTIONS.merge(options)
32
32
  log_debug { sign_message("Connecting to server: #{options.inspect}") }
33
33
  EM.connect(options[:host], options[:port], self, options)
@@ -6,10 +6,10 @@ module Protobuf
6
6
  ::EventMachine.stop_event_loop if ::EventMachine.reactor_running?
7
7
  end
8
8
 
9
- def self.run(server)
9
+ def self.run(options)
10
10
  # Startup and run the rpc server
11
11
  ::EventMachine.schedule do
12
- ::EventMachine.start_server(server.host, server.port, ::Protobuf::Rpc::Evented::Server)
12
+ ::EventMachine.start_server(options[:host], options[:port], ::Protobuf::Rpc::Evented::Server)
13
13
  end
14
14
 
15
15
  # Join or start the reactor
@@ -9,9 +9,11 @@ module Protobuf
9
9
  include ::Protobuf::Rpc::Server
10
10
  include ::Protobuf::Logger::LogMethods
11
11
 
12
+ AUTO_COLLECT_TIMEOUT = 20 # seconds
13
+
12
14
  def self.cleanup?
13
15
  # every 10 connections run a cleanup routine after closing the response
14
- @threads.size > (@thread_threshold - 1) && (@threads.size % @thread_threshold) == 0
16
+ @threads.size > (@threshold - 1) && (@threads.size % @threshold) == 0
15
17
  end
16
18
 
17
19
  def self.cleanup_threads
@@ -42,18 +44,17 @@ module Protobuf
42
44
  end
43
45
  end
44
46
 
45
- def self.run(opts = {})
47
+ def self.run(options = {})
46
48
  log_debug { sign_message("Run") }
47
- host = opts.fetch(:host, "127.0.0.1")
48
- port = opts.fetch(:port, 9399)
49
- backlog = opts.fetch(:backlog, 100)
50
- thread_threshold = opts.fetch(:thread_threshold, 100)
51
- auto_collect_timeout = opts.fetch(:auto_collect_timeout, 20)
49
+ host = options[:host]
50
+ port = options[:port]
51
+ backlog = options[:backlog]
52
+ @threshold = options[:threshold]
52
53
 
53
54
  @threads = []
54
- @thread_threshold = thread_threshold
55
55
  @server = ::TCPServer.new(host, port)
56
- raise "blah" if @server.closed?
56
+ raise "The server was unable to start properly." if @server.closed?
57
+
57
58
  @server.listen(backlog)
58
59
  @working = []
59
60
  @listen_fds = [@server]
@@ -62,7 +63,7 @@ module Protobuf
62
63
  while running?
63
64
  log_debug { sign_message("Waiting for connections") }
64
65
 
65
- if ready_cnxns = IO.select(@listen_fds, [], [], auto_collect_timeout)
66
+ if ready_cnxns = IO.select(@listen_fds, [], [], AUTO_COLLECT_TIMEOUT)
66
67
  cnxns = ready_cnxns.first
67
68
  cnxns.each do |client|
68
69
  case
@@ -8,13 +8,13 @@ module Protobuf
8
8
  include ::Protobuf::Rpc::Zmq::Util
9
9
  attr_reader :frontend, :backend, :poller, :context
10
10
 
11
- ##
11
+ ##
12
12
  # Constructor
13
13
  #
14
- def initialize(opts={})
14
+ def initialize(options = {})
15
15
  @context = ::ZMQ::Context.new
16
- @frontend = setup_frontend(opts)
17
- @backend = setup_backend(opts)
16
+ @frontend = setup_frontend(options)
17
+ @backend = setup_backend(options)
18
18
  @poller = setup_poller
19
19
  end
20
20
 
@@ -52,27 +52,29 @@ module Protobuf
52
52
  end
53
53
  end
54
54
 
55
- def setup_backend(opts={})
56
- dealer_options = opts.merge(:port => opts.fetch(:port, 9399) + 1)
57
- host = dealer_options.fetch(:host, "127.0.0.1")
58
- port = dealer_options.fetch(:port, 9400)
59
- protocol = dealer_options.fetch(:protocol, "tcp")
55
+ def setup_backend(options = {})
56
+ dealer_options = options.merge(:port => options[:port] + 1)
57
+ host = dealer_options[:host]
58
+ port = dealer_options[:port]
60
59
 
61
60
  zmq_backend = context.socket(::ZMQ::DEALER)
62
- zmq_error_check(zmq_backend.bind("#{protocol}://#{resolve_ip(host)}:#{port}"))
61
+ zmq_error_check(zmq_backend.bind(bind_address(host, port)))
63
62
  zmq_backend
64
63
  end
65
64
 
66
- def setup_frontend(opts={})
67
- host = opts.fetch(:host, "127.0.0.1")
68
- port = opts.fetch(:port, 9399)
69
- protocol = opts.fetch(:protocol, "tcp")
65
+ def setup_frontend(options = {})
66
+ host = options[:host]
67
+ port = options[:port]
70
68
 
71
69
  zmq_frontend = context.socket(::ZMQ::ROUTER)
72
- zmq_error_check(zmq_frontend.bind("#{protocol}://#{resolve_ip(host)}:#{port}"))
70
+ zmq_error_check(zmq_frontend.bind(bind_address(host, port)))
73
71
  zmq_frontend
74
72
  end
75
73
 
74
+ def bind_address(host, port)
75
+ "tcp://#{resolve_ip(host)}:#{port}"
76
+ end
77
+
76
78
  def setup_poller
77
79
  zmq_poller = ::ZMQ::Poller.new
78
80
  zmq_poller.register(frontend, ::ZMQ::POLLIN)
@@ -11,12 +11,12 @@ module Protobuf
11
11
  ##
12
12
  # Class Methods
13
13
  #
14
- def self.run(opts = {})
14
+ def self.run(options = {})
15
15
  log_debug { sign_message("initializing broker") }
16
- @broker = ::Protobuf::Rpc::Zmq::Broker.new(opts)
17
- local_worker_threads = opts.fetch(:threads, 5)
16
+ @broker = ::Protobuf::Rpc::Zmq::Broker.new(options)
17
+ local_worker_threads = options[:threads]
18
18
 
19
- worker_options = opts.merge(:port => opts.fetch(:port, 9399) + 1)
19
+ worker_options = options.merge(:port => options[:port] + 1)
20
20
  log_debug { sign_message("starting server workers") }
21
21
  local_worker_threads.times do
22
22
  @threads << Thread.new { ::Protobuf::Rpc::Zmq::Worker.new(worker_options).run }
@@ -11,15 +11,13 @@ module Protobuf
11
11
  ##
12
12
  # Constructor
13
13
  #
14
- def initialize(opts={})
15
- @options = opts
16
- host = @options.fetch(:host) { "127.0.0.1" }
17
- port = @options.fetch(:port) { 9400 }
18
- protocol = @options.fetch(:protocol) { "tcp" }
14
+ def initialize(options = {})
15
+ host = options[:host]
16
+ port = options[:port]
19
17
 
20
18
  @zmq_context = ::ZMQ::Context.new
21
19
  @socket = @zmq_context.socket(::ZMQ::REP)
22
- zmq_error_check(@socket.connect("#{protocol}://#{resolve_ip(host)}:#{port}"))
20
+ zmq_error_check(@socket.connect("tcp://#{resolve_ip(host)}:#{port}"))
23
21
 
24
22
  @poller = ::ZMQ::Poller.new
25
23
  @poller.register(@socket, ::ZMQ::POLLIN)
@@ -1,4 +1,4 @@
1
1
  module Protobuf
2
- VERSION = '2.1.0'
2
+ VERSION = '2.1.1'
3
3
  PROTOC_VERSION = '2.4.1'
4
4
  end
@@ -60,7 +60,6 @@ namespace :benchmark do
60
60
 
61
61
  def sock_client_sock_server(number_tests, test_length, global_bench = nil)
62
62
  load "protobuf/socket.rb"
63
- ::Protobuf::Rpc::Connector.connector_for_client(true)
64
63
  EM.stop if EM.reactor_running?
65
64
 
66
65
  StubServer.new(:server => Protobuf::Rpc::Socket::Server, :port => 9399) do |server|
@@ -76,7 +75,6 @@ namespace :benchmark do
76
75
 
77
76
  def sock_client_em_server(number_tests, test_length, global_bench = nil)
78
77
  load "protobuf/socket.rb"
79
- ::Protobuf::Rpc::Connector.connector_for_client(true)
80
78
  EM.stop if EM.reactor_running?
81
79
  em_thread = Thread.new { EM.run }
82
80
  Thread.pass until EM.reactor_running?
@@ -97,7 +95,6 @@ namespace :benchmark do
97
95
 
98
96
  def zmq_client_zmq_server(number_tests, test_length, global_bench = nil)
99
97
  load "protobuf/zmq.rb"
100
- ::Protobuf::Rpc::Connector.connector_for_client(true)
101
98
  StubServer.new(:port => 9399, :server => Protobuf::Rpc::Zmq::Server) do |server|
102
99
  client = ::Test::ResourceService.client(:port => 9399)
103
100
 
@@ -4,7 +4,6 @@ require 'spec/support/test/resource_service'
4
4
  describe 'Functional EventMachine Client' do
5
5
  before(:each) do
6
6
  load 'protobuf/evented.rb'
7
- ::Protobuf::Rpc::Connector.connector_for_client(true)
8
7
  end
9
8
 
10
9
  it 'runs fine when required fields are set' do
@@ -4,9 +4,8 @@ require 'spec/support/test/resource_service'
4
4
  describe 'Functional Socket Client' do
5
5
  before(:all) do
6
6
  load "protobuf/socket.rb"
7
- ::Protobuf::Rpc::Connector.connector_for_client(true)
8
7
  Thread.abort_on_exception = true
9
- server = OpenStruct.new(:server => "127.0.0.1", :port => 9399, :backlog => 100, :threshold => 100)
8
+ server = OpenStruct.new(:host => "127.0.0.1", :port => 9399, :backlog => 100, :threshold => 100)
10
9
  @server_thread = Thread.new(server) { |s| Protobuf::Rpc::SocketRunner.run(s) }
11
10
  Thread.pass until Protobuf::Rpc::Socket::Server.running?
12
11
  end
@@ -4,9 +4,8 @@ require 'spec/support/test/resource_service'
4
4
  describe 'Functional ZMQ Client' do
5
5
  before(:all) do
6
6
  load "protobuf/zmq.rb"
7
- ::Protobuf::Rpc::Connector.connector_for_client(true)
8
7
  Thread.abort_on_exception = true
9
- server = OpenStruct.new(:server => "127.0.0.1", :port => 9399, :backlog => 100, :threshold => 100)
8
+ server = OpenStruct.new(:host => "127.0.0.1", :port => 9399, :backlog => 100, :threshold => 100, :threads => 5)
10
9
  @server_thread = Thread.new(server) { |s| Protobuf::Rpc::ZmqRunner.run(s) }
11
10
  Thread.pass until Protobuf::Rpc::Zmq::Server.running?
12
11
  end
@@ -4,7 +4,6 @@ require 'spec/support/test/resource_service'
4
4
  describe Protobuf::Rpc::Client do
5
5
  before(:each) do
6
6
  load 'protobuf/evented.rb'
7
- ::Protobuf::Rpc::Connector.connector_for_client(true)
8
7
  end
9
8
 
10
9
  context "when using fiber based calls" do
@@ -6,36 +6,27 @@ require 'protobuf/zmq'
6
6
  describe ::Protobuf::Rpc::Connector do
7
7
 
8
8
  describe '.connector_for_client(true)' do
9
- after { described_class.instance_variable_set(:@_connector, nil) }
9
+ subject { described_class.connector_for_client }
10
10
 
11
11
  context 'Protobuf.connector_type is socket' do
12
- it 'returns a socket connector class' do
13
- ::Protobuf.connector_type = :socket
14
- described_class.connector_for_client(true).should eq ::Protobuf::Rpc::Connectors::Socket
15
- end
12
+ before { ::Protobuf.connector_type = :socket }
13
+ it { should eq ::Protobuf::Rpc::Connectors::Socket }
16
14
  end
17
15
 
18
16
  context 'Protobuf.connector_type is not a known value' do
19
- it 'returns a socket connector class' do
20
- ::Protobuf.stub(:connector_type).and_return('some value')
21
- described_class.connector_for_client(true).should eq ::Protobuf::Rpc::Connectors::Socket
22
- end
17
+ before { ::Protobuf.connector_type = :socket }
18
+ it { should eq ::Protobuf::Rpc::Connectors::Socket }
23
19
  end
24
20
 
25
21
  context 'Protobuf.connector_type is evented' do
26
- it 'returns an eventmachine connector class' do
27
- ::Protobuf.connector_type = :evented
28
- described_class.connector_for_client(true).should eq ::Protobuf::Rpc::Connectors::EventMachine
29
- end
22
+ before { ::Protobuf.connector_type = :evented }
23
+ it { should eq ::Protobuf::Rpc::Connectors::EventMachine }
30
24
  end
31
25
 
32
26
  context 'Protobuf.connector_type is zmq' do
33
- it 'returns a zmq connector class' do
34
- ::Protobuf.connector_type = :zmq
35
- described_class.connector_for_client(true).should eq ::Protobuf::Rpc::Connectors::Zmq
36
- end
27
+ before { ::Protobuf.connector_type = :zmq }
28
+ it { should eq ::Protobuf::Rpc::Connectors::Zmq }
37
29
  end
38
-
39
30
  end
40
31
 
41
32
  end
@@ -2,11 +2,11 @@ require 'spec_helper'
2
2
 
3
3
  describe Protobuf::Rpc::Connectors::Base do
4
4
 
5
- let(:opts) do
5
+ let(:options) do
6
6
  { :timeout => 60 }
7
7
  end
8
8
 
9
- subject { Protobuf::Rpc::Connectors::Base.new(opts) }
9
+ subject { Protobuf::Rpc::Connectors::Base.new(options) }
10
10
 
11
11
  describe "#send_request" do
12
12
  it "raising an error when 'send_request' is not overridden" do
@@ -14,14 +14,14 @@ describe Protobuf::Rpc::Connectors::Base do
14
14
  end
15
15
 
16
16
  it "does not raise error when 'send_request' is overridden" do
17
- new_sub = Class.new(subject.class){ def send_request; end }.new(opts)
17
+ new_sub = Class.new(subject.class){ def send_request; end }.new(options)
18
18
  expect{ new_sub.send_request }.to_not raise_error
19
19
  end
20
20
  end
21
21
 
22
22
  describe '.new' do
23
23
  it 'assigns passed options and initializes success/failure callbacks' do
24
- subject.options.should eq(Protobuf::Rpc::Connectors::DEFAULT_OPTIONS.merge(opts))
24
+ subject.options.should eq(Protobuf::Rpc::Connectors::DEFAULT_OPTIONS.merge(options))
25
25
  subject.success_cb.should be_nil
26
26
  subject.failure_cb.should be_nil
27
27
  end
@@ -5,14 +5,12 @@ require 'protobuf/evented'
5
5
  require 'protobuf/socket'
6
6
 
7
7
  describe Protobuf::Rpc::Socket::Server do
8
- before(:each) do
9
- load 'protobuf/socket.rb'
10
- ::Protobuf::Rpc::Connector.connector_for_client(true)
8
+ before(:each) do
9
+ load 'protobuf/socket.rb'
11
10
  end
12
11
 
13
12
  before(:all) do
14
- load 'protobuf/socket.rb'
15
- ::Protobuf::Rpc::Connector.connector_for_client(true)
13
+ load 'protobuf/socket.rb'
16
14
  Thread.abort_on_exception = true
17
15
  server = OpenStruct.new(:server => "127.0.0.1", :port => 9399, :backlog => 100, :threshold => 100)
18
16
  @server_thread = Thread.new(server) { |s| Protobuf::Rpc::SocketRunner.run(s) }
@@ -1,15 +1,18 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe ::Protobuf::Rpc::Zmq::Broker do
4
- before(:each) do
5
- load 'protobuf/zmq.rb'
6
- ::Protobuf::Rpc::Connector.connector_for_client(true)
4
+ before(:each) do
5
+ load 'protobuf/zmq.rb'
7
6
  end
8
7
 
9
8
  after(:each) do
10
9
  subject.teardown
11
10
  end
12
11
 
12
+ subject do
13
+ described_class.new({ :host => '127.0.0.1', :port => 9399 })
14
+ end
15
+
13
16
  it 'sets up a context' do
14
17
  subject.context.should be_a(::ZMQ::Context)
15
18
  end
@@ -4,7 +4,6 @@ require 'protobuf/rpc/servers/zmq/server'
4
4
  describe Protobuf::Rpc::Zmq::Server do
5
5
  before(:each) do
6
6
  load 'protobuf/zmq.rb'
7
- ::Protobuf::Rpc::Connector.connector_for_client(true)
8
7
  end
9
8
 
10
9
  describe '.running?' do
@@ -6,8 +6,7 @@ end
6
6
 
7
7
  describe ::Protobuf::Rpc::Zmq::Util do
8
8
  before(:each) do
9
- load 'protobuf/zmq.rb'
10
- ::Protobuf::Rpc::Connector.connector_for_client(true)
9
+ load 'protobuf/zmq.rb'
11
10
  end
12
11
 
13
12
  subject { UtilTest.new }
@@ -3,7 +3,6 @@ require 'spec_helper'
3
3
  describe ::Protobuf::Rpc::Zmq::Worker do
4
4
  before(:each) do
5
5
  load 'protobuf/zmq.rb'
6
- ::Protobuf::Rpc::Connector.connector_for_client(true)
7
6
  end
8
7
 
9
8
  after(:each) do
@@ -11,6 +10,10 @@ describe ::Protobuf::Rpc::Zmq::Worker do
11
10
  subject.instance_variable_get(:@zmq_context).terminate
12
11
  end
13
12
 
13
+ subject do
14
+ described_class.new({ :host => '127.0.0.1', :port => 9400 })
15
+ end
16
+
14
17
  it 'sets the context' do
15
18
  subject.instance_variable_get(:@zmq_context).should be_a(::ZMQ::Context)
16
19
  end
@@ -37,12 +37,12 @@ class StubServer
37
37
 
38
38
  attr_accessor :options
39
39
 
40
- def initialize(opts = {})
40
+ def initialize(options = {})
41
41
  @running = true
42
42
  @options = OpenStruct.new({ :host => "127.0.0.1",
43
43
  :port => 9399,
44
44
  :delay => 0,
45
- :server => Protobuf::Rpc::Evented::Server }.merge(opts))
45
+ :server => Protobuf::Rpc::Evented::Server }.merge(options))
46
46
 
47
47
  start
48
48
  yield self
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: protobuf
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-11-05 00:00:00.000000000Z
13
+ date: 2012-11-06 00:00:00.000000000Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
17
- requirement: &2152184060 !ruby/object:Gem::Requirement
17
+ requirement: &2152100680 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: '0'
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *2152184060
25
+ version_requirements: *2152100680
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: ffi
28
- requirement: &2152179420 !ruby/object:Gem::Requirement
28
+ requirement: &2152099380 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *2152179420
36
+ version_requirements: *2152099380
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: multi_json
39
- requirement: &2152175780 !ruby/object:Gem::Requirement
39
+ requirement: &2152098400 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ! '>='
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: '0'
45
45
  type: :runtime
46
46
  prerelease: false
47
- version_requirements: *2152175780
47
+ version_requirements: *2152098400
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: thor
50
- requirement: &2152173860 !ruby/object:Gem::Requirement
50
+ requirement: &2152097220 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ! '>='
@@ -55,10 +55,10 @@ dependencies:
55
55
  version: '0'
56
56
  type: :runtime
57
57
  prerelease: false
58
- version_requirements: *2152173860
58
+ version_requirements: *2152097220
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: eventmachine
61
- requirement: &2152172500 !ruby/object:Gem::Requirement
61
+ requirement: &2152095600 !ruby/object:Gem::Requirement
62
62
  none: false
63
63
  requirements:
64
64
  - - ! '>='
@@ -66,10 +66,10 @@ dependencies:
66
66
  version: '0'
67
67
  type: :development
68
68
  prerelease: false
69
- version_requirements: *2152172500
69
+ version_requirements: *2152095600
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: ffi-rzmq
72
- requirement: &2152170080 !ruby/object:Gem::Requirement
72
+ requirement: &2152094240 !ruby/object:Gem::Requirement
73
73
  none: false
74
74
  requirements:
75
75
  - - ! '>='
@@ -77,10 +77,10 @@ dependencies:
77
77
  version: '0'
78
78
  type: :development
79
79
  prerelease: false
80
- version_requirements: *2152170080
80
+ version_requirements: *2152094240
81
81
  - !ruby/object:Gem::Dependency
82
82
  name: perftools.rb
83
- requirement: &2152151800 !ruby/object:Gem::Requirement
83
+ requirement: &2152088440 !ruby/object:Gem::Requirement
84
84
  none: false
85
85
  requirements:
86
86
  - - ! '>='
@@ -88,10 +88,10 @@ dependencies:
88
88
  version: '0'
89
89
  type: :development
90
90
  prerelease: false
91
- version_requirements: *2152151800
91
+ version_requirements: *2152088440
92
92
  - !ruby/object:Gem::Dependency
93
93
  name: pry
94
- requirement: &2152144100 !ruby/object:Gem::Requirement
94
+ requirement: &2152087100 !ruby/object:Gem::Requirement
95
95
  none: false
96
96
  requirements:
97
97
  - - ! '>='
@@ -99,10 +99,10 @@ dependencies:
99
99
  version: '0'
100
100
  type: :development
101
101
  prerelease: false
102
- version_requirements: *2152144100
102
+ version_requirements: *2152087100
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: pry-nav
105
- requirement: &2152143260 !ruby/object:Gem::Requirement
105
+ requirement: &2152086180 !ruby/object:Gem::Requirement
106
106
  none: false
107
107
  requirements:
108
108
  - - ! '>='
@@ -110,10 +110,10 @@ dependencies:
110
110
  version: '0'
111
111
  type: :development
112
112
  prerelease: false
113
- version_requirements: *2152143260
113
+ version_requirements: *2152086180
114
114
  - !ruby/object:Gem::Dependency
115
115
  name: rake
116
- requirement: &2152142540 !ruby/object:Gem::Requirement
116
+ requirement: &2152085220 !ruby/object:Gem::Requirement
117
117
  none: false
118
118
  requirements:
119
119
  - - ! '>='
@@ -121,10 +121,10 @@ dependencies:
121
121
  version: '0'
122
122
  type: :development
123
123
  prerelease: false
124
- version_requirements: *2152142540
124
+ version_requirements: *2152085220
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: rake-compiler
127
- requirement: &2152141860 !ruby/object:Gem::Requirement
127
+ requirement: &2152083820 !ruby/object:Gem::Requirement
128
128
  none: false
129
129
  requirements:
130
130
  - - ! '>='
@@ -132,10 +132,10 @@ dependencies:
132
132
  version: '0'
133
133
  type: :development
134
134
  prerelease: false
135
- version_requirements: *2152141860
135
+ version_requirements: *2152083820
136
136
  - !ruby/object:Gem::Dependency
137
137
  name: rspec
138
- requirement: &2152140260 !ruby/object:Gem::Requirement
138
+ requirement: &2152082700 !ruby/object:Gem::Requirement
139
139
  none: false
140
140
  requirements:
141
141
  - - ! '>='
@@ -143,10 +143,10 @@ dependencies:
143
143
  version: '0'
144
144
  type: :development
145
145
  prerelease: false
146
- version_requirements: *2152140260
146
+ version_requirements: *2152082700
147
147
  - !ruby/object:Gem::Dependency
148
148
  name: simplecov
149
- requirement: &2152139460 !ruby/object:Gem::Requirement
149
+ requirement: &2152081360 !ruby/object:Gem::Requirement
150
150
  none: false
151
151
  requirements:
152
152
  - - ! '>='
@@ -154,10 +154,10 @@ dependencies:
154
154
  version: '0'
155
155
  type: :development
156
156
  prerelease: false
157
- version_requirements: *2152139460
157
+ version_requirements: *2152081360
158
158
  - !ruby/object:Gem::Dependency
159
159
  name: yard
160
- requirement: &2152138580 !ruby/object:Gem::Requirement
160
+ requirement: &2152080320 !ruby/object:Gem::Requirement
161
161
  none: false
162
162
  requirements:
163
163
  - - ! '>='
@@ -165,7 +165,7 @@ dependencies:
165
165
  version: '0'
166
166
  type: :development
167
167
  prerelease: false
168
- version_requirements: *2152138580
168
+ version_requirements: *2152080320
169
169
  description: Google Protocol Buffers v2.4.1 Serialization and RPC implementation for
170
170
  Ruby.
171
171
  email:
@@ -446,7 +446,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
446
446
  version: '0'
447
447
  segments:
448
448
  - 0
449
- hash: 2922389583391730892
449
+ hash: 893090751339011969
450
450
  required_rubygems_version: !ruby/object:Gem::Requirement
451
451
  none: false
452
452
  requirements:
@@ -455,7 +455,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
455
455
  version: '0'
456
456
  segments:
457
457
  - 0
458
- hash: 2922389583391730892
458
+ hash: 893090751339011969
459
459
  requirements: []
460
460
  rubyforge_project:
461
461
  rubygems_version: 1.8.15