protobuf 2.8.0.beta5 → 2.8.0.beta6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8c1f25ffde20a579438083ec4b093a3b69e4df0e
4
+ data.tar.gz: 5745bab0fb469561800260865054a5996a358e54
5
+ SHA512:
6
+ metadata.gz: d7f10fcee632cfd3dd496feaf6860d1fcc756b0196e08848033ed9fce721a03d37d01eed9e171debb60dbc829793600dc09b7f614d414995b77c1fa784f926d5
7
+ data.tar.gz: d9099f622b4630c29273f287ca0eae438acc053533797b365fcbb1c5f303659439385fb3fff4a4887c6c4759036897da6e49780faf7ef3f26fcb55882a0f768c
data/lib/protobuf/cli.rb CHANGED
@@ -29,7 +29,6 @@ module Protobuf
29
29
  option :evented, :type => :boolean, :aliases => %w(-m), :desc => 'Evented Mode for server and client connections (uses EventMachine).'
30
30
  option :zmq, :type => :boolean, :aliases => %w(-z), :desc => 'ZeroMQ Socket Mode for server and client connections.'
31
31
 
32
- option :beacon_address, :type => :string, :desc => 'Broadcast beacons to this address (defaul: value of ServiceDirectory.address)'
33
32
  option :beacon_interval, :type => :numeric, :desc => 'Broadcast beacons every N seconds. (default: 5)'
34
33
  option :beacon_port, :type => :numeric, :desc => 'Broadcast beacons to this port (default: value of ServiceDirectory.port)'
35
34
  option :broadcast_beacons, :type => :boolean, :desc => 'Broadcast beacons for dynamic discovery (Currently only available with ZeroMQ).'
@@ -68,7 +68,6 @@ module Protobuf
68
68
  @socket.flush
69
69
  log_debug { sign_message("write closed") }
70
70
  end
71
-
72
71
  end
73
72
  end
74
73
  end
@@ -6,6 +6,8 @@ module Protobuf
6
6
  module Connectors
7
7
  class Zmq < Base
8
8
 
9
+ RequestTimeout = Class.new(RuntimeError)
10
+
9
11
  ##
10
12
  # Included Modules
11
13
  #
@@ -23,7 +25,11 @@ module Protobuf
23
25
  # Class Methods
24
26
  #
25
27
  def self.zmq_context
26
- @zmq_context ||= ZMQ::Context.new
28
+ @zmq_contexts ||= Hash.new { |hash, key|
29
+ hash[key] = ZMQ::Context.new
30
+ }
31
+
32
+ @zmq_contexts[Process.pid]
27
33
  end
28
34
 
29
35
  ##
@@ -37,9 +43,7 @@ module Protobuf
37
43
  #
38
44
  def send_request
39
45
  setup_connection
40
- poll_send_data
41
- ensure
42
- close_connection
46
+ send_request_with_lazy_pirate
43
47
  end
44
48
 
45
49
  def log_signature
@@ -53,23 +57,23 @@ module Protobuf
53
57
  #
54
58
 
55
59
  def close_connection
56
- socket_close
60
+ # The socket is automatically closed after every request.
57
61
  end
58
62
 
59
- # Establish a request socket connection to the remote rpc_server.
60
- # Set the socket option LINGER to 0 so that we don't wait
61
- # for queued messages to be accepted when the socket/context are
62
- # asked to close/terminate.
63
- #
64
- def connect_to_rpc_server
65
- return if error?
66
-
63
+ # Create a socket connected to a server that can handle the current
64
+ # service. The LINGER is set to 0 so we can close immediately in
65
+ # the event of a timeout
66
+ def create_socket
67
67
  server_uri = lookup_server_uri
68
- log_debug { sign_message("Establishing connection: #{server_uri}") }
68
+
69
+ socket = zmq_context.socket(::ZMQ::REQ)
69
70
  socket.setsockopt(::ZMQ::LINGER, 0)
