protobuf 2.8.6 → 2.8.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bae0f4fcbb6ab57fe7866db45ea440c29899979d
4
- data.tar.gz: 0fb43022f7937ae06df7185a611eead5a9f2b217
3
+ metadata.gz: fa760a7ec58543a5e0cc40c95f95240646291506
4
+ data.tar.gz: ecd9644df44958b8f3330b574c119ba3b15e9f8d
5
5
  SHA512:
6
- metadata.gz: b063acb75ac9ce464056edc2d418cc588e6b0ac0b885441a57f9dfc8c5795ee87faba8d393c09f6a91a8d12417808a2dd5603643988bd8c821b76dc1fd1608dd
7
- data.tar.gz: 310368ac66f9e72150575ef01ec7f6cd7a1fba31a5bf33b926ca0743b1e907b623fd566d4b95f8a19ee4c5fc3b02b5d564049e2dbaae41c3f86997a679dcf847
6
+ metadata.gz: d33d3de6834639e094746377c53f3cebd3116306ec235fb358ce7be64ed18e2d158fdb79eb216e294ce8417a1d2962622a66d5e430245620bbd07290190d84eb
7
+ data.tar.gz: f3e322395f7c27c30559869d8df4147a80da23a391f4020c5df19db58295fd5a3414c18bc7198cef0100af50ce15128c2f9df83a1ee109795878334307bae9f6
data/.gitignore CHANGED
@@ -3,6 +3,7 @@
3
3
  pkg/*
4
4
  .bundle
5
5
  .rvmrc
6
+ .rspec
6
7
  *.log
7
8
  coverage
8
9
  doc
data/CHANGES.md CHANGED
@@ -1,3 +1,9 @@
1
+ 2.8.7
2
+ ---------
3
+
4
+ - Fire ActiveSupport load hooks when RPC Server and Client classes are loaded. [#126, @liveh2o]
5
+ - Prevent infinite loop when doing service lookup from directory. [#125, @brianstien]
6
+
1
7
  2.8.6
2
8
  ---------
3
9
 
data/README.md CHANGED
@@ -3,8 +3,7 @@
3
3
  [![Gem Version](https://badge.fury.io/rb/protobuf.png)](http://badge.fury.io/rb/protobuf)
4
4
  [![Build Status](https://secure.travis-ci.org/localshred/protobuf.png?branch=master)](https://travis-ci.org/localshred/protobuf)
5
5
 
6
- ___See [CHANGES.md](https://github.com/localshred/protobuf/blob/master/CHANGES.md) for up-to-date
7
- API changes.___
6
+ ___See [CHANGES.md](https://github.com/localshred/protobuf/blob/master/CHANGES.md) or [Release Notes](https://github.com/localshred/protobuf/releases) for significant version changes.___
8
7
 
9
8
  Protobuf is an implementation of [Google's protocol buffers][google-pb] in ruby, version 2.5.0 is currently supported.
10
9
 
@@ -162,5 +162,9 @@ module Protobuf
162
162
  end
163
163
 
164
164
  end
165
+
166
+ if ActiveSupport::VERSION::MAJOR > 2
167
+ ActiveSupport.run_load_hooks(:protobuf_rpc_client, Client)
168
+ end
165
169
  end
166
170
  end
@@ -87,13 +87,21 @@ module Protobuf
87
87
  # to the host and port in the options
88
88
  #
89
89
  def lookup_server_uri
90
- begin
91
- listing = service_directory.lookup(service)
92
- host = listing.try(:address) || options[:host]
93
- port = listing.try(:port) || options[:port]
94
- end until host_alive?( host )
90
+ 5.times do
91
+ service_directory.all_listings_for(service).each do |listing|
92
+ host = listing.try(:address)
93
+ port = listing.try(:port)
94
+ return "tcp://#{host}:#{port}" if host_alive?(host)
95
+ end
96
+
97
+ host = options[:host]
98
+ port = options[:port]
99
+ return "tcp://#{host}:#{port}" if host_alive?(host)
100
+
101
+ sleep 1
102
+ end
95
103
 
96
- "tcp://#{host}:#{port}"
104
+ raise "Host not found for service #{service}"
97
105
  end
98
106
 
99
107
  def host_alive?(host)
@@ -145,7 +153,7 @@ module Protobuf
145
153
  end
146
154
  ensure
147
155
  log_debug { sign_message("Closing Socket") }
148
- zmq_error_check(socket.close, :socket_close)
156
+ zmq_error_check(socket.close, :socket_close) if socket
149
157
  log_debug { sign_message("Socket closed") }
150
158
  end
151
159
 
@@ -205,5 +205,9 @@ module Protobuf
205
205
  end
206
206
 
207
207
  end
208
+
209
+ if ActiveSupport::VERSION::MAJOR > 2
210
+ ActiveSupport.run_load_hooks(:protobuf_rpc_service, Service)
211
+ end
208
212
  end
209
213
  end
@@ -85,6 +85,14 @@ module Protobuf
85
85
  reset
86
86
  end
87
87
 
88
+ def all_listings_for(service)
89
+ if running? && @listings_by_service.key?(service.to_s)
90
+ @listings_by_service[service.to_s].entries.shuffle
91
+ else
92
+ []
93
+ end
94
+ end
95
+
88
96
  def each_listing(&block)
89
97
  @listings_by_uuid.each_value(&block)
90
98
  end
@@ -1,4 +1,4 @@
1
1
  module Protobuf
2
- VERSION = '2.8.6'
2
+ VERSION = '2.8.7'
3
3
  PROTOC_VERSION = '2.5.0'
4
4
  end
@@ -31,6 +31,7 @@ describe ::Protobuf::Rpc::Connectors::Zmq do
31
31
  describe "#lookup_server_uri" do
32
32
  let(:service_directory) { double('ServiceDirectory', :running? => running? ) }
33
33
  let(:listing) { double('Listing', :address => '127.0.0.2', :port => 9399) }
34
+ let(:listings) { [listing] }
34
35
  let(:running?) { true }
35
36
 
36
37
  before do
@@ -39,12 +40,12 @@ describe ::Protobuf::Rpc::Connectors::Zmq do
39
40
 
40
41
  context "when the service directory is running" do
41
42
  it "searches the service directory" do
42
- service_directory.should_receive(:lookup).and_return(listing)
43
+ service_directory.stub(:all_listings_for).and_return(listings)
43
44
  subject.send(:lookup_server_uri).should eq "tcp://127.0.0.2:9399"
44
45
  end
45
46
 
46
47
  it "defaults to the options" do
47
- service_directory.should_receive(:lookup) { nil }
48
+ service_directory.stub(:all_listings_for).and_return([])
48
49
  subject.send(:lookup_server_uri).should eq "tcp://127.0.0.1:9400"
49
50
  end
50
51
  end
@@ -53,17 +54,25 @@ describe ::Protobuf::Rpc::Connectors::Zmq do
53
54
  let(:running?) { false }
54
55
 
55
56
  it "defaults to the options" do
56
- service_directory.should_receive(:lookup) { nil }
57
+ service_directory.stub(:all_listings_for).and_return([])
57
58
  subject.send(:lookup_server_uri).should eq "tcp://127.0.0.1:9400"
58
59
  end
59
60
  end
60
61
 
61
62
  it "checks if the server is alive" do
62
- service_directory.should_receive(:lookup) { nil }
63
+ service_directory.stub(:all_listings_for).and_return([])
63
64
  subject.should_receive(:host_alive?).with("127.0.0.1") { true }
64
65
  subject.send(:lookup_server_uri).should eq "tcp://127.0.0.1:9400"
65
66
  end
66
67
 
68
+ context "when no host is alive" do
69
+ it "raises an error" do
70
+ service_directory.stub(:all_listings_for).and_return(listings)
71
+ subject.stub(:host_alive?).and_return(false)
72
+ expect { subject.send(:lookup_server_uri) }.to raise_error
73
+ end
74
+ end
75
+
67
76
  end
68
77
 
69
78
  describe "#host_alive?" do
@@ -154,6 +154,23 @@ describe ::Protobuf::Rpc::ServiceDirectory do
154
154
  send_beacon(:flatline, echo_server)
155
155
  end
156
156
 
157
+ describe "#all_listings_for" do
158
+ context "when listings are present" do
159
+ it "returns all listings for a given service" do
160
+ send_beacon(:heartbeat, hello_server)
161
+ send_beacon(:heartbeat, combo_server)
162
+
163
+ subject.all_listings_for("HelloService").size.should eq(2)
164
+ end
165
+ end
166
+
167
+ context "when no listings are present" do
168
+ it "returns and empty array" do
169
+ subject.all_listings_for("HelloService").size.should eq(0)
170
+ end
171
+ end
172
+ end
173
+
157
174
  describe "#each_listing" do
158
175
  it "should yield to a block for each listing" do
159
176
  send_beacon(:heartbeat, hello_server)
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.8.6
4
+ version: 2.8.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - BJ Neilsen
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-09-17 00:00:00.000000000 Z
13
+ date: 2013-10-07 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport