protobuf 3.7.2 → 3.7.3

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: 79198f130aec8d18aae9ef3a3170e16bd67f4ff3
4
- data.tar.gz: 3c13e8622eea8728f59a9279b37140438ae65d71
3
+ metadata.gz: 5bb5d776c81e8200caad253a8be81e107ce831bb
4
+ data.tar.gz: 9c69a987b14927860a5b4d98a01c588430b6655d
5
5
  SHA512:
6
- metadata.gz: 7931e2b2a6943bd7f0c1e9f2ad5de360e8f127b37a413074a74ae571e70a0ac0331c6a9292918b6ee5836bee3c686a5cc751813a2c851b2824dc244012577d2f
7
- data.tar.gz: 23a58d4a0b01ea80ad10c4c6857834606341f0f4d8d6df3b3ca3f34a920ba393fe55b5b33feb1e3d05ac53bfb1ef742d254ee79e00613bbee3df2daab4afe824
6
+ metadata.gz: 0c3891829c33f48f7526c3c00f2b29e5fd5269c35d635838a036aa844330f391cb98146161b11a0d53334476cbaf337d51c331eb084aa96ed3e504c1d14058e6
7
+ data.tar.gz: 1b073df66474e5689306916be8af7ec260f7a0428c2d6002d07cbb6fd0eb4a071135ebdd60e6fffd836254b7923dbb5abbca06dc479f60e0ad86d0568695b357
@@ -28,7 +28,8 @@ module Protobuf
28
28
  @ping_port_responses ||= ::ThreadSafe::Cache.new
29
29
  end
30
30
 
31
- def self.zmq_context
31
+ def self.zmq_context(reload = false)
32
+ @zmq_contexts = nil if reload
32
33
  @zmq_contexts ||= Hash.new do |hash, key|
33
34
  hash[key] = ZMQ::Context.new
34
35
  end
@@ -88,7 +89,11 @@ module Protobuf
88
89
  # service. The LINGER is set to 0 so we can close immediately in
89
90
  # the event of a timeout
90
91
  def create_socket
92
+ has_reloaded_context = false
93
+ attempt_number = 0
94
+
91
95
  begin
96
+ attempt_number += 1
92
97
  socket = zmq_context.socket(::ZMQ::REQ)
93
98
 
94
99
  if socket # Make sure the context builds the socket
@@ -97,8 +102,16 @@ module Protobuf
97
102
  zmq_error_check(socket.connect(server_uri), :socket_connect)
98
103
  socket = socket_to_available_server(socket) if first_alive_load_balance?
99
104
  end
100
- end while socket.try(:socket).nil?
101
105
 
106
+ if !has_reloaded_context && attempt_number == socket_creation_attempts
107
+ logger.info { sign_message("Reset Context: could not create socket") }
108
+ zmq_context(true) # reload the context
109
+ attempt_number = 0
110
+ has_reloaded_context = true
111
+ end
112
+ end while socket.nil? && attempt_number < socket_creation_attempts
113
+
114
+ raise RequestTimeout, "Cannot create new ZMQ client socket" if socket.nil?
102
115
  socket
103
116
  end
104
117
 
@@ -241,6 +254,10 @@ module Protobuf
241
254
  end
242
255
  end
243
256
 
257
+ def socket_creation_attempts
258
+ @socket_creation_attempts ||= (ENV["PB_ZMQ_CLIENT_SOCKET_CREATION_ATTEMPTS"] || 5).to_i
259
+ end
260
+
244
261
  def socket_to_available_server(socket)
245
262
  check_available_response = ""
246
263
  socket.setsockopt(::ZMQ::RCVTIMEO, check_available_rcv_timeout)
@@ -263,8 +280,8 @@ module Protobuf
263
280
  # If the context does not exist, create it, then register
264
281
  # an exit block to ensure the context is terminated correctly.
265
282
  #
266
- def zmq_context
267
- self.class.zmq_context
283
+ def zmq_context(reload = false)
284
+ self.class.zmq_context(reload)
268
285
  end
269
286
 
270
287
  def zmq_eagain_error_check(return_code, source)
@@ -1,3 +1,3 @@
1
1
  module Protobuf
2
- VERSION = '3.7.2' # rubocop:disable Style/MutableConstant
2
+ VERSION = '3.7.3' # rubocop:disable Style/MutableConstant
3
3
  end
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: 3.7.2
4
+ version: 3.7.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - BJ Neilsen