71
+
72
+ log_debug { sign_message("Establishing connection: #{server_uri}") }
70
73
  zmq_error_check(socket.connect(server_uri), :socket_connect)
71
- zmq_error_check(poller.register_readable(socket), :poller_register_readable)
72
74
  log_debug { sign_message("Connection established to #{server_uri}") }
75
+
76
+ socket
73
77
  end
74
78
 
75
79
  # Method to determine error state, must be used with Connector API.
@@ -97,53 +101,44 @@ module Protobuf
97
101
  # If we haven't received a legitimate response in the CLIENT_RETRIES number
98
102
  # of retries, fail the request.
99
103
  #
100
- def poll_send_data
101
- return if error?
102
-
103
- poll_timeout = (options[:timeout].to_f / CLIENT_RETRIES.to_f) * 1000
104
-
105
- CLIENT_RETRIES.times do |n|
106
- connect_to_rpc_server
107
- log_debug { sign_message("Sending Request (attempt #{n + 1}, #{socket})") }
108
- send_data
109
- log_debug { sign_message("Request sending complete (attempt #{n + 1}, #{socket})") }
110
-
111
- if poller.poll(poll_timeout) == 1
112
- read_response
113
- return
114
- else
115
- socket_close
116
- end
117
- end
118
-
119
- fail(:RPC_FAILED, "The server took longer than #{options[:timeout]} seconds to respond")
120
- end
104
+ def send_request_with_lazy_pirate
105
+ attempt = 0
106
+ timeout = options[:timeout].to_f
107
+ @stats.request_size = @request_data.size
121
108
 
122
- def poller
123
- @poller ||= ::ZMQ::Poller.new
109
+ begin
110
+ attempt += 1
111
+ send_request_with_timeout(timeout, attempt)
112
+ parse_response
113
+ rescue RequestTimeout
114
+ retry if attempt < CLIENT_RETRIES
115
+ fail(:RPC_FAILED, "The server repeatedly failed to respond within #{timeout} seconds")
116
+ rescue => e
117
+ fail(:RPC_FAILED, "Unexpected error sending request: #{e}")
118
+ end
124
119
  end
125
120
 
126
- # Read the string response from the available readable. This will be
127
- # the current @socket. Calls `parse_response` to invoke the success or
128
- # failed callbacks, depending on the state of the communication
129
- # and response data.
130
- #
131
- def read_response
132
- return if error?
133
-
134
- @response_data = ''
135
- zmq_error_check(socket.recv_string(@response_data), :socket_recv_string)
136
-
137
- parse_response
138
- end
121
+ def send_request_with_timeout(timeout, attempt = 0)
122
+ socket = create_socket
139
123
 
140
- # Send the request data to the remote rpc_server.
141
- #
142
- def send_data
143
- return if error?
124
+ poller = ::ZMQ::Poller.new
125
+ poller.register_readable(socket)
144
126
 
145
- @stats.request_size = @request_data.size
127
+ log_debug { sign_message("Sending Request (attempt #{attempt}, #{socket})") }
146
128
  zmq_error_check(socket.send_string(@request_data), :socket_send_string)
129
+ log_debug { sign_message("Waiting #{timeout} seconds for response (attempt #{attempt}, #{socket})") }
130
+
131
+ if poller.poll(timeout * 1000) == 1
132
+ zmq_error_check(socket.recv_string(@response_data = ""), :socket_recv_string)
133
+ log_debug { sign_message("Response received (attempt #{attempt}, #{socket})") }
134
+ else
135
+ log_debug { sign_message("Timed out waiting for response (attempt #{attempt}, #{socket})") }
136
+ raise RequestTimeout
137
+ end
138
+ ensure
139
+ log_debug { sign_message("Closing Socket") }
140
+ zmq_error_check(socket.close, :socket_close)
141
+ log_debug { sign_message("Socket closed") }
147
142
  end
148
143
 
149
144
  # The service we're attempting to connect to
