rsmp 0.5.2 → 0.5.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/config/supervisor.yaml +3 -2
- data/config/tlc.yaml +4 -3
- data/lib/rsmp/collect/collector.rb +9 -0
- data/lib/rsmp/collect/matcher.rb +7 -0
- data/lib/rsmp/collect/notifier.rb +5 -0
- data/lib/rsmp/logger.rb +70 -47
- data/lib/rsmp/node.rb +4 -0
- data/lib/rsmp/proxy.rb +4 -2
- data/lib/rsmp/version.rb +1 -1
- 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: 22ab99646f7155eb2bd6cd2f39923f499f7fa5b019f63a5124886bc1ef4cbb15
|
4
|
+
data.tar.gz: db75cb477bfe945f799f37108a33550b4251d05b3d1a4f225e962dad16a4c827
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c311032b06dab4f4d0aeb3a1ce61c961b87125546116eba2429bce01f3cdb5bcd0a9bf0bbe037dedb6c0cea2e269926cc180be51823bcddddebe89bde55c273f
|
7
|
+
data.tar.gz: 3121265aa3f49f49131a4afe7fe2479bcad25b2be74bcfaabb89ef8cf485cbae20298a33df456913c5818f160d0fa1e5ce7adf8142cbdac962cd109e8b13fd66
|
data/Gemfile.lock
CHANGED
data/config/supervisor.yaml
CHANGED
data/config/tlc.yaml
CHANGED
@@ -34,13 +34,14 @@ log:
|
|
34
34
|
color: true
|
35
35
|
timestamp: true
|
36
36
|
id: true
|
37
|
-
|
37
|
+
component_id: true
|
38
38
|
ip: false
|
39
|
-
site_id:
|
39
|
+
site_id: 9
|
40
|
+
component_id: 3
|
40
41
|
level: false
|
41
42
|
debug: true
|
42
43
|
text: true
|
43
|
-
direction:
|
44
|
+
direction: false
|
44
45
|
json: true
|
45
46
|
acknowledgements: false
|
46
47
|
watchdogs: false
|
@@ -61,9 +61,18 @@ module RSMP
|
|
61
61
|
str = "#{@title.capitalize} collection"
|
62
62
|
str << " in response to #{options[:m_id]}" if options[:m_id]
|
63
63
|
str << " didn't complete within #{@options[:timeout]}s"
|
64
|
+
reached = progress
|
65
|
+
str << ", reached #{progress[:reached]}/#{progress[:need]}"
|
64
66
|
raise RSMP::TimeoutError.new str
|
65
67
|
end
|
66
68
|
|
69
|
+
# Return progress as collected vs. number requested
|
70
|
+
def progress
|
71
|
+
need = @options[:num]
|
72
|
+
reached = @messages.size
|
73
|
+
{ need: need, got: reached }
|
74
|
+
end
|
75
|
+
|
67
76
|
# Get the collected message.
|
68
77
|
def message
|
69
78
|
@messages.first
|
data/lib/rsmp/collect/matcher.rb
CHANGED
@@ -70,6 +70,13 @@ module RSMP
|
|
70
70
|
@queries.map { |query| query.message }.uniq
|
71
71
|
end
|
72
72
|
|
73
|
+
# Return progress as completes queries vs. total number of queries
|
74
|
+
def progress
|
75
|
+
need = @queries.size
|
76
|
+
reached = @queries.count { |query| query.done? }
|
77
|
+
{ need: need, reached: reached }
|
78
|
+
end
|
79
|
+
|
73
80
|
# Are there queries left to match?
|
74
81
|
def done?
|
75
82
|
@queries.all? { |query| query.done? }
|
@@ -16,12 +16,17 @@ module RSMP
|
|
16
16
|
@notify_queue = []
|
17
17
|
end
|
18
18
|
|
19
|
+
def clear_deferred_notify &block
|
20
|
+
@notify_queue = []
|
21
|
+
end
|
22
|
+
|
19
23
|
def deferred_notify &block
|
20
24
|
was, @defer_notify = @defer_notify, true
|
21
25
|
yield
|
22
26
|
dequeue_notify
|
23
27
|
ensure
|
24
28
|
@defer_notify = was
|
29
|
+
@notify_queue = []
|
25
30
|
end
|
26
31
|
|
27
32
|
def dequeue_notify
|
data/lib/rsmp/logger.rb
CHANGED
@@ -5,33 +5,60 @@ module RSMP
|
|
5
5
|
|
6
6
|
def initialize settings={}
|
7
7
|
defaults = {
|
8
|
-
'prefix'=>nil,
|
9
8
|
'active'=>false,
|
10
9
|
'path'=>nil,
|
11
10
|
'stream'=>nil,
|
12
|
-
'author'=>false,
|
13
11
|
'color'=>true,
|
14
|
-
'site_id'=>true,
|
15
|
-
'component'=>false,
|
16
|
-
'level'=>false,
|
17
|
-
'ip'=>false,
|
18
|
-
'port'=>false,
|
19
|
-
'index'=>false,
|
20
|
-
'timestamp'=>true,
|
21
|
-
'json'=>false,
|
22
12
|
'debug'=>false,
|
23
13
|
'statistics'=>false,
|
24
14
|
'hide_ip_and_port' => false,
|
25
|
-
'acknowledgements' => false
|
15
|
+
'acknowledgements' => false,
|
16
|
+
'json'=>false,
|
17
|
+
'tabs'=>'-',
|
18
|
+
|
19
|
+
'prefix'=>false,
|
20
|
+
'index'=>false,
|
21
|
+
'author'=>false,
|
22
|
+
'timestamp'=>true,
|
23
|
+
'ip'=>false,
|
24
|
+
'port'=>false,
|
25
|
+
'site_id'=>true,
|
26
|
+
'component_id'=>true,
|
27
|
+
'direction'=>false,
|
28
|
+
'level'=>false,
|
29
|
+
'id'=>false,
|
30
|
+
'str'=>true,
|
31
|
+
}
|
32
|
+
|
33
|
+
default_lengths = {
|
34
|
+
'index'=>7,
|
35
|
+
'author'=>13,
|
36
|
+
'timestamp'=>24,
|
37
|
+
'ip'=>22,
|
38
|
+
'port'=>5,
|
39
|
+
'site_id'=>19,
|
40
|
+
'component_id'=>19,
|
41
|
+
'direction'=>4,
|
42
|
+
'level'=>7,
|
43
|
+
'id'=>4,
|
26
44
|
}
|
45
|
+
|
27
46
|
if settings
|
28
47
|
@settings = defaults.merge settings
|
29
48
|
else
|
30
49
|
@settings = defaults
|
31
50
|
end
|
32
51
|
|
33
|
-
|
52
|
+
# copy default length for items that are set to true
|
53
|
+
@settings = @settings.map do |key,value|
|
54
|
+
if value == true && default_lengths[key]
|
55
|
+
[ key, default_lengths[key] ]
|
56
|
+
else
|
57
|
+
[ key, value ]
|
58
|
+
end
|
59
|
+
end.to_h
|
34
60
|
|
61
|
+
@muted = {}
|
35
62
|
setup_output_destination
|
36
63
|
end
|
37
64
|
|
@@ -138,43 +165,39 @@ module RSMP
|
|
138
165
|
end
|
139
166
|
log.join("\n")
|
140
167
|
end
|
141
|
-
|
142
|
-
def build_output item
|
143
|
-
parts = []
|
144
|
-
parts << "#{@settings['prefix']} " if @settings['prefix']
|
145
|
-
parts << item[:index].to_s.ljust(7) if @settings["index"] == true
|
146
|
-
parts << item[:author].to_s.ljust(13) if @settings["author"] == true
|
147
|
-
parts << Clock.to_s(item[:timestamp]).ljust(24) unless @settings["timestamp"] == false
|
148
|
-
parts << item[:ip].to_s.ljust(22) unless @settings["ip"] == false
|
149
|
-
parts << item[:port].to_s.ljust(8) unless @settings["port"] == false
|
150
|
-
parts << item[:site_id].to_s.ljust(13) unless @settings["site_id"] == false
|
151
|
-
parts << item[:component_id].to_s.ljust(18) unless @settings["component"] == false
|
152
|
-
|
153
|
-
directions = {in:"-->",out:"<--"}
|
154
|
-
parts << directions[item[:direction]].to_s.ljust(4) unless @settings["direction"] == false
|
155
|
-
|
156
|
-
parts << item[:level].to_s.capitalize.ljust(7) unless @settings["level"] == false
|
157
168
|
|
169
|
+
def build_part parts, item, key, &block
|
170
|
+
skey = key.to_s
|
171
|
+
return unless @settings[skey]
|
158
172
|
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
parts << item[:str].to_s.strip unless @settings["text"] == false
|
168
|
-
parts << item[:message].json unless @settings["json"] == false || item[:message] == nil
|
169
|
-
|
170
|
-
if item[:exception]
|
171
|
-
parts << "#{item[:exception].class.to_s}\n"
|
172
|
-
parts << item[:exception].backtrace.join("\n")
|
173
|
-
end
|
174
|
-
|
175
|
-
out = parts.join(' ').chomp(' ')
|
176
|
-
out
|
173
|
+
part = item[key]
|
174
|
+
part = yield part if block
|
175
|
+
part = part.to_s
|
176
|
+
part = part.ljust @settings[skey] if @settings[skey].is_a?(Integer)
|
177
|
+
|
178
|
+
# replace the first char with a dash if string is all whitespace
|
179
|
+
part = @settings['tabs'].ljust(part.length) if @settings['tabs'] && part !~ /\S/
|
180
|
+
parts << part
|
177
181
|
end
|
178
182
|
|
183
|
+
def build_output item
|
184
|
+
parts = []
|
185
|
+
build_part( parts, item, :prefix ) { @settings['prefix'] if @settings['prefix'] != false}
|
186
|
+
build_part( parts, item, :index )
|
187
|
+
build_part( parts, item, :author )
|
188
|
+
build_part( parts, item, :timestamp ) { |part| Clock.to_s part }
|
189
|
+
build_part( parts, item, :ip )
|
190
|
+
build_part( parts, item, :port )
|
191
|
+
build_part( parts, item, :site_id )
|
192
|
+
build_part( parts, item, :component_id )
|
193
|
+
build_part( parts, item, :direction ) { |part| {in:"-->",out:"<--"}[part] }
|
194
|
+
build_part( parts, item, :level ) { |part| part.capitalize }
|
195
|
+
build_part( parts, item, :id ) { Logger.shorten_message_id(item[:message].m_id,4) if item[:message] }
|
196
|
+
build_part( parts, item, :str )
|
197
|
+
build_part( parts, item, :json ) { item[:message].json if item[:message] }
|
198
|
+
build_part( parts, item, :exception ) { |e| [e.class,e.backtrace].flatten.join("\n") }
|
199
|
+
|
200
|
+
parts.join(' ').chomp(@settings['tabs']).rstrip
|
201
|
+
end
|
179
202
|
end
|
180
|
-
end
|
203
|
+
end
|
data/lib/rsmp/node.rb
CHANGED
data/lib/rsmp/proxy.rb
CHANGED
@@ -350,7 +350,7 @@ module RSMP
|
|
350
350
|
rescue SchemaError, RSMP::Schemer::Error => e
|
351
351
|
str = "Received invalid #{message.type}, schema errors: #{e.message}"
|
352
352
|
log str, message: message, level: :warning
|
353
|
-
notify_error e.exception(
|
353
|
+
notify_error e.exception(str), message: message
|
354
354
|
dont_acknowledge message, str
|
355
355
|
message
|
356
356
|
rescue InvalidMessage => e
|
@@ -360,10 +360,12 @@ module RSMP
|
|
360
360
|
message
|
361
361
|
rescue FatalError => e
|
362
362
|
str = "Rejected #{message.type},"
|
363
|
-
notify_error e.exception(
|
363
|
+
notify_error e.exception(str), message: message
|
364
364
|
dont_acknowledge message, str, "#{e.message}"
|
365
365
|
stop
|
366
366
|
message
|
367
|
+
ensure
|
368
|
+
node.clear_deferred
|
367
369
|
end
|
368
370
|
|
369
371
|
def process_message message
|
data/lib/rsmp/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rsmp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Emil Tin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-11-
|
11
|
+
date: 2021-11-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: async
|