rsmp 0.1.21 → 0.1.32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitmodules +0 -4
- data/Gemfile.lock +13 -11
- data/config/supervisor.yaml +9 -15
- data/config/tlc.yaml +9 -8
- data/documentation/message_distribution.md +8 -8
- data/lib/rsmp.rb +5 -0
- data/lib/rsmp/archive.rb +7 -4
- data/lib/rsmp/cli.rb +133 -102
- data/lib/rsmp/collector.rb +42 -30
- data/lib/rsmp/component.rb +2 -0
- data/lib/rsmp/components.rb +1 -1
- data/lib/rsmp/convert/export/json_schema.rb +204 -0
- data/lib/rsmp/convert/import/yaml.rb +38 -0
- data/lib/rsmp/deep_merge.rb +11 -0
- data/lib/rsmp/inspect.rb +46 -0
- data/lib/rsmp/listener.rb +4 -14
- data/lib/rsmp/logger.rb +3 -1
- data/lib/rsmp/logging.rb +1 -1
- data/lib/rsmp/message.rb +22 -31
- data/lib/rsmp/node.rb +11 -1
- data/lib/rsmp/notifier.rb +7 -2
- data/lib/rsmp/proxy.rb +95 -39
- data/lib/rsmp/rsmp.rb +34 -23
- data/lib/rsmp/site.rb +30 -32
- data/lib/rsmp/site_proxy.rb +103 -22
- data/lib/rsmp/site_proxy_wait.rb +63 -38
- data/lib/rsmp/supervisor.rb +82 -47
- data/lib/rsmp/supervisor_proxy.rb +21 -13
- data/lib/rsmp/tlc.rb +61 -35
- data/lib/rsmp/version.rb +1 -1
- data/rsmp.gemspec +3 -14
- metadata +13 -113
- data/config/site.yaml +0 -40
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7992be63350c61210d51f99a820314c3e8d9d7020e5e08e5000d2fb4a054e96e
|
4
|
+
data.tar.gz: b2b0d397391912c748fe6f1a9b7ea1896e17affaead760ac58b1df8b00355164
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fce26ff77f208cfe072a0f672a66e75e64d7e73fa7fe61ca28604df64a4c1039cc566340338d5734b745bfadf7fdfc9b34ed6e444a78984e97a1e009f07e68c3
|
7
|
+
data.tar.gz: 698e829317c201896b52ac2a3f2c2c9258d947a64b2cf3b6f3dbc82fff987881c65603d3966437b4b699d6962cf1d38d30da1b31b3d09e2c24fa19519aa2cfbc
|
data/.gitmodules
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rsmp (0.1.
|
5
|
-
async (~> 1.28.
|
6
|
-
async-io (~> 1.30.
|
4
|
+
rsmp (0.1.32)
|
5
|
+
async (~> 1.28.7)
|
6
|
+
async-io (~> 1.30.2)
|
7
7
|
colorize (~> 0.8.1)
|
8
|
-
|
8
|
+
rsmp_schemer (~> 0.2.0)
|
9
9
|
thor (~> 1.0.1)
|
10
10
|
|
11
11
|
GEM
|
@@ -18,17 +18,17 @@ GEM
|
|
18
18
|
ffi (~> 1.9)
|
19
19
|
rspec-expectations (~> 3.4)
|
20
20
|
thor (~> 1.0)
|
21
|
-
async (1.28.
|
21
|
+
async (1.28.9)
|
22
22
|
console (~> 1.10)
|
23
23
|
nio4r (~> 2.3)
|
24
24
|
timers (~> 4.1)
|
25
|
-
async-io (1.30.
|
25
|
+
async-io (1.30.2)
|
26
26
|
async (~> 1.14)
|
27
27
|
backports (3.17.0)
|
28
28
|
builder (3.2.4)
|
29
29
|
childprocess (3.0.0)
|
30
30
|
colorize (0.8.1)
|
31
|
-
console (1.
|
31
|
+
console (1.12.0)
|
32
32
|
fiber-local
|
33
33
|
contracts (0.16.0)
|
34
34
|
cucumber (3.1.2)
|
@@ -54,16 +54,18 @@ GEM
|
|
54
54
|
fiber-local (1.0.0)
|
55
55
|
gherkin (5.1.0)
|
56
56
|
hana (1.3.7)
|
57
|
-
json_schemer (0.2.
|
57
|
+
json_schemer (0.2.18)
|
58
58
|
ecma-re-validator (~> 0.3)
|
59
59
|
hana (~> 1.3)
|
60
60
|
regexp_parser (~> 2.0)
|
61
61
|
uri_template (~> 0.7)
|
62
62
|
multi_json (1.14.1)
|
63
63
|
multi_test (0.1.2)
|
64
|
-
nio4r (2.5.
|
64
|
+
nio4r (2.5.7)
|
65
65
|
rake (13.0.1)
|
66
|
-
regexp_parser (2.
|
66
|
+
regexp_parser (2.1.1)
|
67
|
+
rsmp_schemer (0.2.0)
|
68
|
+
json_schemer (~> 0.2.18)
|
67
69
|
rspec (3.9.0)
|
68
70
|
rspec-core (~> 3.9.0)
|
69
71
|
rspec-expectations (~> 3.9.0)
|
@@ -79,7 +81,7 @@ GEM
|
|
79
81
|
rspec-support (3.9.2)
|
80
82
|
thor (1.0.1)
|
81
83
|
timecop (0.9.1)
|
82
|
-
timers (4.3.
|
84
|
+
timers (4.3.3)
|
83
85
|
uri_template (0.7.0)
|
84
86
|
|
85
87
|
PLATFORMS
|
data/config/supervisor.yaml
CHANGED
@@ -1,18 +1,12 @@
|
|
1
1
|
port: 12111
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
acknowledgement_timeout: 2
|
11
|
-
store_messages: false
|
12
|
-
command_response_timeout: 1
|
13
|
-
status_response_timeout: 1
|
14
|
-
status_update_timeout: 1
|
15
|
-
|
2
|
+
guest:
|
3
|
+
sxl: tlc
|
4
|
+
intervals:
|
5
|
+
timer: 0.1
|
6
|
+
watchdog: 0.1
|
7
|
+
timeouts:
|
8
|
+
watchdog: 0.2
|
9
|
+
acknowledgement: 0.2
|
16
10
|
log:
|
17
11
|
active: true
|
18
12
|
color: true
|
@@ -20,6 +14,7 @@ log:
|
|
20
14
|
id: true
|
21
15
|
component: true
|
22
16
|
ip: false
|
17
|
+
port: true
|
23
18
|
site_id: true
|
24
19
|
text: true
|
25
20
|
direction: true
|
@@ -27,4 +22,3 @@ log:
|
|
27
22
|
json: true
|
28
23
|
acknowledgements: false
|
29
24
|
watchdogs: false
|
30
|
-
|
data/config/tlc.yaml
CHANGED
@@ -2,7 +2,8 @@ site_id: RN+SI0001
|
|
2
2
|
supervisors:
|
3
3
|
- ip: 127.0.0.1
|
4
4
|
port: 12111
|
5
|
-
|
5
|
+
sxl: tlc
|
6
|
+
sxl_version: 1.0.15
|
6
7
|
components:
|
7
8
|
main:
|
8
9
|
TC:
|
@@ -18,15 +19,16 @@ components:
|
|
18
19
|
plan: 'BBB1NB'
|
19
20
|
detector_logic:
|
20
21
|
DL1:
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
22
|
+
intervals:
|
23
|
+
timer: 0.1
|
24
|
+
watchdog: 0.1
|
25
|
+
reconnect: 0.1
|
26
|
+
timeouts:
|
27
|
+
watchdog: 0.2
|
28
|
+
acknowledgement: 0.2
|
26
29
|
security_codes:
|
27
30
|
1: '1111'
|
28
31
|
2: '2222'
|
29
|
-
|
30
32
|
log:
|
31
33
|
active: true
|
32
34
|
color: true
|
@@ -41,4 +43,3 @@ log:
|
|
41
43
|
json: true
|
42
44
|
acknowledgements: false
|
43
45
|
watchdogs: false
|
44
|
-
|
@@ -1,23 +1,23 @@
|
|
1
1
|
# Message distribution
|
2
2
|
|
3
|
-
Proxy - -
|
3
|
+
Proxy - - Notifier --> Listeners
|
4
4
|
|
5
|
-
A proxy distributes
|
5
|
+
A proxy distributes messages to listeners, when they are installed.
|
6
6
|
|
7
|
-
|
7
|
+
Collectors are special listenerws that waits for specific message, and are used to implement methods for waiting for RMSP responses, statuses, alarms, etc.
|
8
8
|
|
9
|
-
Note that Archive is not a
|
9
|
+
Note that Archive is not a listener, and does not receive messages via the Notifier. Instead the Archive gets and stores messages via the log() interface in the Logging module. The reason is that the items that the Archive and the Logger contain other data as well as the message, like error messages, warnings, text descriptions, colors codes, etc. The Distributor and Receiver handles only Message objects.
|
10
10
|
|
11
|
-
##
|
11
|
+
## Notifier
|
12
12
|
A module that handles distributing messages to receivers.
|
13
13
|
|
14
|
-
##
|
14
|
+
## Listener
|
15
15
|
Receives messages as long as it's installed into a distributor.
|
16
16
|
|
17
|
-
##
|
17
|
+
## Collector
|
18
18
|
A subclass of Receiver that wait for specific messages. Once received
|
19
19
|
the client receives the collection.
|
20
20
|
|
21
21
|
## Proxy
|
22
|
-
A proxy includes the
|
22
|
+
A proxy includes the Notifier module and distributes each message to listerens after processing it.
|
23
23
|
|
data/lib/rsmp.rb
CHANGED
@@ -10,6 +10,8 @@ require 'json_schemer'
|
|
10
10
|
require 'async/queue'
|
11
11
|
|
12
12
|
require 'rsmp/rsmp'
|
13
|
+
require 'rsmp/deep_merge'
|
14
|
+
require 'rsmp/inspect'
|
13
15
|
require 'rsmp/logging'
|
14
16
|
require 'rsmp/wait'
|
15
17
|
require 'rsmp/node'
|
@@ -31,4 +33,7 @@ require 'rsmp/logger'
|
|
31
33
|
require 'rsmp/archive'
|
32
34
|
require 'rsmp/tlc'
|
33
35
|
|
36
|
+
require 'rsmp/convert/import/yaml'
|
37
|
+
require 'rsmp/convert/export/json_schema'
|
38
|
+
|
34
39
|
require 'rsmp/version'
|
data/lib/rsmp/archive.rb
CHANGED
@@ -3,6 +3,8 @@
|
|
3
3
|
|
4
4
|
module RSMP
|
5
5
|
class Archive
|
6
|
+
include Inspect
|
7
|
+
|
6
8
|
attr_reader :items
|
7
9
|
|
8
10
|
@@index = 0
|
@@ -12,14 +14,15 @@ module RSMP
|
|
12
14
|
@max = max
|
13
15
|
end
|
14
16
|
|
17
|
+
def inspect
|
18
|
+
"#<#{self.class.name}:#{self.object_id}, #{inspector(:@items)}>"
|
19
|
+
end
|
20
|
+
|
15
21
|
def self.prepare_item item
|
16
22
|
raise ArgumentError unless item.is_a? Hash
|
17
23
|
|
18
|
-
now_obj = RSMP.now_object
|
19
|
-
now_str = RSMP.now_string(now_obj)
|
20
|
-
|
21
24
|
cleaned = item.select { |k,v| [:author,:level,:ip,:port,:site_id,:component_id,:str,:message,:exception].include? k }
|
22
|
-
cleaned[:timestamp] =
|
25
|
+
cleaned[:timestamp] = Clock.now
|
23
26
|
if item[:message]
|
24
27
|
cleaned[:direction] = item[:message].direction
|
25
28
|
cleaned[:component_id] = item[:message].attributes['cId']
|
data/lib/rsmp/cli.rb
CHANGED
@@ -2,106 +2,137 @@ require 'thor'
|
|
2
2
|
require 'rsmp'
|
3
3
|
|
4
4
|
module RSMP
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
5
|
+
class CLI < Thor
|
6
|
+
|
7
|
+
desc "site", "Run RSMP site"
|
8
|
+
method_option :config, :type => :string, :aliases => "-c", banner: 'Path to .yaml config file'
|
9
|
+
method_option :id, :type => :string, :aliases => "-i", banner: 'RSMP site id'
|
10
|
+
method_option :supervisors, :type => :string, :aliases => "-s", banner: 'ip:port,... list of supervisor to connect to'
|
11
|
+
method_option :log, :type => :string, :aliases => "-l", banner: 'Path to log file'
|
12
|
+
method_option :json, :type => :boolean, :aliases => "-j", banner: 'Show JSON messages in log'
|
13
|
+
method_option :type, :type => :string, :aliases => "-t", banner: 'Type of site: [tlc]'
|
14
|
+
def site
|
15
|
+
settings = {}
|
16
|
+
log_settings = { 'active' => true }
|
17
|
+
|
18
|
+
if options[:config]
|
19
|
+
if File.exist? options[:config]
|
20
|
+
settings = YAML.load_file options[:config]
|
21
|
+
log_settings = settings.delete('log') || {}
|
22
|
+
else
|
23
|
+
puts "Error: Config #{options[:config]} not found"
|
24
|
+
exit
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
if options[:id]
|
29
|
+
settings['site_id'] = options[:id]
|
30
|
+
end
|
31
|
+
|
32
|
+
if options[:supervisors]
|
33
|
+
settings['supervisors'] = []
|
34
|
+
options[:supervisors].split(',').each do |supervisor|
|
35
|
+
ip, port = supervisor.split ':'
|
36
|
+
ip = '127.0.0.1' if ip.empty?
|
37
|
+
port = '12111' if port.empty?
|
38
|
+
settings['supervisors'] << {"ip"=>ip, "port"=>port}
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
if options[:log]
|
43
|
+
log_settings['path'] = options[:log]
|
44
|
+
end
|
45
|
+
|
46
|
+
if options[:json]
|
47
|
+
log_settings['json'] = options[:json]
|
48
|
+
end
|
49
|
+
|
50
|
+
site_class = RSMP::Site
|
51
|
+
if options[:type]
|
52
|
+
case options[:type]
|
53
|
+
when 'tlc'
|
54
|
+
site_class = RSMP::Tlc
|
55
|
+
else
|
56
|
+
site_class = RSMP::Site
|
57
|
+
end
|
58
|
+
end
|
59
|
+
site_class.new(site_settings:settings, log_settings: log_settings).start
|
60
|
+
rescue RSMP::Schemer::UnknownSchemaTypeError => e
|
61
|
+
puts "Cannot start site: #{e}"
|
62
|
+
rescue RSMP::Schemer::UnknownSchemaVersionError => e
|
63
|
+
puts "Cannot start site: #{e}"
|
64
|
+
rescue Psych::SyntaxError => e
|
65
|
+
puts "Cannot read config file #{e}"
|
66
|
+
end
|
67
|
+
|
68
|
+
desc "supervisor", "Run RSMP supervisor"
|
69
|
+
method_option :config, :type => :string, :aliases => "-c", banner: 'Path to .yaml config file'
|
70
|
+
method_option :id, :type => :string, :aliases => "-i", banner: 'RSMP site id'
|
71
|
+
method_option :ip, :type => :numeric, banner: 'IP address to listen on'
|
72
|
+
method_option :port, :type => :string, :aliases => "-p", banner: 'Port to listen on'
|
73
|
+
method_option :log, :type => :string, :aliases => "-l", banner: 'Path to log file'
|
74
|
+
method_option :json, :type => :boolean, :aliases => "-j", banner: 'Show JSON messages in log'
|
75
|
+
def supervisor
|
76
|
+
settings = {}
|
77
|
+
log_settings = { 'active' => true }
|
78
|
+
|
79
|
+
if options[:config]
|
80
|
+
if File.exist? options[:config]
|
81
|
+
settings = YAML.load_file options[:config]
|
82
|
+
log_settings = settings.delete 'log'
|
83
|
+
else
|
84
|
+
puts "Error: Config #{options[:config]} not found"
|
85
|
+
exit
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
if options[:id]
|
90
|
+
settings['site_id'] = options[:id]
|
91
|
+
end
|
92
|
+
|
93
|
+
if options[:ip]
|
94
|
+
settings['ip'] = options[:ip]
|
95
|
+
end
|
96
|
+
|
97
|
+
if options[:port]
|
98
|
+
settings['port'] = options[:port]
|
99
|
+
end
|
100
|
+
|
101
|
+
if options[:log]
|
102
|
+
log_settings['path'] = options[:log]
|
103
|
+
end
|
104
|
+
|
105
|
+
if options[:json]
|
106
|
+
log_settings['json'] = options[:json]
|
107
|
+
end
|
108
|
+
|
109
|
+
RSMP::Supervisor.new(supervisor_settings:settings,log_settings:log_settings).start
|
110
|
+
rescue RSMP::ConfigurationError => e
|
111
|
+
puts "Cannot start supervisor: #{e}"
|
112
|
+
end
|
113
|
+
|
114
|
+
desc "convert", "Convert SXL from YAML to JSON Schema"
|
115
|
+
method_option :in, :type => :string, :aliases => "-i", banner: 'Path to YAML input file'
|
116
|
+
method_option :out, :type => :string, :aliases => "-o", banner: 'Path to JSON Schema output file'
|
117
|
+
def convert
|
118
|
+
unless options[:in]
|
119
|
+
puts "Error: Input option missing"
|
120
|
+
exit
|
121
|
+
end
|
122
|
+
|
123
|
+
unless options[:out]
|
124
|
+
puts "Error: Output option missing"
|
125
|
+
exit
|
126
|
+
end
|
127
|
+
|
128
|
+
unless File.exist? options[:in]
|
129
|
+
puts "Error: Input path file #{options[:in]} not found"
|
130
|
+
exit
|
131
|
+
end
|
132
|
+
|
133
|
+
sxl = RSMP::Convert::Import::YAML.read options[:in]
|
134
|
+
RSMP::Convert::Export::JSONSchema.write sxl, options[:out]
|
135
|
+
end
|
136
|
+
|
137
|
+
end
|
107
138
|
end
|