@@ -157,21 +152,6 @@ module Protobuf
157
152
  ::Protobuf::Rpc::ServiceDirectory.instance
158
153
  end
159
154
 
160
- # Setup a ZMQ request socket in the current zmq context.
161
- #
162
- def socket
163
- @socket ||= zmq_context.socket(::ZMQ::REQ)
164
- end
165
-
166
- def socket_close
167
- if socket
168
- log_debug { sign_message("Closing Socket") }
169
- zmq_error_check(socket.close, :socket_close)
170
- log_debug { sign_message("Socket closed") }
171
- @socket = nil
172
- end
173
- end
174
-
175
155
  # Return the ZMQ Context to use for this process.
176
156
  # If the context does not exist, create it, then register
177
157
  # an exit block to ensure the context is terminated correctly.
@@ -189,7 +169,6 @@ module Protobuf
189
169
  ERROR
190
170
  end
191
171
  end
192
-
193
172
  end
194
173
  end
195
174
  end
@@ -50,15 +50,7 @@ module Protobuf
50
50
  end
51
51
 
52
52
  def beacon_ip
53
- unless @beacon_ip
54
- unless address = options[:beacon_address]
55
- address = ::Protobuf::Rpc::ServiceDirectory.address
56
- end
57
-
58
- @beacon_ip = resolve_ip(address)
59
- end
60
-
61
- @beacon_ip
53
+ "255.255.255.255"
62
54
  end
63
55
 
64
56
  def beacon_port
@@ -39,6 +39,10 @@ module Protobuf
39
39
  @server.add_worker
40
40
  log_info { "Increased worker size to: #{@server.total_workers}" }
41
41
  end
42
+
43
+ trap(:TTOU) do
44
+ log_info { "Current worker size: #{@server.workers.size}" }
45
+ end
42
46
  end
43
47
  end
44
48
  end
@@ -1,4 +1,4 @@
1
1
  module Protobuf
2
- VERSION = '2.8.0.beta5'
2
+ VERSION = '2.8.0.beta6'
3
3
  PROTOC_VERSION = '2.4.1'
4
4
  end
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: protobuf
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.8.0.beta5
5
- prerelease: 6
4
+ version: 2.8.0.beta6
6
5
  platform: ruby
7
6
  authors:
8
7
  - BJ Neilsen
@@ -10,214 +9,188 @@ authors:
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2013-06-26 00:00:00.000000000 Z
12
+ date: 2013-07-03 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: activesupport
17
16
  requirement: !ruby/object:Gem::Requirement
18
- none: false
19
17
  requirements:
20
- - - ! '>='
18
+ - - '>='
21
19
  - !ruby/object:Gem::Version
22
20
  version: '0'
23
21
  type: :runtime
24
22
  prerelease: false
25
23
  version_requirements: !ruby/object:Gem::Requirement
26
- none: false
27
24
  requirements:
28
- - - ! '>='
25
+ - - '>='
29
26
  - !ruby/object:Gem::Version
30
27
  version: '0'
31
28
  - !ruby/object:Gem::Dependency
32
29
  name: ffi
33
30
  requirement: !ruby/object:Gem::Requirement
34
- none: false
35
31
  requirements:
36
- - - ! '>='
32
+ - - '>='
37
33
  - !ruby/object:Gem::Version
38
34
  version: '0'
39
35
  type: :runtime
40
36
  prerelease: false
41
37
  version_requirements: !ruby/object:Gem::Requirement
42
- none: false
43
38
  requirements:
44
- - - ! '>='
39
+ - - '>='
45
40
  - !ruby/object:Gem::Version
46
41
  version: '0'
47
42
  - !ruby/object:Gem::Dependency
48
43
  name: multi_json
49
44
  requirement: !ruby/object:Gem::Requirement
50
- none: false
51
45
  requirements:
52
- - - ! '>='
46
+ - - '>='
53
47
  - !ruby/object:Gem::Version
54
48
  version: '0'
55
49
  type: :runtime
