rsmp 0.1.35 → 0.1.40

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b70cfe0846c716ed0e04af05ee6d44dafc76fdacf6bd56c2abd5c5f60b5a49d3
4
- data.tar.gz: 0b7c1e7e2277db224bfc5be53bc587c8f1252f76730a49356e5268a437d34241
3
+ metadata.gz: d1feaa7fd1863a9783573d2f8c2c025f06ba53de97a441bd7f8b5da164c813cd
4
+ data.tar.gz: e34aea14d3949b54d9ed9db3dcc8495cf3d5db8761f77e74b6c162bcf86468d6
5
5
  SHA512:
6
- metadata.gz: 5364ebe4f16562e35533e3d9992674a1d1a6bd0aeb9b2432c6b5da445bab99356691dbee8ab67d63571233f86fd7702e8b5252d1e58f48370120b5190a3fe204
7
- data.tar.gz: 28d03ee56aee3bd68c21f52ca780eb1ee58ea58af669deb140024d3fbd2387fd1124c2db1dc02ee33384bb3b40ecda26a6f57827c268d8799f4ae419edbcf364
6
+ metadata.gz: 7da97ae66c060644d623f49dc7b8702110ce54a6fd4bfadac56cc74945430612a7a8c5269e98174a17aeedfd83a7551b3eecc9e151f5aea1cff53a88eb43c5c5
7
+ data.tar.gz: 4d51c29847821378a1e34f2e34f6f5fe779053c18022927ac3041f51b235db55303f45658f7f10ea017f9021bbf1665ebe8383e491e0f9b98017f1c8da7a4dca
data/Gemfile.lock CHANGED
@@ -1,11 +1,11 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rsmp (0.1.35)
4
+ rsmp (0.1.40)
5
5
  async (~> 1.28.7)
6
6
  async-io (~> 1.30.2)
7
7
  colorize (~> 0.8.1)
8
- rsmp_schemer (~> 0.2.0)
8
+ rsmp_schemer
9
9
  thor (~> 1.0.1)
10
10
 
11
11
  GEM
@@ -64,7 +64,7 @@ GEM
64
64
  nio4r (2.5.7)
65
65
  rake (13.0.1)
66
66
  regexp_parser (2.1.1)
67
- rsmp_schemer (0.2.1)
67
+ rsmp_schemer (0.3.1)
68
68
  json_schemer (~> 0.2.18)
69
69
  rspec (3.9.0)
70
70
  rspec-core (~> 3.9.0)
@@ -45,9 +45,11 @@ module RSMP
45
45
  @options[:timeout] = options[:timeout] if options[:timeout]
46
46
  @block = block
47
47
 
48
- listen do
49
- task.with_timeout(@options[:timeout]) do
50
- @condition.wait
48
+ unless @done
49
+ listen do
50
+ task.with_timeout(@options[:timeout]) do
51
+ @condition.wait
52
+ end
51
53
  end
52
54
  end
53
55
 
