rsmp 0.5.4 → 0.6.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7d5f4cf2cac16a579cca8eb8e81d84ff60cd94e294bba6caf3c3d450fc71e202
4
- data.tar.gz: c99aade3e55837ee0502e0b3b3e8120ad5f488fcc78b5cdc7d412534012fa72d
3
+ metadata.gz: 99c851e6110d58148d2e4875f65340d6427a3a674908ae95397025bc380491bc
4
+ data.tar.gz: 9aa3d5570819e3b20e84542ee3b6ef6bb5d8a17afae964394f14f7e6eda88e2d
5
5
  SHA512:
6
- metadata.gz: 37ce6e272ccb1265865000d35fb5fb473f426c725786a89b8f7cf52871f40dc82a5f90fb860c7aa5a9662fc1c2554cef31a68e15583d949e19c6732ae4b47289
7
- data.tar.gz: 738d271c31fe5d968c9a24e983ce66758891b46cc3c83bcdce374c20603dd54b68ce47a0d0686b3967b4ffcc45c4830c14535464f8094cdab9d483687d3355c0
6
+ metadata.gz: c54182fe42fd77bc9f23b7a7ea116807d92e8c9c02a62ae91da1460373ec695f390f98ebe6d6dcb8e2c72487f861f0ab12bd947e1271942b7a0fba2916b7dbff
7
+ data.tar.gz: 5510c69befdc20d5091c16709c5d9b70a7a226773aad37b69fe1699c8cc86443b1196c8d348e0996ec5da8b8a94b1b3b3f2db8c0bcbedaa2ac979797d5b2e535
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rsmp (0.5.4)
4
+ rsmp (0.6.1)
5
5
  async (~> 1.29.1)
6
6
  async-io (~> 1.32.1)
7
7
  colorize (~> 0.8.1)
@@ -11,13 +11,13 @@ log:
11
11
  active: true
12
12
  color: true
13
13
  timestamp: true
14
- id: true
15
14
  component: true
16
15
  ip: false
17
16
  port: true
18
- site_id: true
17
+ site_id: 9
18
+ component_id: 3
19
19
  text: true
20
- direction: true
20
+ direction: false
21
21
  level: false
22
22
  debug: true
23
23
  json: true
data/config/tlc.yaml CHANGED
@@ -33,14 +33,14 @@ log:
33
33
  active: true
34
34
  color: true
35
35
  timestamp: true
36
- id: true
37
- component: true
36
+ component_id: true
38
37
  ip: false
39
- site_id: true
38
+ site_id: 9
39
+ component: 3
40
40
  level: false
41
41
  debug: true
42
42
  text: true
43
- direction: true
43
+ direction: false
44
44
  json: true
45
45
  acknowledgements: false
46
46
  watchdogs: false
data/lib/rsmp/archive.rb CHANGED
@@ -21,11 +21,11 @@ module RSMP
21
21
  def self.prepare_item item
22
22
  raise ArgumentError unless item.is_a? Hash
23
23
 
24
- cleaned = item.select { |k,v| [:author,:level,:ip,:port,:site_id,:component_id,:str,:message,:exception].include? k }
24
+ cleaned = item.select { |k,v| [:author,:level,:ip,:port,:site_id,:component,:str,:message,:exception].include? k }
25
25
  cleaned[:timestamp] = Clock.now
26
26
  if item[:message]
27
27
  cleaned[:direction] = item[:message].direction
28
- cleaned[:component_id] = item[:message].attributes['cId']
28
+ cleaned[:component] = item[:message].attributes['cId']
29
29
  end
30
30
 
31
31
  cleaned
@@ -15,8 +15,10 @@ module RSMP
15
15
  return unless settings
16
16
  check_main_component settings
17
17
  settings.each_pair do |type,components_by_type|
18
- components_by_type.each_pair do |id,settings|
19
- @components[id] = build_component(id:id, type:type, settings:settings)
18
+ if components_by_type
19
+ components_by_type.each_pair do |id,settings|
20
+ @components[id] = build_component(id:id, type:type, settings:settings)
21
+ end
20
22
  end
21
23
  end
22
24
  end
data/lib/rsmp/error.rb CHANGED
@@ -41,6 +41,9 @@ module RSMP
41
41
  class TimeoutError < Error
42
42
  end
43
43
 
44
+ class DisonnectError < Error
45
+ end
46
+
44
47
  class ConnectionError < Error
45
48
  end
46
49
 
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'=>true,
27
+ 'direction'=>false,
28
+ 'level'=>false,
29
+ 'id'=>true,
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'=>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
- @muted = {}
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
- unless @settings["id"] == false
160
- length = 4
161
- if item[:message]
162
- parts << Logger.shorten_message_id(item[:message].m_id,length)+' '
163
- else
164
- parts << " "*(length+1)
165
- end
166
- end
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 ConnectionError.new("Connection was closed")
89
+ notify_error DisonnectError.new("Connection was closed")
90
90
  ensure
91
91
  close_socket
92
92
  clear
@@ -7,6 +7,7 @@ module RSMP
7
7
  attr_reader :rsmp_versions, :site_id, :supervisor_settings, :proxies, :logger
8
8
 
9
9
  def initialize options={}
10
+
10
11
  handle_supervisor_settings( options[:supervisor_settings] || {} )
11
12
  super options
12
13
  @proxies = []
data/lib/rsmp/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module RSMP
2
- VERSION = "0.5.4"
2
+ VERSION = "0.6.1"
3
3
  end
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
4
+ version: 0.6.1
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-09 00:00:00.000000000 Z
11
+ date: 2021-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async