56
50
  prerelease: false
57
51
  version_requirements: !ruby/object:Gem::Requirement
58
- none: false
59
52
  requirements:
60
- - - ! '>='
53
+ - - '>='
61
54
  - !ruby/object:Gem::Version
62
55
  version: '0'
63
56
  - !ruby/object:Gem::Dependency
64
57
  name: thor
65
58
  requirement: !ruby/object:Gem::Requirement
66
- none: false
67
59
  requirements:
68
- - - ! '>='
60
+ - - '>='
69
61
  - !ruby/object:Gem::Version
70
62
  version: '0'
71
63
  type: :runtime
72
64
  prerelease: false
73
65
  version_requirements: !ruby/object:Gem::Requirement
74
- none: false
75
66
  requirements:
76
- - - ! '>='
67
+ - - '>='
77
68
  - !ruby/object:Gem::Version
78
69
  version: '0'
79
70
  - !ruby/object:Gem::Dependency
80
71
  name: eventmachine
81
72
  requirement: !ruby/object:Gem::Requirement
82
- none: false
83
73
  requirements:
84
- - - ! '>='
74
+ - - '>='
85
75
  - !ruby/object:Gem::Version
86
76
  version: '0'
87
77
  type: :development
88
78
  prerelease: false
89
79
  version_requirements: !ruby/object:Gem::Requirement
90
- none: false
91
80
  requirements:
92
- - - ! '>='
81
+ - - '>='
93
82
  - !ruby/object:Gem::Version
94
83
  version: '0'
95
84
  - !ruby/object:Gem::Dependency
96
85
  name: ffi-rzmq
97
86
  requirement: !ruby/object:Gem::Requirement
98
- none: false
99
87
  requirements:
100
- - - ! '>='
88
+ - - '>='
101
89
  - !ruby/object:Gem::Version
102
90
  version: '0'
103
91
  type: :development
104
92
  prerelease: false
105
93
  version_requirements: !ruby/object:Gem::Requirement
106
- none: false
107
94
  requirements:
108
- - - ! '>='
95
+ - - '>='
109
96
  - !ruby/object:Gem::Version
110
97
  version: '0'
111
98
  - !ruby/object:Gem::Dependency
112
99
  name: pry
113
100
  requirement: !ruby/object:Gem::Requirement
114
- none: false
115
101
  requirements:
116
- - - ! '>='
102
+ - - '>='
117
103
  - !ruby/object:Gem::Version
118
104
  version: '0'
119
105
  type: :development
120
106
  prerelease: false
121
107
  version_requirements: !ruby/object:Gem::Requirement
122
- none: false
123
108
  requirements:
124
- - - ! '>='
109
+ - - '>='
125
110
  - !ruby/object:Gem::Version
126
111
  version: '0'
127
112
  - !ruby/object:Gem::Dependency
128
113
  name: pry-nav
129
114
  requirement: !ruby/object:Gem::Requirement
130
- none: false
131
115
  requirements:
132
- - - ! '>='
116
+ - - '>='
133
117
  - !ruby/object:Gem::Version
134
118
  version: '0'
135
119
  type: :development
136
120
  prerelease: false
137
121
  version_requirements: !ruby/object:Gem::Requirement
138
- none: false
139
122
  requirements:
140
- - - ! '>='
123
+ - - '>='
141
124
  - !ruby/object:Gem::Version
142
125
  version: '0'
143
126
  - !ruby/object:Gem::Dependency
144
127
  name: rake
145
128
  requirement: !ruby/object:Gem::Requirement
146
- none: false
147
129
  requirements:
148
- - - ! '>='
130
+ - - '>='
149
131
  - !ruby/object:Gem::Version
150
132
  version: '0'
151
133
  type: :development
152
134
  prerelease: false
153
135
  version_requirements: !ruby/object:Gem::Requirement
154
- none: false
155
136
  requirements:
156
- - - ! '>='
137
+ - - '>='
157
138
  - !ruby/object:Gem::Version