data/lib/rsmp/logger.rb CHANGED
@@ -7,6 +7,7 @@ module RSMP
7
7
  defaults = {
8
8
  'active'=>false,
9
9
  'path'=>nil,
10
+ 'stream'=>nil,
10
11
  'author'=>false,
11
12
  'color'=>true,
12
13
  'site_id'=>true,
@@ -33,7 +34,9 @@ module RSMP
33
34
  end
34
35
 
35
36
  def setup_output_destination
36
- if @settings['path']
37
+ if @settings['stream']
38
+ @stream = @settings['stream']
39
+ elsif @settings['path']
37
40
  @stream = File.open(@settings['path'],'a') # appending
38
41
  else
39
42
  @stream = $stdout
@@ -85,20 +88,19 @@ module RSMP
85
88
  def colorize level, str
86
89
  if @settings["color"] == false || @settings["color"] == nil
87
90
  str
88
- elsif @settings["color"] == true
89
- case level
90
- when :error
91
- str.colorize(:red)
92
- when :warning
93
- str.colorize(:light_yellow)
94
- when :not_acknowledged
95
- str.colorize(:cyan)
96
- when :log
97
- str.colorize(:light_blue)
98
- when :statistics
99
- str.colorize(:light_black)
100
- when :test
101
- str.colorize(:light_magenta)
91
+ elsif @settings["color"] == true || @settings["color"].is_a?(Hash)
92
+ colors = {
93
+ 'info' => 'white',
94
+ 'log' => 'light_blue',
95
+ 'test' => 'light_magenta',
96
+ 'statistics' => 'light_black',
97
+ 'not_acknowledged' => 'cyan',
98
+ 'warning' => 'light_yellow',
99
+ 'error' => 'red'
100
+ }
101
+ colors.merge! @settings["color"] if @settings["color"].is_a?(Hash)
102
+ if colors[level.to_s]
103
+ str.colorize colors[level.to_s].to_sym
102
104
  else
103
105
  str
104
106
  end
@@ -111,7 +113,7 @@ module RSMP
111
113
  end
112
114
  end
113
115
 
114
- def log item, force:false
116
+ def log item, force:false
115
117
  if output?(item, force)
116
118
  output item[:level], build_output(item)
117
119
  end
data/lib/rsmp/proxy.rb CHANGED
@@ -162,6 +162,8 @@ module RSMP
162
162
  begin
163
163
  now = Clock.now
164
164
  timer(now)
165
+ rescue RSMP::Schemer::Error => e
166
+ puts "Timer: Schema error: #{e}"
165
167
  rescue EOFError => e
166
168
  log "Timer: Connection closed: #{e}", level: :warning
167
169
  rescue IOError => e
@@ -246,7 +248,7 @@ module RSMP
246
248
  # TODO
247
249
  # what schema should we use to validate the intial Version and MessageAck messages?
248
250
  schemas = { core: '3.1.5' }
249
- schemas[sxl] = sxl_version if sxl
251
+ schemas[sxl] = RSMP::Schemer.sanitize_version(sxl_version) if sxl
250
252
  schemas
251
253
  end
252
254
 
@@ -261,7 +263,7 @@ module RSMP
261
263
  log_send message, reason
262
264
  rescue EOFError, IOError
263
265
  buffer_message message
264
- rescue SchemaError => e
266
+ rescue SchemaError, RSMP::Schemer::Error => e
265
267
  str = "Could not send #{message.type} because schema validation failed: #{e.message}"
266
268
  log str, message: message, level: :error
267
269
  notify_error e.exception("#{str} #{message.json}")
@@ -306,7 +308,7 @@ module RSMP
306
308
  log str, message: Malformed.new(attributes), level: :warning
307
309
  # cannot send NotAcknowledged for a malformed message since we can't read it, just ignore it
308
310
  nil
309
- rescue SchemaError => e
311
+ rescue SchemaError, RSMP::Schemer::Error => e
310
312
  str = "Received invalid #{message.type}, schema errors: #{e.message}"
311
313
  log str, message: message, level: :warning
312
314
  notify_error e.exception("#{str} #{message.json}")
data/lib/rsmp/site.rb CHANGED
@@ -53,7 +53,7 @@ module RSMP
53
53
  def check_sxl_version
54
54
  sxl = @site_settings['sxl']
55
55
  version = @site_settings['sxl_version']
56
- RSMP::Schemer::find_schema! sxl, version
56
+ RSMP::Schemer::find_schema! sxl, version, lenient: true
57
57
  end
58
58
 
59
59
  def reconnect
@@ -36,7 +36,8 @@ module RSMP
36
36
 
37
37
  def connection_complete
38
38
  super
39
- log "Connection to site #{@site_id} established, using core #{@rsmp_version}, #{@sxl} #{@site_sxl_version}", level: :info
39
+ sanitized_sxl_version = RSMP::Schemer.sanitize_version(@site_sxl_version)
40
+ log "Connection to site #{@site_id} established, using core #{@rsmp_version}, #{@sxl} #{sanitized_sxl_version}", level: :info
40
41
  end
41
42
 
42
43
  def process_message message
@@ -308,11 +309,13 @@ module RSMP
308
309
  # comes from the Version message send by the site
309
310
  type = 'tlc'
310
311
  version = message.attribute 'SXL'
311
- RSMP::Schemer::find_schema! type, version
312
+ RSMP::Schemer::find_schema! type, version, lenient: true
312
313
 
313
314
  # store sxl version requested by site
314
315
  # TODO should check agaist site settings
315
316
  @site_sxl_version = message.attribute 'SXL'
317
+ rescue RSMP::Schemer::UnknownSchemaError => e
318
+ dont_acknowledge message, "Rejected #{message.type} message,", "#{e}"
316
319
  end
317
320
 
318
321
  def sxl_version
@@ -327,8 +330,6 @@ module RSMP
327
330
  check_rsmp_version message
328
331
  check_sxl_version message
329
332
  version_accepted message
330
- rescue RSMP::Schemer::UnknownSchemaError => e
331
- dont_acknowledge message, "Rejected #{message.type} message,", "#{e}"
332
333
  end
333
334
 
334
335
  def check_site_ids message
@@ -49,7 +49,6 @@ module RSMP
49
49
  raise RSMP::ConfigurationError.new("Configuration for site '#{site_id}' is empty")
50
50
  end
51
51
  sxl = settings['sxl']
52
- sxl = 'tlc' unless sxl # temporary fix until configs are updated
53
52
  unless sxl
54
53
  raise RSMP::ConfigurationError.new("Configuration error for site '#{site_id}': No SXL specified")
55
54
  end
@@ -54,7 +54,8 @@ module RSMP
54
54
 
55
55
  def connection_complete
56
56
  super
57
- log "Connection to supervisor established, using core #{@rsmp_version}, #{sxl} #{sxl_version}", level: :info
57
+ sanitized_sxl_version = RSMP::Schemer.sanitize_version(sxl_version)
58
+ log "Connection to supervisor established, using core #{@rsmp_version}, #{sxl} #{sanitized_sxl_version}", level: :info
58
59
  start_watchdog
59
60
  end
60
61
 
data/lib/rsmp/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module RSMP
2
- VERSION = "0.1.35"
2
+ VERSION = "0.1.40"
3
3
  end
data/rsmp.gemspec CHANGED
@@ -34,7 +34,7 @@ Gem::Specification.new do |spec|
34
34
  spec.add_dependency "async-io", "~> 1.30.2"
35
35
  spec.add_dependency "colorize", "~> 0.8.1"
36
36
  spec.add_dependency "thor", "~> 1.0.1"
37
- spec.add_dependency "rsmp_schemer", "~> 0.2.0"
37
+ spec.add_dependency "rsmp_schemer"
38
38
 
39
39
  spec.add_development_dependency "bundler", "~> 2.2.3"
40
40
  spec.add_development_dependency "rake", "~> 13.0.1"
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.1.35
4
+ version: 0.1.40
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-06-17 00:00:00.000000000 Z
11
+ date: 2021-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async
@@ -70,16 +70,16 @@ dependencies:
70
70
  name: rsmp_schemer
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: 0.2.0
75
+ version: '0'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
- version: 0.2.0
82
+ version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: bundler
85
85
  requirement: !ruby/object:Gem::Requirement