logjam_agent 0.31.0 → 0.32.0
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/logjam_agent/version.rb +1 -1
- data/lib/logjam_agent/zmq_forwarder.rb +40 -32
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df4bc6a68ce75215afa172d8247bffc2fd1192651e2410e26d4c298500bf4934
|
4
|
+
data.tar.gz: 54067782beccfe222468f27d1062d4c8cf65f9dd7e4fd94abaa24e2f3eaa46fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2eec84c0f349756469546bb35d0ae047585149e9c11429daad6701d98a4d104c9ab4161aa342be12790fd9eb46a4ee47c766a7e8cd3930388e584b31317ecf90
|
7
|
+
data.tar.gz: 941264e9a1eeeedf6a44748d02e8fb825c59402e28fb66244f3ff9b1045dfa097d5763503ad23b8ff53398560684a576462f1084343b9f2d539e9b37ff9c3386
|
data/lib/logjam_agent/version.rb
CHANGED
@@ -16,6 +16,7 @@ module LogjamAgent
|
|
16
16
|
@sequence = SEQUENCE_START
|
17
17
|
@socket = nil
|
18
18
|
@ping_ensured = false
|
19
|
+
@socket_mutex = Mutex.new
|
19
20
|
end
|
20
21
|
|
21
22
|
def connection_specs
|
@@ -35,11 +36,11 @@ module LogjamAgent
|
|
35
36
|
}
|
36
37
|
end
|
37
38
|
|
38
|
-
@@
|
39
|
+
@@context_mutex = Mutex.new
|
39
40
|
@@zmq_context = nil
|
40
41
|
|
41
42
|
def self.context
|
42
|
-
@@
|
43
|
+
@@context_mutex.synchronize do
|
43
44
|
@@zmq_context ||=
|
44
45
|
begin
|
45
46
|
require 'ffi-rzmq'
|
@@ -50,29 +51,12 @@ module LogjamAgent
|
|
50
51
|
end
|
51
52
|
end
|
52
53
|
|
53
|
-
def socket
|
54
|
-
return @socket if @socket
|
55
|
-
@socket = self.class.context.socket(ZMQ::DEALER)
|
56
|
-
raise "ZMQ error on socket creation: #{ZMQ::Util.error_string}" if @socket.nil?
|
57
|
-
if LogjamAgent.ensure_ping_at_exit
|
58
|
-
ensure_ping_at_exit
|
59
|
-
else
|
60
|
-
at_exit { reset }
|
61
|
-
end
|
62
|
-
@socket.setsockopt(ZMQ::LINGER, @config[:linger])
|
63
|
-
@socket.setsockopt(ZMQ::SNDHWM, @config[:snd_hwm])
|
64
|
-
@socket.setsockopt(ZMQ::RCVHWM, @config[:rcv_hwm])
|
65
|
-
@socket.setsockopt(ZMQ::RCVTIMEO, @config[:rcv_timeo])
|
66
|
-
@socket.setsockopt(ZMQ::SNDTIMEO, @config[:snd_timeo])
|
67
|
-
spec = connection_specs.sort_by{rand}.first
|
68
|
-
@socket.connect(spec)
|
69
|
-
@socket
|
70
|
-
end
|
71
|
-
|
72
54
|
def reset
|
73
|
-
|
74
|
-
@socket
|
75
|
-
|
55
|
+
@socket_mutex.synchronize do
|
56
|
+
if @socket
|
57
|
+
@socket.close
|
58
|
+
@socket = nil
|
59
|
+
end
|
76
60
|
end
|
77
61
|
end
|
78
62
|
|
@@ -89,16 +73,40 @@ module LogjamAgent
|
|
89
73
|
key += ".#{engine}"
|
90
74
|
end
|
91
75
|
msg = LogjamAgent.encode_payload(data)
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
76
|
+
@socket_mutex.synchronize do
|
77
|
+
if options[:sync]
|
78
|
+
send_receive(app_env, key, msg)
|
79
|
+
else
|
80
|
+
publish(app_env, key, msg)
|
81
|
+
end
|
96
82
|
end
|
97
83
|
rescue => error
|
98
84
|
reraise_expectation_errors!
|
99
85
|
raise ForwardingError.new(error.message)
|
100
86
|
end
|
101
87
|
|
88
|
+
private
|
89
|
+
|
90
|
+
# this method assumes the caller holds the socket mutex
|
91
|
+
def socket
|
92
|
+
return @socket if @socket
|
93
|
+
@socket = self.class.context.socket(ZMQ::DEALER)
|
94
|
+
raise "ZMQ error on socket creation: #{ZMQ::Util.error_string}" if @socket.nil?
|
95
|
+
if LogjamAgent.ensure_ping_at_exit
|
96
|
+
ensure_ping_at_exit
|
97
|
+
else
|
98
|
+
at_exit { reset }
|
99
|
+
end
|
100
|
+
@socket.setsockopt(ZMQ::LINGER, @config[:linger])
|
101
|
+
@socket.setsockopt(ZMQ::SNDHWM, @config[:snd_hwm])
|
102
|
+
@socket.setsockopt(ZMQ::RCVHWM, @config[:rcv_hwm])
|
103
|
+
@socket.setsockopt(ZMQ::RCVTIMEO, @config[:rcv_timeo])
|
104
|
+
@socket.setsockopt(ZMQ::SNDTIMEO, @config[:snd_timeo])
|
105
|
+
spec = connection_specs.sort_by{rand}.first
|
106
|
+
@socket.connect(spec)
|
107
|
+
@socket
|
108
|
+
end
|
109
|
+
|
102
110
|
def publish(app_env, key, data)
|
103
111
|
info = pack_info(@sequence = next_fixnum(@sequence))
|
104
112
|
parts = [app_env, key, data, info]
|
@@ -109,8 +117,6 @@ module LogjamAgent
|
|
109
117
|
end
|
110
118
|
end
|
111
119
|
|
112
|
-
private
|
113
|
-
|
114
120
|
def log_warning(message)
|
115
121
|
LogjamAgent.error_handler.call ForwardingWarning.new(message)
|
116
122
|
end
|
@@ -138,8 +144,10 @@ module LogjamAgent
|
|
138
144
|
end
|
139
145
|
|
140
146
|
def ping
|
141
|
-
|
142
|
-
|
147
|
+
@socket_mutex.synchronize do
|
148
|
+
if @socket && !send_receive("ping", @app_env, "{}", NO_COMPRESSION)
|
149
|
+
log_warning "failed to receive pong"
|
150
|
+
end
|
143
151
|
end
|
144
152
|
end
|
145
153
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logjam_agent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.32.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefan Kaes
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-08-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|