rsmp 0.5.3 → 0.6.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/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 +1 -0
- data/lib/rsmp/error.rb +3 -0
- data/lib/rsmp/logger.rb +70 -47
- data/lib/rsmp/node.rb +9 -0
- data/lib/rsmp/proxy.rb +3 -4
- 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: d4e37b5be3866a109446020e5c6eafcd6f42d459e4c4a49e740804dd8523a9f3
|
|
4
|
+
data.tar.gz: 60487c581cbf0e89d00e66398a80ba7c9fdf080d4f69d7fd9e1db5166f0190fd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 51d7732d473f79779250ea80bbb62cf0bf47cce700a69954bf162241c8ee271a27308600f6dc10c1016c644b109f27e3a9a0f5c91728cc69f096f550c3c896c9
|
|
7
|
+
data.tar.gz: fe7d9db2ced99c524673114d8f0f128821e127400474ac28e91054a83a1777e5340ab79bb48339c799ac78039482e5e06d19ea9f31ea6ff49d0dc5605556caed
|
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? }
|
data/lib/rsmp/error.rb
CHANGED
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
|
@@ -14,9 +14,18 @@ module RSMP
|
|
|
14
14
|
@deferred = []
|
|
15
15
|
@clock = Clock.new
|
|
16
16
|
@error_queue = Async::Queue.new
|
|
17
|
+
@ignore_errors = []
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def ignore_errors classes, &block
|
|
21
|
+
was, @ignore_errors = @ignore_errors, [classes].flatten
|
|
22
|
+
yield
|
|
23
|
+
ensure
|
|
24
|
+
@ignore_errors = was
|
|
17
25
|
end
|
|
18
26
|
|
|
19
27
|
def notify_error e, options={}
|
|
28
|
+
return if @ignore_errors.find { |klass| e.is_a? klass }
|
|
20
29
|
if options[:level] == :internal
|
|
21
30
|
log ["#{e.to_s} in task: #{Async::Task.current.to_s}",e.backtrace].flatten.join("\n"), level: :error
|
|
22
31
|
end
|
data/lib/rsmp/proxy.rb
CHANGED
|
@@ -86,7 +86,7 @@ module RSMP
|
|
|
86
86
|
return if @state == :stopped
|
|
87
87
|
set_state :stopping
|
|
88
88
|
stop_tasks
|
|
89
|
-
notify_error
|
|
89
|
+
notify_error DisonnectError.new("Connection was closed")
|
|
90
90
|
ensure
|
|
91
91
|
close_socket
|
|
92
92
|
clear
|
|
@@ -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,12 +360,11 @@ 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
367
|
ensure
|
|
368
|
-
clear_deferred_notify
|
|
369
368
|
node.clear_deferred
|
|
370
369
|
end
|
|
371
370
|
|
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.
|
|
4
|
+
version: 0.6.0
|
|
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
|