protobuf 3.3.3 → 3.3.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -75,10 +75,7 @@ module Protobuf
75
75
 
76
76
  if socket # Make sure the context builds the socket
77
77
  socket.setsockopt(::ZMQ::LINGER, 0)
78
-
79
- logger.debug { sign_message("Establishing connection: #{server_uri}") }
80
78
  zmq_error_check(socket.connect(server_uri), :socket_connect)
81
- logger.debug { sign_message("Connection established to #{server_uri}") }
82
79
 
83
80
  if first_alive_load_balance?
84
81
  begin
@@ -110,7 +107,7 @@ module Protobuf
110
107
  # to the host and port in the options
111
108
  #
112
109
  def lookup_server_uri
113
- 15.times do
110
+ server_lookup_attempts.times do
114
111
  service_directory.all_listings_for(service).each do |listing|
115
112
  host = listing.try(:address)
116
113
  port = listing.try(:port)
@@ -121,7 +118,7 @@ module Protobuf
121
118
  port = options[:port]
122
119
  return "tcp://#{host}:#{port}" if host_alive?(host)
123
120
 
124
- sleep (5.0/100.0)
121
+ sleep (1.0/100.0)
125
122
  end
126
123
 
127
124
  raise "Host not found for service #{service}"
@@ -131,7 +128,7 @@ module Protobuf
131
128
  return true unless ping_port_enabled?
132
129
 
133
130
  if (last_response = self.class.ping_port_responses[host])
134
- if (Time.now.to_i - last_response[:at]) <= 2
131
+ if (Time.now.to_i - last_response[:at]) <= host_alive_check_interval
135
132
  return last_response[:ping_port_open]
136
133
  end
137
134
  end
@@ -144,6 +141,10 @@ module Protobuf
144
141
  ping_port_open
145
142
  end
146
143
 
144
+ def host_alive_check_interval
145
+ @host_alive_check_interval ||= [ENV["PB_ZMQ_CLIENT_HOST_ALIVE_CHECK_INTERVAL"].to_i, 1].max
146
+ end
147
+
147
148
  def ping_port_open?(host)
148
149
  socket = TCPSocket.new(host, ping_port.to_i)
149
150
  socket.setsockopt(::Socket::IPPROTO_TCP, ::Socket::TCP_NODELAY, 1)
@@ -197,6 +198,10 @@ module Protobuf
197
198
  logger.debug { sign_message("Socket closed") }
198
199
  end
199
200
 
201
+ def server_lookup_attempts
202
+ @server_lookup_attempts ||= [ENV["PB_ZMQ_CLIENT_SERVER_LOOKUP_ATTEMPTS"].to_i, 5].max
203
+ end
204
+
200
205
  # The service we're attempting to connect to
201
206
  #
202
207
  def service
@@ -33,9 +33,9 @@ module Protobuf
33
33
  # Something went wrong
34
34
  break if rc == -1
35
35
 
36
- process_backend if @poller.readables.include?(@backend_socket)
36
+ check_and_process_backend
37
37
  process_local_queue # Fair ordering so queued requests get in before new requests
38
- process_frontend if @poller.readables.include?(@frontend_socket)
38
+ check_and_process_frontend
39
39
  end
40
40
  ensure
41
41
  teardown
@@ -47,6 +47,39 @@ module Protobuf
47
47
 
48
48
  private
49
49
 
50
+ def backend_poll_weight
51
+ @backend_poll_weight ||= [ENV["PB_ZMQ_SERVER_BACKEND_POLL_WEIGHT"].to_i, 1].max
52
+ end
53
+
54
+ def check_and_process_backend
55
+ readables_include_backend = @poller.readables.include?(@backend_socket)
56
+ message_count_read_from_backend = 0
57
+
58
+ while readables_include_backend && message_count_read_from_backend < backend_poll_weight do
59
+ message_count_read_from_backend += 1
60
+ process_backend
61
+ @poller.poll_nonblock
62
+ readables_include_backend = @poller.readables.include?(@backend_socket)
63
+ end
64
+ end
65
+
66
+ def check_and_process_frontend
67
+ readables_include_frontend = @poller.readables.include?(@frontend_socket)
68
+ message_count_read_from_frontend = 0
69
+
70
+ while readables_include_frontend && message_count_read_from_frontend < frontend_poll_weight do
71
+ message_count_read_from_frontend += 1
72
+ process_frontend
73
+ break unless local_queue_available? # no need to read frontend just to throw away messages, will prioritize backend when full
74
+ @poller.poll_nonblock
75
+ readables_include_frontend = @poller.readables.include?(@frontend_socket)
76
+ end
77
+ end
78
+
79
+ def frontend_poll_weight
80
+ @frontend_poll_weight ||= [ENV["PB_ZMQ_SERVER_FRONTEND_POLL_WEIGHT"].to_i, 1].max
81
+ end
82
+
50
83
  def init_backend_socket
51
84
  @backend_socket = @zmq_context.socket(ZMQ::ROUTER)
