protobuf 3.7.2 → 3.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/protobuf/rpc/connectors/zmq.rb +21 -4
- data/lib/protobuf/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5bb5d776c81e8200caad253a8be81e107ce831bb
|
4
|
+
data.tar.gz: 9c69a987b14927860a5b4d98a01c588430b6655d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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)
|
data/lib/protobuf/version.rb
CHANGED