protobuf 3.4.2 → 3.4.3

Sign up to get free protection for your applications and to get access to all the features.
data/.rubocop.yml CHANGED
@@ -6,6 +6,9 @@ Lint/EndAlignment:
6
6
  Lint/Loop:
7
7
  Enabled: false
8
8
 
9
+ Metrics/ClassLength:
10
+ Enabled: false
11
+
9
12
  Style/CaseIndentation:
10
13
  IndentWhenRelativeTo: end
11
14
 
@@ -11,6 +11,10 @@ module Protobuf
11
11
  new.decode(bytes)
12
12
  end
13
13
 
14
+ def decode_from(stream)
15
+ new.decode_from(stream)
16
+ end
17
+
14
18
  # Create a new object with the given values and return the encoded bytes.
15
19
  def encode(fields = {})
16
20
  new(fields).encode
@@ -59,11 +59,25 @@ module Protobuf
59
59
  # Private Instance methods
60
60
  #
61
61
  def check_available_rcv_timeout
62
- @check_available_rcv_timeout ||= [ENV["PB_ZMQ_CLIENT_CHECK_AVAILABLE_RCV_TIMEOUT"].to_i, 200].max
62
+ @check_available_rcv_timeout ||= begin
63
+ case
64
+ when ENV.key?("PB_ZMQ_CLIENT_CHECK_AVAILABLE_RCV_TIMEOUT") then
65
+ ENV["PB_ZMQ_CLIENT_CHECK_AVAILABLE_RCV_TIMEOUT"].to_i
66
+ else
67
+ 200 # ms
68
+ end
69
+ end
63
70
  end
64
71
 
65
72
  def check_available_snd_timeout
66
- @check_available_snd_timeout ||= [ENV["PB_ZMQ_CLIENT_CHECK_AVAILABLE_SND_TIMEOUT"].to_i, 200].max
73
+ @check_available_snd_timeout ||= begin
74
+ case
75
+ when ENV.key?("PB_ZMQ_CLIENT_CHECK_AVAILABLE_SND_TIMEOUT") then
76
+ ENV["PB_ZMQ_CLIENT_CHECK_AVAILABLE_SND_TIMEOUT"].to_i
77
+ else
78
+ 200 # ms
79
+ end
80
+ end
67
81
  end
68
82
 
69
83
  def close_connection
@@ -23,6 +23,7 @@ module Protobuf
23
23
 
24
24
  def run
25
25
  @idle_workers = []
26
+ @running = true
26
27
 
27
28
  loop do
28
29
  process_local_queue
@@ -39,10 +40,11 @@ module Protobuf
39
40
  end
40
41
  ensure
41
42
  teardown
43
+ @running = false
42
44
  end
43
45
 
44
46
  def running?
45
- @server.running?
47
+ @running && @server.running?
46
48
  end
47
49
 
48
50
  private
@@ -76,6 +76,10 @@ module Protobuf
76
76
  !brokerless? && options[:broadcast_beacons]
77
77
  end
78
78
 
79
+ def broadcast_busy?
80
+ broadcast_beacons? && options[:broadcast_busy]
81
+ end
82
+
79
83
  def broadcast_flatline