158
139
  version: '0'
159
140
  - !ruby/object:Gem::Dependency
160
141
  name: rake-compiler
161
142
  requirement: !ruby/object:Gem::Requirement
162
- none: false
163
143
  requirements:
164
- - - ! '>='
144
+ - - '>='
165
145
  - !ruby/object:Gem::Version
166
146
  version: '0'
167
147
  type: :development
168
148
  prerelease: false
169
149
  version_requirements: !ruby/object:Gem::Requirement
170
- none: false
171
150
  requirements:
172
- - - ! '>='
151
+ - - '>='
173
152
  - !ruby/object:Gem::Version
174
153
  version: '0'
175
154
  - !ruby/object:Gem::Dependency
176
155
  name: rspec
177
156
  requirement: !ruby/object:Gem::Requirement
178
- none: false
179
157
  requirements:
180
- - - ! '>='
158
+ - - '>='
181
159
  - !ruby/object:Gem::Version
182
160
  version: '0'
183
161
  type: :development
184
162
  prerelease: false
185
163
  version_requirements: !ruby/object:Gem::Requirement
186
- none: false
187
164
  requirements:
188
- - - ! '>='
165
+ - - '>='
189
166
  - !ruby/object:Gem::Version
190
167
  version: '0'
191
168
  - !ruby/object:Gem::Dependency
192
169
  name: simplecov
193
170
  requirement: !ruby/object:Gem::Requirement
194
- none: false
195
171
  requirements:
196
- - - ! '>='
172
+ - - '>='
197
173
  - !ruby/object:Gem::Version
198
174
  version: '0'
199
175
  type: :development
200
176
  prerelease: false
201
177
  version_requirements: !ruby/object:Gem::Requirement
202
- none: false
203
178
  requirements:
204
- - - ! '>='
179
+ - - '>='
205
180
  - !ruby/object:Gem::Version
206
181
  version: '0'
207
182
  - !ruby/object:Gem::Dependency
208
183
  name: yard
209
184
  requirement: !ruby/object:Gem::Requirement
210
- none: false
211
185
  requirements:
212
- - - ! '>='
186
+ - - '>='
213
187
  - !ruby/object:Gem::Version
214
188
  version: '0'
215
189
  type: :development
216
190
  prerelease: false
217
191
  version_requirements: !ruby/object:Gem::Requirement
218
- none: false
219
192
  requirements:
220
- - - ! '>='
193
+ - - '>='
221
194
  - !ruby/object:Gem::Version
222
195
  version: '0'
223
196
  description: Google Protocol Buffers v2.4.1 Serialization and RPC implementation for
@@ -495,30 +468,26 @@ files:
495
468
  - test/test_types.rb
496
469
  homepage: https://github.com/localshred/protobuf
497
470
  licenses: []
471
+ metadata: {}
498
472
  post_install_message:
499
473
  rdoc_options: []
500
474
  require_paths:
501
475
  - lib
502
476
  required_ruby_version: !ruby/object:Gem::Requirement
503
- none: false
504
477
  requirements:
505
- - - ! '>='
478
+ - - '>='
506
479
  - !ruby/object:Gem::Version
507
480
  version: '0'
508
- segments:
509
- - 0
510
- hash: -2179465812601701045
511
481
  required_rubygems_version: !ruby/object:Gem::Requirement
512
- none: false
513
482
  requirements:
514
- - - ! '>'
483
+ - - '>'
515
484
  - !ruby/object:Gem::Version
516
485
  version: 1.3.1
517
486
  requirements: []
518
487
  rubyforge_project:
519
- rubygems_version: 1.8.23
488
+ rubygems_version: 2.0.2
520
489
  signing_key:
521
- specification_version: 3
490
+ specification_version: 4
522
491
  summary: Google Protocol Buffers v2.4.1 Serialization and RPC implementation for Ruby.
523
492
  test_files:
524
493
  - spec/benchmark/tasks.rb