52
85
  zmq_error_check(@backend_socket.bind(@server.backend_uri))
@@ -79,6 +112,10 @@ module Protobuf
79
112
  !!@server.try(:inproc?)
80
113
  end
81
114
 
115
+ def local_queue_available?
116
+ local_queue.size < local_queue_max_size
117
+ end
118
+
82
119
  def local_queue_max_size
83
120
  @local_queue_max_size ||= [ENV["PB_ZMQ_SERVER_QUEUE_MAX_SIZE"].to_i, 5].max
84
121
  end
@@ -97,7 +134,7 @@ module Protobuf
97
134
  address, _, message, *frames = read_from_frontend
98
135
 
99
136
  if message == ::Protobuf::Rpc::Zmq::CHECK_AVAILABLE_MESSAGE
100
- if local_queue.size < local_queue_max_size
137
+ if local_queue_available?
101
138
  write_to_frontend([address, ::Protobuf::Rpc::Zmq::EMPTY_STRING, ::Protobuf::Rpc::Zmq::WORKERS_AVAILABLE])
102
139
  else
103
140
  write_to_frontend([address, ::Protobuf::Rpc::Zmq::EMPTY_STRING, ::Protobuf::Rpc::Zmq::NO_WORKERS_AVAILABLE])
@@ -1,3 +1,3 @@
1
1
  module Protobuf
2
- VERSION = '3.3.3'
2
+ VERSION = '3.3.4'
3
3
  end
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.3.3
4
+ version: 3.3.4
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - BJ Neilsen
@@ -11,174 +12,198 @@ authors:
11
12
  autorequire:
12
13
  bindir: bin
13
14
  cert_chain: []
14
- date: 2014-09-13 00:00:00.000000000 Z
15
+ date: 2014-09-15 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: pry-nav
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: rake
102
115
  requirement: !ruby/object:Gem::Requirement
116
+ none: false
103
117
  requirements:
104
- - - ">="
118
+ - - ! '>='
105
119
  - !ruby/object:Gem::Version
106
120
  version: '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: '0'
114
129
  - !ruby/object:Gem::Dependency
115
130
  name: rspec
116
131
  requirement: !ruby/object:Gem::Requirement
132
+ none: false
117
133
  requirements:
118
- - - ">="
134
+ - - ! '>='
119
135
  - !ruby/object:Gem::Version
120
136
  version: '3.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: '3.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: yard
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: timecop
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
194
  name: perftools.rb
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
  description: Google Protocol Buffers serialization and RPC implementation for Ruby.
@@ -193,9 +218,9 @@ executables:
193
218
  extensions: []
194
219
  extra_rdoc_files: []
195
220
  files:
196
- - ".gitignore"
197
- - ".travis.yml"
198
- - ".yardopts"
221
+ - .gitignore
222
+ - .travis.yml
223
+ - .yardopts
199
224
  - CHANGES.md
200
225
  - CONTRIBUTING.md
201
226
  - Gemfile
@@ -370,26 +395,33 @@ files:
370
395
  homepage: https://github.com/localshred/protobuf
371
396
  licenses:
372
397
  - MIT
373
- metadata: {}
374
398
  post_install_message:
375
399
  rdoc_options: []
376
400
  require_paths:
377
401
  - lib
378
402
  required_ruby_version: !ruby/object:Gem::Requirement
403
+ none: false
379
404
  requirements:
380
- - - ">="
405
+ - - ! '>='
381
406
  - !ruby/object:Gem::Version
382
407
  version: '0'
408
+ segments:
409
+ - 0
410
+ hash: 3745042984186986363
383
411
  required_rubygems_version: !ruby/object:Gem::Requirement
412
+ none: false
384
413
  requirements:
385
- - - ">="
414
+ - - ! '>='
386
415
  - !ruby/object:Gem::Version
387
416
  version: '0'
417
+ segments:
418
+ - 0
419
+ hash: 3745042984186986363
388
420
  requirements: []
389
421
  rubyforge_project:
390
- rubygems_version: 2.2.2
422
+ rubygems_version: 1.8.24
391
423
  signing_key:
392
- specification_version: 4
424
+ specification_version: 3
393
425
  summary: Google Protocol Buffers serialization and RPC implementation for Ruby.
394
426
  test_files: []
395
427
  has_rdoc:
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: fe61fc4d47ed6c201b9236f073587ef838d0c02f
4
- data.tar.gz: 39e557ae7adcad48d9ba1f21612b8cc233845b61
5
- SHA512:
6
- metadata.gz: b4720d9276e63dc31920f46eab1753aa57eaae8680c5745976866a8424541ab010fc9c3e1ac128b49ee8681bc71ff23b5869e0ef3d0d5c7234a3408688eb5fd0
7
- data.tar.gz: cfd4db44b90c1dc3b2ae9dad0d2b303e00123ece4618534c13a1d1a90f078cb3003340073ee5ee7546d70de4701148de2a4b6416e551df3d93f85c7439d574fa