80
84
  flatline = ::Protobuf::Rpc::DynamicDiscovery::Beacon.new(
81
85
  :beacon_type => ::Protobuf::Rpc::DynamicDiscovery::BeaconType::FLATLINE,
@@ -176,15 +180,11 @@ module Protobuf
176
180
 
177
181
  def run
178
182
  @running = true
179
-
180
- start_broker unless brokerless?
181
- start_missing_workers
182
-
183
183
  yield if block_given? # runs on startup
184
184
  wait_for_shutdown_signal
185
185
  broadcast_flatline if broadcast_beacons?
186
186
  Thread.pass until reap_dead_workers.empty?
187
- @broker.join unless brokerless?
187
+ @broker_thread.join unless brokerless?
188
188
  ensure
189
189
  @running = false
190
190
  teardown
@@ -246,14 +246,13 @@ module Protobuf
246
246
  loop do
247
247
  break if IO.select([@shutdown_r], nil, nil, timeout)
248
248
 
249
- if reap_dead_workers?
250
- reap_dead_workers
251
- start_missing_workers
252
- end
249
+ start_broker unless brokerless?
250
+ reap_dead_workers if reap_dead_workers?
251
+ start_missing_workers
253
252
 
254
253
  next unless broadcast_heartbeat?
255
254
 
256
- if options[:broadcast_busy] && all_workers_busy?
255
+ if broadcast_busy? && all_workers_busy?
257
256
  broadcast_flatline
258
257
  else
259
258
  broadcast_heartbeat
@@ -285,15 +284,29 @@ module Protobuf
285
284
  end
286
285
 
287
286
  def start_broker
288
- @broker = Thread.new(self) do |server|
289
- ::Protobuf::Rpc::Zmq::Broker.new(server).run
287
+ return if @broker && @broker.running? && !@broker_thread.stop?
288
+ if @broker && !@broker.running?
289
+ broadcast_flatline if broadcast_busy?
290
+ @broker_thread.join if @broker_thread
291
+ init_zmq_context # need a new context to restart the broker
292
+ end
293
+
294
+ @broker = ::Protobuf::Rpc::Zmq::Broker.new(self)
295
+ @broker_thread = Thread.new(@broker) do |broker|
296
+ begin
297
+ broker.run
298
+ rescue => e
299
+ message = "Broker failed: #{e.inspect}\n #{e.backtrace.join($INPUT_RECORD_SEPARATOR)}"
300
+ $stderr.puts(message)
301
+ logger.error { message }
302
+ end
290
303
  end
291
304
  end
292
305
 
293
306
  def start_worker
294
- @workers << Thread.new(self) do |server|
307
+ @workers << Thread.new(self, @broker) do |server, broker|
295
308
  begin
296
- ::Protobuf::Rpc::Zmq::Worker.new(server).run
309
+ ::Protobuf::Rpc::Zmq::Worker.new(server, broker).run
297
310
  rescue => e
298
311
  message = "Worker failed: #{e.inspect}\n #{e.backtrace.join($INPUT_RECORD_SEPARATOR)}"
299
312
  $stderr.puts(message)
@@ -12,8 +12,9 @@ module Protobuf
12
12
  ##
13
13
  # Constructor
14
14
  #
15
- def initialize(server)
15
+ def initialize(server, broker)
16
16
  @server = server
17
+ @broker = broker
17
18
 
18
19
  init_zmq_context
19
20
  init_backend_socket
@@ -61,7 +62,7 @@ module Protobuf
61
62
  end
62
63
 
63
64
  def running?
64
- @server.running?
65
+ @broker.running? && @server.running?
65
66
  end
66
67
 
67
68
  private
@@ -1,3 +1,3 @@
1
1
  module Protobuf
2
- VERSION = '3.4.2'
2
+ VERSION = '3.4.3'
3
3
  end
@@ -1,5 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
+ require 'stringio'
3
4
  require 'spec_helper'
4
5
 
5
6
  RSpec.describe Protobuf::Message do
@@ -71,6 +72,15 @@ RSpec.describe Protobuf::Message do
71
72
  end
72
73
  end
73
74
 
75
+ describe '.decode_from' do
76
+ let(:message) { ::Test::Resource.new(:name => "Jim") }
77
+
78
+ it 'creates a new message object decoded from the given byte stream' do
79
+ stream = ::StringIO.new(message.encode)
80
+ expect(::Test::Resource.decode_from(stream)).to eq message
81
+ end
82
+ end
83
+
74
84
  describe 'defining a new field' do
75
85
  context 'when defining a field with a tag that has already been used' do
76
86
  it 'raises a TagCollisionError' do
metadata CHANGED
@@ -1,7 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: protobuf
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.2
4
+ version: 3.4.3
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - BJ Neilsen
@@ -11,202 +12,230 @@ authors:
11
12
  autorequire:
12
13
  bindir: bin
13
14
  cert_chain: []
14
- date: 2014-12-29 00:00:00.000000000 Z
15
+ date: 2015-01-17 00:00:00.000000000 Z
15
16
  dependencies:
16
17
  - !ruby/object:Gem::Dependency
17
18
  name: activesupport
18
19
  requirement: !ruby/object:Gem::Requirement
20
+ none: false
19
21
  requirements:
20
- - - ">="
22
+ - - ! '>='
21
23
  - !ruby/object:Gem::Version
22
24
  version: '3.2'
23
25
  type: :runtime
24
26
  prerelease: false
25
27
  version_requirements: !ruby/object:Gem::Requirement
28
+ none: false
26
29
  requirements:
27
- - - ">="
30
+ - - ! '>='
28
31
  - !ruby/object:Gem::Version
29
32
  version: '3.2'
30
33
  - !ruby/object:Gem::Dependency
31
34
  name: middleware
32
35
  requirement: !ruby/object:Gem::Requirement
36
+ none: false
33
37
  requirements:
34
- - - ">="
38
+ - - ! '>='
35
39
  - !ruby/object:Gem::Version
36
40
  version: '0'
37
41
  type: :runtime
38
42
  prerelease: false
39
43
  version_requirements: !ruby/object:Gem::Requirement
44
+ none: false
40
45
  requirements:
41
- - - ">="
46
+ - - ! '>='
42
47
  - !ruby/object:Gem::Version
43
48
  version: '0'
44
49
  - !ruby/object:Gem::Dependency
45
50
  name: thor
46
51
  requirement: !ruby/object:Gem::Requirement
52
+ none: false
47
53
  requirements:
48
- - - ">="
54
+ - - ! '>='
49
55
  - !ruby/object:Gem::Version
50
56
  version: '0'
51
57
  type: :runtime
52
58
  prerelease: false
53
59
  version_requirements: !ruby/object:Gem::Requirement
60
+ none: false
54
61
  requirements:
55
- - - ">="
62
+ - - ! '>='
56
63
  - !ruby/object:Gem::Version
57
64
  version: '0'
58
65
  - !ruby/object:Gem::Dependency
59
66
  name: thread_safe
60
67
  requirement: !ruby/object:Gem::Requirement
68
+ none: false
61
69
  requirements:
62
- - - ">="
70
+ - - ! '>='
63
71
  - !ruby/object:Gem::Version
64
72
  version: '0'
65
73
  type: :runtime
66
74
  prerelease: false
67
75
  version_requirements: !ruby/object:Gem::Requirement
76
+ none: false
68
77
  requirements:
69
- - - ">="
78
+ - - ! '>='
70
79
  - !ruby/object:Gem::Version
71
80
  version: '0'
72
81
  - !ruby/object:Gem::Dependency
73
82
  name: ffi-rzmq
74
83
  requirement: !ruby/object:Gem::Requirement
84
+ none: false
75
85
  requirements:
76
- - - ">="
86
+ - - ! '>='
77
87
  - !ruby/object:Gem::Version
78
88
  version: '0'
79
89
  type: :development
80
90
  prerelease: false
81
91
  version_requirements: !ruby/object:Gem::Requirement
92
+ none: false
82
93
  requirements:
83
- - - ">="
94
+ - - ! '>='
84
95
  - !ruby/object:Gem::Version
85
96
  version: '0'
86
97
  - !ruby/object:Gem::Dependency
87
98
  name: rake
88
99
  requirement: !ruby/object:Gem::Requirement
100
+ none: false
89
101
  requirements:
90
- - - ">="
102
+ - - ! '>='
91
103
  - !ruby/object:Gem::Version
92
104
  version: '0'
93
105
  type: :development
94
106
  prerelease: false
95
107
  version_requirements: !ruby/object:Gem::Requirement
108
+ none: false
96
109
  requirements:
97
- - - ">="
110
+ - - ! '>='
98
111
  - !ruby/object:Gem::Version
99
112
  version: '0'
100
113
  - !ruby/object:Gem::Dependency
101
114
  name: rspec
102
115
  requirement: !ruby/object:Gem::Requirement
116
+ none: false
103
117
  requirements:
104
- - - ">="
118
+ - - ! '>='
105
119
  - !ruby/object:Gem::Version
106
120
  version: '3.0'
107
121
  type: :development
108
122
  prerelease: false
109
123
  version_requirements: !ruby/object:Gem::Requirement
124
+ none: false
110
125
  requirements:
111
- - - ">="
126
+ - - ! '>='
112
127
  - !ruby/object:Gem::Version
113
128
  version: '3.0'
114
129
  - !ruby/object:Gem::Dependency
115
130
  name: rubocop
116
131
  requirement: !ruby/object:Gem::Requirement
132
+ none: false
117
133
  requirements:
118
- - - ">="
134
+ - - ! '>='
119
135
  - !ruby/object:Gem::Version
120
136
  version: '0'
121
137
  type: :development
122
138
  prerelease: false
123
139
  version_requirements: !ruby/object:Gem::Requirement
140
+ none: false
124
141
  requirements:
125
- - - ">="
142
+ - - ! '>='
126
143
  - !ruby/object:Gem::Version
127
144
  version: '0'
128
145
  - !ruby/object:Gem::Dependency
129
146
  name: simplecov
130
147
  requirement: !ruby/object:Gem::Requirement
148
+ none: false
131
149
  requirements:
132
- - - ">="
150
+ - - ! '>='
133
151
  - !ruby/object:Gem::Version
134
152
  version: '0'
135
153
  type: :development
136
154
  prerelease: false
137
155
  version_requirements: !ruby/object:Gem::Requirement
156
+ none: false
138
157
  requirements:
139
- - - ">="
158
+ - - ! '>='
140
159
  - !ruby/object:Gem::Version
141
160
  version: '0'
142
161
  - !ruby/object:Gem::Dependency
143
162
  name: timecop
144
163
  requirement: !ruby/object:Gem::Requirement
164
+ none: false
145
165
  requirements:
146
- - - ">="
166
+ - - ! '>='
147
167
  - !ruby/object:Gem::Version
148
168
  version: '0'
149
169
  type: :development
150
170
  prerelease: false
151
171
  version_requirements: !ruby/object:Gem::Requirement
172
+ none: false
152
173
  requirements:
153
- - - ">="
174
+ - - ! '>='
154
175
  - !ruby/object:Gem::Version
155
176
  version: '0'
156
177
  - !ruby/object:Gem::Dependency
157
178
  name: yard
158
179
  requirement: !ruby/object:Gem::Requirement
180
+ none: false
159
181
  requirements:
160
- - - ">="
182
+ - - ! '>='
161
183
  - !ruby/object:Gem::Version
162
184
  version: '0'
163
185
  type: :development
164
186
  prerelease: false
165
187
  version_requirements: !ruby/object:Gem::Requirement
188
+ none: false
166
189
  requirements:
167
- - - ">="
190
+ - - ! '>='
168
191
  - !ruby/object:Gem::Version
169
192
  version: '0'
170
193
  - !ruby/object:Gem::Dependency
171
- name: pry-byebug
194
+ name: pry-debugger
172
195
  requirement: !ruby/object:Gem::Requirement
196
+ none: false
173
197
  requirements:
174
- - - ">="
198
+ - - ! '>='
175
199
  - !ruby/object:Gem::Version
176
200
  version: '0'
177
201
  type: :development
178
202
  prerelease: false
179
203
  version_requirements: !ruby/object:Gem::Requirement
204
+ none: false
180
205
  requirements:
181
- - - ">="
206
+ - - ! '>='
182
207
  - !ruby/object:Gem::Version
183
208
  version: '0'
184
209
  - !ruby/object:Gem::Dependency
185
210
  name: pry-stack_explorer
186
211
  requirement: !ruby/object:Gem::Requirement
212
+ none: false
187
213
  requirements:
188
- - - ">="
214
+ - - ! '>='
189
215
  - !ruby/object:Gem::Version
190
216
  version: '0'
191
217
  type: :development
192
218
  prerelease: false
193
219
  version_requirements: !ruby/object:Gem::Requirement
220
+ none: false
194
221
  requirements:
195
- - - ">="
222
+ - - ! '>='
196
223
  - !ruby/object:Gem::Version
197
224
  version: '0'
198
225
  - !ruby/object:Gem::Dependency
199
226
  name: ruby-prof
200
227
  requirement: !ruby/object:Gem::Requirement
228
+ none: false
201
229
  requirements:
202
- - - ">="
230
+ - - ! '>='
203
231
  - !ruby/object:Gem::Version
204
232
  version: '0'
205
233
  type: :development
206
234
  prerelease: false
207
235
  version_requirements: !ruby/object:Gem::Requirement
236
+ none: false
208
237
  requirements:
209
- - - ">="
238
+ - - ! '>='
210
239
  - !ruby/object:Gem::Version
211
240
  version: '0'
212
241
  description: Google Protocol Buffers serialization and RPC implementation for Ruby.
@@ -221,11 +250,11 @@ executables:
221
250
  extensions: []
222
251
  extra_rdoc_files: []
223
252
  files:
224
- - ".gitignore"
225
- - ".rubocop.yml"
226
- - ".rubocop_todo.yml"
227
- - ".travis.yml"
228
- - ".yardopts"
253
+ - .gitignore
254
+ - .rubocop.yml
255
+ - .rubocop_todo.yml
256
+ - .travis.yml
257
+ - .yardopts
229
258
  - CHANGES.md
230
259
  - CONTRIBUTING.md
231
260
  - Gemfile
@@ -401,96 +430,33 @@ files:
401
430
  homepage: https://github.com/localshred/protobuf
402
431
  licenses:
403
432
  - MIT
404
- metadata: {}
405
433
  post_install_message:
406
434
  rdoc_options: []
407
435
  require_paths:
408
436
  - lib
409
437
  required_ruby_version: !ruby/object:Gem::Requirement
438
+ none: false
410
439
  requirements:
411
- - - ">="
440
+ - - ! '>='
412
441
  - !ruby/object:Gem::Version
413
442
  version: '0'
443
+ segments:
444
+ - 0
445
+ hash: -2458400158971729281
414
446
  required_rubygems_version: !ruby/object:Gem::Requirement
447
+ none: false
415
448
  requirements:
416
- - - ">="
449
+ - - ! '>='
417
450
  - !ruby/object:Gem::Version
418
451
  version: '0'
452
+ segments:
453
+ - 0
454
+ hash: -2458400158971729281
419
455
  requirements: []
420
456
  rubyforge_project:
421
- rubygems_version: 2.2.2
457
+ rubygems_version: 1.8.24
422
458
  signing_key:
423
- specification_version: 4
459
+ specification_version: 3
424
460
  summary: Google Protocol Buffers serialization and RPC implementation for Ruby.
425
- test_files:
426
- - spec/benchmark/tasks.rb
427
- - spec/bin/protoc-gen-ruby_spec.rb
428
- - spec/data/data.bin
429
- - spec/data/types.bin
430
- - spec/encoding/all_types_spec.rb
431
- - spec/encoding/extreme_values_spec.rb
432
- - spec/functional/socket_server_spec.rb
433
- - spec/functional/zmq_server_spec.rb
434
- - spec/lib/protobuf/cli_spec.rb
435
- - spec/lib/protobuf/code_generator_spec.rb
436
- - spec/lib/protobuf/enum_spec.rb
437
- - spec/lib/protobuf/field/float_field_spec.rb
438
- - spec/lib/protobuf/field/int32_field_spec.rb
439
- - spec/lib/protobuf/field/string_field_spec.rb
440
- - spec/lib/protobuf/field_spec.rb
441
- - spec/lib/protobuf/generators/base_spec.rb
442
- - spec/lib/protobuf/generators/enum_generator_spec.rb
443
- - spec/lib/protobuf/generators/extension_generator_spec.rb
444
- - spec/lib/protobuf/generators/field_generator_spec.rb
445
- - spec/lib/protobuf/generators/file_generator_spec.rb
446
- - spec/lib/protobuf/generators/message_generator_spec.rb
447
- - spec/lib/protobuf/generators/service_generator_spec.rb
448
- - spec/lib/protobuf/lifecycle_spec.rb
449
- - spec/lib/protobuf/message_spec.rb
450
- - spec/lib/protobuf/optionable_spec.rb
451
- - spec/lib/protobuf/rpc/client_spec.rb
452
- - spec/lib/protobuf/rpc/connector_spec.rb
453
- - spec/lib/protobuf/rpc/connectors/base_spec.rb
454
- - spec/lib/protobuf/rpc/connectors/common_spec.rb
455
- - spec/lib/protobuf/rpc/connectors/socket_spec.rb
456
- - spec/lib/protobuf/rpc/connectors/zmq_spec.rb
457
- - spec/lib/protobuf/rpc/middleware/exception_handler_spec.rb
458
- - spec/lib/protobuf/rpc/middleware/logger_spec.rb
459
- - spec/lib/protobuf/rpc/middleware/request_decoder_spec.rb
460
- - spec/lib/protobuf/rpc/middleware/response_encoder_spec.rb
461
- - spec/lib/protobuf/rpc/servers/socket_server_spec.rb
462
- - spec/lib/protobuf/rpc/servers/zmq/server_spec.rb
463
- - spec/lib/protobuf/rpc/servers/zmq/util_spec.rb
464
- - spec/lib/protobuf/rpc/servers/zmq/worker_spec.rb
465
- - spec/lib/protobuf/rpc/service_directory_spec.rb
466
- - spec/lib/protobuf/rpc/service_dispatcher_spec.rb
467
- - spec/lib/protobuf/rpc/service_filters_spec.rb
468
- - spec/lib/protobuf/rpc/service_spec.rb
469
- - spec/lib/protobuf/rpc/stat_spec.rb
470
- - spec/lib/protobuf_spec.rb
471
- - spec/spec_helper.rb
472
- - spec/support/all.rb
473
- - spec/support/packed_field.rb
474
- - spec/support/server.rb
475
- - spec/support/test/all_types.data.bin
476
- - spec/support/test/all_types.data.txt
477
- - spec/support/test/defaults.pb.rb
478
- - spec/support/test/defaults.proto
479
- - spec/support/test/enum.pb.rb
480
- - spec/support/test/enum.proto
481
- - spec/support/test/extended.pb.rb
482
- - spec/support/test/extended.proto
483
- - spec/support/test/extreme_values.data.bin
484
- - spec/support/test/google_unittest.pb.rb
485
- - spec/support/test/google_unittest.proto
486
- - spec/support/test/google_unittest_import.pb.rb
487
- - spec/support/test/google_unittest_import.proto
488
- - spec/support/test/google_unittest_import_public.pb.rb
489
- - spec/support/test/google_unittest_import_public.proto
490
- - spec/support/test/multi_field_extensions.pb.rb
491
- - spec/support/test/multi_field_extensions.proto
492
- - spec/support/test/resource.pb.rb
493
- - spec/support/test/resource.proto
494
- - spec/support/test/resource_service.rb
495
- - spec/support/test_app_file.rb
461
+ test_files: []
496
462
  has_rdoc:
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 7ab4fb52f93dfd58648db2463454e2b73215ec42
4
- data.tar.gz: 32a62725dc2677e231d3ec63cd335fa3b3026316
5
- SHA512:
6
- metadata.gz: 9f32ea8b0ef6e9339d43187648c438343e3643e5577a39b9c19f72fbf5749bbb6c614fdb1f4f53d3979ea3e75b67213d6afb81e1ce9bb6fabcf77e4db2dd6d1f
7
- data.tar.gz: 2fc11caaa7c981e93f2515f8ebf4affc6e8fe9ba41a99314b7f4e005144b055a2c29018856b3652e17c91e187c2f1c44d267053374b8c1c1910079dfc5524878