rsmp 0.8.1 → 0.8.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/Gemfile.lock +45 -67
- data/config/tlc.yaml +8 -6
- data/documentation/collecting_message.md +1 -1
- data/lib/rsmp/collect/collector.rb +37 -24
- data/lib/rsmp/collect/command_response_collector.rb +1 -1
- data/lib/rsmp/collect/filter.rb +31 -0
- data/lib/rsmp/collect/listener.rb +0 -8
- data/lib/rsmp/collect/query.rb +16 -6
- data/lib/rsmp/collect/state_collector.rb +18 -7
- data/lib/rsmp/collect/status_collector.rb +20 -0
- data/lib/rsmp/node.rb +0 -1
- data/lib/rsmp/proxy.rb +22 -19
- data/lib/rsmp/site.rb +3 -2
- data/lib/rsmp/site_proxy.rb +26 -46
- data/lib/rsmp/supervisor_proxy.rb +3 -11
- data/lib/rsmp/tlc/signal_group.rb +15 -7
- data/lib/rsmp/tlc/traffic_controller.rb +92 -28
- data/lib/rsmp/tlc/traffic_controller_site.rb +10 -1
- data/lib/rsmp/version.rb +1 -1
- data/lib/rsmp.rb +2 -3
- data/rsmp.gemspec +7 -7
- metadata +19 -20
- data/lib/rsmp/collect/status_response_collector.rb +0 -11
- data/lib/rsmp/collect/status_update_collector.rb +0 -11
- data/lib/rsmp/collect/status_update_or_response_collector.rb +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e12fd3ea8f7f931b3ce3269a13e8ccd1248642a89062682b0088d044732f1757
|
4
|
+
data.tar.gz: ff18134bf0e16210e30a5820f5bd2c27b5fb7f81bcf2f9f993e6c8aefe69d9d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3335d30f728748483d26e5d3d0c5671746b80dece2badc781064d0ae81f277fd7b899e9e508255a17d6f1cbd017a64164f6f0a21f1ca777b359c23b1fa482ebf
|
7
|
+
data.tar.gz: a2e457988983d9c3173f91c1269979ea6a37ce75ac5e0acc30f21fbb34d2cfab8fe81295ac43c6a6010df0f7c06e11dc9efadd01c28fc20a0e77ff6d6c580787
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.0
|
1
|
+
3.1.0
|
data/Gemfile.lock
CHANGED
@@ -1,27 +1,21 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rsmp (0.8.
|
4
|
+
rsmp (0.8.5)
|
5
5
|
async (~> 1.29.1)
|
6
|
-
async-io (~> 1.32.
|
6
|
+
async-io (~> 1.32.2)
|
7
7
|
colorize (~> 0.8.1)
|
8
8
|
rsmp_schemer
|
9
|
-
thor (~> 1.
|
9
|
+
thor (~> 1.2.1)
|
10
10
|
|
11
11
|
GEM
|
12
12
|
remote: https://rubygems.org/
|
13
13
|
specs:
|
14
|
-
|
15
|
-
concurrent-ruby (~> 1.0, >= 1.0.2)
|
16
|
-
i18n (>= 1.6, < 2)
|
17
|
-
minitest (>= 5.1)
|
18
|
-
tzinfo (~> 2.0)
|
19
|
-
zeitwerk (~> 2.3)
|
20
|
-
aruba (1.1.2)
|
14
|
+
aruba (2.0.0)
|
21
15
|
bundler (>= 1.17, < 3.0)
|
22
16
|
childprocess (>= 2.0, < 5.0)
|
23
17
|
contracts (>= 0.16.0, < 0.18.0)
|
24
|
-
cucumber (>=
|
18
|
+
cucumber (>= 4.0, < 8.0)
|
25
19
|
rspec-expectations (~> 3.4)
|
26
20
|
thor (~> 1.0)
|
27
21
|
async (1.29.2)
|
@@ -33,68 +27,56 @@ GEM
|
|
33
27
|
builder (3.2.4)
|
34
28
|
childprocess (4.1.0)
|
35
29
|
colorize (0.8.1)
|
36
|
-
concurrent-ruby (1.1.9)
|
37
30
|
console (1.14.0)
|
38
31
|
fiber-local
|
39
32
|
contracts (0.17)
|
40
|
-
cucumber (
|
33
|
+
cucumber (7.1.0)
|
41
34
|
builder (~> 3.2, >= 3.2.4)
|
42
|
-
cucumber-core (~>
|
43
|
-
cucumber-create-meta (~>
|
44
|
-
cucumber-cucumber-expressions (~>
|
45
|
-
cucumber-gherkin (~>
|
46
|
-
cucumber-html-formatter (~>
|
47
|
-
cucumber-messages (~>
|
48
|
-
cucumber-wire (~>
|
35
|
+
cucumber-core (~> 10.1, >= 10.1.0)
|
36
|
+
cucumber-create-meta (~> 6.0, >= 6.0.1)
|
37
|
+
cucumber-cucumber-expressions (~> 14.0, >= 14.0.0)
|
38
|
+
cucumber-gherkin (~> 22.0, >= 22.0.0)
|
39
|
+
cucumber-html-formatter (~> 17.0, >= 17.0.0)
|
40
|
+
cucumber-messages (~> 17.1, >= 17.1.1)
|
41
|
+
cucumber-wire (~> 6.2, >= 6.2.0)
|
49
42
|
diff-lcs (~> 1.4, >= 1.4.4)
|
50
43
|
mime-types (~> 3.3, >= 3.3.1)
|
51
44
|
multi_test (~> 0.1, >= 0.1.2)
|
52
45
|
sys-uname (~> 1.2, >= 1.2.2)
|
53
|
-
cucumber-core (
|
54
|
-
cucumber-gherkin (~>
|
55
|
-
cucumber-messages (~>
|
56
|
-
cucumber-tag-expressions (~>
|
57
|
-
cucumber-create-meta (
|
58
|
-
cucumber-messages (~>
|
46
|
+
cucumber-core (10.1.1)
|
47
|
+
cucumber-gherkin (~> 22.0, >= 22.0.0)
|
48
|
+
cucumber-messages (~> 17.1, >= 17.1.1)
|
49
|
+
cucumber-tag-expressions (~> 4.1, >= 4.1.0)
|
50
|
+
cucumber-create-meta (6.0.4)
|
51
|
+
cucumber-messages (~> 17.1, >= 17.1.1)
|
59
52
|
sys-uname (~> 1.2, >= 1.2.2)
|
60
|
-
cucumber-cucumber-expressions (
|
61
|
-
cucumber-gherkin (
|
62
|
-
cucumber-messages (~>
|
63
|
-
cucumber-html-formatter (
|
64
|
-
cucumber-messages (~>
|
65
|
-
cucumber-messages (
|
66
|
-
|
67
|
-
cucumber-
|
68
|
-
|
69
|
-
cucumber-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
regexp_parser (~> 2.0)
|
75
|
-
ffi (1.15.3)
|
53
|
+
cucumber-cucumber-expressions (14.0.0)
|
54
|
+
cucumber-gherkin (22.0.0)
|
55
|
+
cucumber-messages (~> 17.1, >= 17.1.1)
|
56
|
+
cucumber-html-formatter (17.0.0)
|
57
|
+
cucumber-messages (~> 17.1, >= 17.1.0)
|
58
|
+
cucumber-messages (17.1.1)
|
59
|
+
cucumber-tag-expressions (4.1.0)
|
60
|
+
cucumber-wire (6.2.1)
|
61
|
+
cucumber-core (~> 10.1, >= 10.1.0)
|
62
|
+
cucumber-cucumber-expressions (~> 14.0, >= 14.0.0)
|
63
|
+
diff-lcs (1.5.0)
|
64
|
+
ecma-re-validator (0.4.0)
|
65
|
+
regexp_parser (~> 2.2)
|
66
|
+
ffi (1.15.5)
|
76
67
|
fiber-local (1.0.0)
|
77
68
|
hana (1.3.7)
|
78
|
-
i18n (1.8.10)
|
79
|
-
concurrent-ruby (~> 1.0)
|
80
69
|
json_schemer (0.2.18)
|
81
70
|
ecma-re-validator (~> 0.3)
|
82
71
|
hana (~> 1.3)
|
83
72
|
regexp_parser (~> 2.0)
|
84
73
|
uri_template (~> 0.7)
|
85
|
-
|
86
|
-
mime-types (3.3.1)
|
74
|
+
mime-types (3.4.1)
|
87
75
|
mime-types-data (~> 3.2015)
|
88
|
-
mime-types-data (3.
|
89
|
-
minitest (5.14.4)
|
76
|
+
mime-types-data (3.2022.0105)
|
90
77
|
multi_test (0.1.2)
|
91
78
|
nio4r (2.5.8)
|
92
|
-
|
93
|
-
activesupport (>= 3.2)
|
94
|
-
middleware
|
95
|
-
thor
|
96
|
-
thread_safe
|
97
|
-
rake (13.0.3)
|
79
|
+
rake (13.0.6)
|
98
80
|
regexp_parser (2.2.0)
|
99
81
|
rsmp_schemer (0.3.2)
|
100
82
|
json_schemer (~> 0.2.18)
|
@@ -104,37 +86,33 @@ GEM
|
|
104
86
|
rspec-mocks (~> 3.10.0)
|
105
87
|
rspec-core (3.10.1)
|
106
88
|
rspec-support (~> 3.10.0)
|
107
|
-
rspec-expectations (3.10.
|
89
|
+
rspec-expectations (3.10.2)
|
108
90
|
diff-lcs (>= 1.2.0, < 2.0)
|
109
91
|
rspec-support (~> 3.10.0)
|
110
92
|
rspec-mocks (3.10.2)
|
111
93
|
diff-lcs (>= 1.2.0, < 2.0)
|
112
94
|
rspec-support (~> 3.10.0)
|
113
|
-
rspec-support (3.10.
|
95
|
+
rspec-support (3.10.3)
|
114
96
|
sys-uname (1.2.2)
|
115
97
|
ffi (~> 1.1)
|
116
|
-
thor (1.
|
117
|
-
thread_safe (0.3.6)
|
98
|
+
thor (1.2.1)
|
118
99
|
timecop (0.9.4)
|
119
100
|
timers (4.3.3)
|
120
|
-
tzinfo (2.0.4)
|
121
|
-
concurrent-ruby (~> 1.0)
|
122
101
|
uri_template (0.7.0)
|
123
|
-
zeitwerk (2.4.2)
|
124
102
|
|
125
103
|
PLATFORMS
|
126
104
|
x86_64-darwin-20
|
127
105
|
x86_64-darwin-21
|
128
106
|
|
129
107
|
DEPENDENCIES
|
130
|
-
aruba (~>
|
131
|
-
bundler (~> 2.
|
132
|
-
cucumber (~>
|
133
|
-
rake (~> 13.0.
|
108
|
+
aruba (~> 2.0.0)
|
109
|
+
bundler (~> 2.3.6)
|
110
|
+
cucumber (~> 7.1.0)
|
111
|
+
rake (~> 13.0.6)
|
134
112
|
rsmp!
|
135
113
|
rspec (~> 3.10.0)
|
136
|
-
rspec-expectations (~> 3.10.
|
114
|
+
rspec-expectations (~> 3.10.2)
|
137
115
|
timecop (~> 0.9.4)
|
138
116
|
|
139
117
|
BUNDLED WITH
|
140
|
-
2.
|
118
|
+
2.3.6
|
data/config/tlc.yaml
CHANGED
@@ -20,17 +20,18 @@ signal_plans:
|
|
20
20
|
dynamic_bands:
|
21
21
|
1: 0
|
22
22
|
2: 5
|
23
|
-
states:
|
24
|
-
A1: '11NBBB'
|
25
|
-
A2: '1NBBBB'
|
26
|
-
B1: 'BBB11N'
|
27
|
-
B2: 'BBB1NB'
|
28
|
-
2:
|
29
23
|
states:
|
30
24
|
A1: '111NBB'
|
31
25
|
A2: '11NBBB'
|
32
26
|
B1: 'BBB11N'
|
33
27
|
B2: 'BBB1NB'
|
28
|
+
2:
|
29
|
+
states:
|
30
|
+
A1: 'NNNNBB'
|
31
|
+
A2: 'NNNNBN'
|
32
|
+
B1: 'BBNNNN'
|
33
|
+
B2: 'BNNNNN'
|
34
|
+
startup_sequence: 'efg'
|
34
35
|
intervals:
|
35
36
|
timer: 0.1
|
36
37
|
watchdog: 0.1
|
@@ -48,3 +49,4 @@ log:
|
|
48
49
|
level: false
|
49
50
|
debug: true
|
50
51
|
json: true
|
52
|
+
live_output: tmp/tlc.state
|
@@ -157,7 +157,7 @@ task.wait # wait for collection task to complete (or time out)
|
|
157
157
|
```
|
158
158
|
|
159
159
|
### With collection
|
160
|
-
If you provide `:collect` options, it will be used to construct a
|
160
|
+
If you provide `:collect` options, it will be used to construct a StatusCollector for collecting the relevant status messages. When collection completes the collector is returned in the `:collector` key:
|
161
161
|
|
162
162
|
```ruby
|
163
163
|
options = {
|
@@ -6,8 +6,8 @@ module RSMP
|
|
6
6
|
class Collector < Listener
|
7
7
|
attr_reader :condition, :messages, :status, :error, :task
|
8
8
|
|
9
|
-
def initialize
|
10
|
-
super
|
9
|
+
def initialize notifier, options={}
|
10
|
+
super notifier, options
|
11
11
|
@options = {
|
12
12
|
cancel: {
|
13
13
|
schema_error: true,
|
@@ -18,7 +18,15 @@ module RSMP
|
|
18
18
|
@outgoing = options[:outgoing] == nil ? false : options[:outgoing]
|
19
19
|
@condition = Async::Notification.new
|
20
20
|
@title = options[:title] || [@options[:type]].flatten.join('/')
|
21
|
-
|
21
|
+
if options[:task]
|
22
|
+
@task = options[:task]
|
23
|
+
else
|
24
|
+
# if notifier is a Proxy, or some other object that implements task(),
|
25
|
+
# then try to get the task that way
|
26
|
+
if notifier.respond_to? 'task'
|
27
|
+
@task = notifier.task
|
28
|
+
end
|
29
|
+
end
|
22
30
|
reset
|
23
31
|
end
|
24
32
|
|
@@ -43,12 +51,12 @@ module RSMP
|
|
43
51
|
@status == :collecting
|
44
52
|
end
|
45
53
|
|
46
|
-
# Is collection
|
54
|
+
# Is collection complete?
|
47
55
|
def ok?
|
48
56
|
@status == :ok
|
49
57
|
end
|
50
58
|
|
51
|
-
# Has collection
|
59
|
+
# Has collection timed out?
|
52
60
|
def timeout?
|
53
61
|
@status == :timeout
|
54
62
|
end
|
@@ -73,6 +81,13 @@ module RSMP
|
|
73
81
|
@outgoing == true
|
74
82
|
end
|
75
83
|
|
84
|
+
# if an errors caused collection to abort, then raise it
|
85
|
+
# return self, so this can be tucked on to calls that return a collector
|
86
|
+
def ok!
|
87
|
+
raise @error if @error
|
88
|
+
self
|
89
|
+
end
|
90
|
+
|
76
91
|
# Collect message
|
77
92
|
# Will return once all messages have been collected, or timeout is reached
|
78
93
|
def collect &block
|
@@ -80,15 +95,14 @@ module RSMP
|
|
80
95
|
wait
|
81
96
|
@status
|
82
97
|
ensure
|
83
|
-
@notifier.remove_listener self
|
98
|
+
@notifier.remove_listener self if @notifier
|
84
99
|
end
|
85
100
|
|
86
101
|
# Collect message
|
87
102
|
# Returns the collected messages, or raise an exception in case of a time out.
|
88
103
|
def collect! &block
|
89
|
-
|
90
|
-
|
91
|
-
end
|
104
|
+
collect(&block)
|
105
|
+
ok!
|
92
106
|
@messages
|
93
107
|
end
|
94
108
|
|
@@ -104,6 +118,7 @@ module RSMP
|
|
104
118
|
end
|
105
119
|
@status
|
106
120
|
rescue Async::TimeoutError
|
121
|
+
@error = RSMP::TimeoutError.new describe_progress
|
107
122
|
@status = :timeout
|
108
123
|
end
|
109
124
|
|
@@ -112,7 +127,7 @@ module RSMP
|
|
112
127
|
# If timeout is reached, an exceptioin is raised.
|
113
128
|
def wait!
|
114
129
|
wait
|
115
|
-
raise
|
130
|
+
raise @error if timeout?
|
116
131
|
@messages
|
117
132
|
end
|
118
133
|
|
@@ -151,28 +166,26 @@ module RSMP
|
|
151
166
|
# Handle message. and return true when we're done collecting
|
152
167
|
def notify message
|
153
168
|
raise ArgumentError unless message
|
154
|
-
raise RuntimeError.new("can't process message when
|
155
|
-
|
156
|
-
perform_match message
|
157
|
-
end
|
169
|
+
raise RuntimeError.new("can't process message when status is :#{@status}, title: #{@title}, desc: #{describe}") unless ready? || collecting?
|
170
|
+
perform_match message
|
158
171
|
@status
|
159
172
|
end
|
160
173
|
|
174
|
+
def describe
|
175
|
+
end
|
176
|
+
|
161
177
|
# Match message against our collection criteria
|
162
178
|
def perform_match message
|
163
|
-
return
|
179
|
+
return false if reject_not_ack(message)
|
180
|
+
return false unless type_match?(message)
|
164
181
|
if @block
|
165
182
|
status = [@block.call(message)].flatten
|
183
|
+
return unless collecting?
|
166
184
|
keep message if status.include?(:keep)
|
167
|
-
if status.include?(:cancel)
|
168
|
-
cancel('Cancelled by block')
|
169
|
-
else
|
170
|
-
complete if done?
|
171
|
-
end
|
172
185
|
else
|
173
186
|
keep message
|
174
|
-
complete if done?
|
175
187
|
end
|
188
|
+
complete if done?
|
176
189
|
end
|
177
190
|
|
178
191
|
# Have we collected the required number of messages?
|
@@ -194,8 +207,8 @@ module RSMP
|
|
194
207
|
@condition.signal
|
195
208
|
end
|
196
209
|
|
197
|
-
#
|
198
|
-
# Check if
|
210
|
+
# An error occured upstream.
|
211
|
+
# Check if we should cancel.
|
199
212
|
def notify_error error, options={}
|
200
213
|
case error
|
201
214
|
when RSMP::SchemaError
|
@@ -224,7 +237,7 @@ module RSMP
|
|
224
237
|
end
|
225
238
|
|
226
239
|
# Abort collection
|
227
|
-
def cancel error
|
240
|
+
def cancel error=nil
|
228
241
|
@error = error
|
229
242
|
@status = :cancelled
|
230
243
|
do_stop
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module RSMP
|
2
|
+
|
3
|
+
# Filter messages based on type, direction and component id.
|
4
|
+
# Used by Collectors.
|
5
|
+
class Filter
|
6
|
+
def initialize ingoing:true, outgoing:true, type:, component:nil
|
7
|
+
@ingoing = ingoing
|
8
|
+
@outgoing = outgoing
|
9
|
+
@type = type
|
10
|
+
@component = component
|
11
|
+
end
|
12
|
+
|
13
|
+
# Check a message against our match criteria
|
14
|
+
# Return true if there's a match, false if not
|
15
|
+
def accept? message
|
16
|
+
return false if message.direction == :in && @ingoing == false
|
17
|
+
return false if message.direction == :out && @outgoing == false
|
18
|
+
if @type
|
19
|
+
if @type.is_a? Array
|
20
|
+
return false unless @type.include? message.type
|
21
|
+
else
|
22
|
+
return false unless message.type == @type
|
23
|
+
end
|
24
|
+
end
|
25
|
+
if @component
|
26
|
+
return false if message.attributes['cId'] && message.attributes['cId'] != @component
|
27
|
+
end
|
28
|
+
true
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/rsmp/collect/query.rb
CHANGED
@@ -8,26 +8,36 @@ module RSMP
|
|
8
8
|
@want = want
|
9
9
|
@got = nil
|
10
10
|
@message = nil
|
11
|
-
@done = false
|
12
11
|
end
|
13
12
|
|
14
13
|
# Are we done, i.e. did the last checked item match?
|
15
14
|
def done?
|
16
|
-
@
|
15
|
+
@got != nil
|
17
16
|
end
|
18
17
|
|
19
18
|
# Check an item and set @done to true if it matches
|
20
19
|
# Store the item and corresponding message if there's a positive or negative match
|
21
|
-
def perform_match item, message
|
20
|
+
def perform_match item, message, block
|
22
21
|
matched = match? item
|
23
22
|
if matched != nil
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
if block
|
24
|
+
status = block.call(nil,item)
|
25
|
+
matched = status if status == true || status == false
|
26
|
+
end
|
27
27
|
end
|
28
28
|
matched
|
29
29
|
end
|
30
30
|
|
31
|
+
def keep message, item
|
32
|
+
@message = message
|
33
|
+
@got = item
|
34
|
+
end
|
35
|
+
|
36
|
+
def forget
|
37
|
+
@message = nil
|
38
|
+
@got = nil
|
39
|
+
end
|
40
|
+
|
31
41
|
def match? item
|
32
42
|
end
|
33
43
|
end
|
@@ -61,7 +61,7 @@ module RSMP
|
|
61
61
|
|
62
62
|
# Get messages from results
|
63
63
|
def messages
|
64
|
-
@queries.map { |query| query.message }.uniq
|
64
|
+
@queries.map { |query| query.message }.uniq.compact
|
65
65
|
end
|
66
66
|
|
67
67
|
# Return progress as completes queries vs. total number of queries
|
@@ -90,22 +90,33 @@ module RSMP
|
|
90
90
|
# Check if a messages matches our criteria.
|
91
91
|
# Match each query against each item in the message
|
92
92
|
def perform_match message
|
93
|
-
return
|
93
|
+
return false if super(message) == false
|
94
|
+
return unless collecting?
|
94
95
|
@queries.each do |query| # look through queries
|
95
96
|
get_items(message).each do |item| # look through items in message
|
96
|
-
matched = query.perform_match(item,message)
|
97
|
-
|
98
|
-
matched = @block.call(message,item) if @block
|
99
|
-
end
|
97
|
+
matched = query.perform_match(item,message,@block)
|
98
|
+
return unless collecting?
|
100
99
|
if matched != nil
|
101
100
|
type = {true=>'match',false=>'mismatch'}[matched]
|
102
101
|
@notifier.log "#{@title.capitalize} #{message.m_id_short} collect #{type} #{query.want}, item #{item}", level: :debug
|
103
|
-
|
102
|
+
if matched == true
|
103
|
+
query.keep message, item
|
104
|
+
elsif matched == false
|
105
|
+
query.forget
|
106
|
+
end
|
104
107
|
end
|
105
108
|
end
|
106
109
|
end
|
107
110
|
complete if done?
|
108
111
|
@notifier.log "#{@title.capitalize} collect reached #{summary}", level: :debug
|
109
112
|
end
|
113
|
+
|
114
|
+
# don't collect anything. Query will collect them instead
|
115
|
+
def keep message
|
116
|
+
end
|
117
|
+
|
118
|
+
def describe
|
119
|
+
@queries.map {|q| q.want.to_s }
|
120
|
+
end
|
110
121
|
end
|
111
122
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module RSMP
|
2
|
+
# Base class for waiting for status updates or responses
|
3
|
+
class StatusCollector < StateCollector
|
4
|
+
def initialize proxy, want, options={}
|
5
|
+
super proxy, want, options.merge(title: 'status response', type:['MessageNotAck'])
|
6
|
+
|
7
|
+
@options[:type] << 'StatusUpdate' unless options[:updates] == false
|
8
|
+
@options[:type] << 'StatusResponse' unless options[:reponses] == false
|
9
|
+
end
|
10
|
+
|
11
|
+
def build_query want
|
12
|
+
RSMP::StatusQuery.new want
|
13
|
+
end
|
14
|
+
|
15
|
+
# Get items, in our case status values
|
16
|
+
def get_items message
|
17
|
+
message.attributes['sS'] || []
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/rsmp/node.rb
CHANGED
data/lib/rsmp/proxy.rb
CHANGED
@@ -52,12 +52,6 @@ module RSMP
|
|
52
52
|
node.clock
|
53
53
|
end
|
54
54
|
|
55
|
-
def collect options, &block
|
56
|
-
collector = RSMP::Collector.new self, options.merge(task: @task)
|
57
|
-
collector.collect &block
|
58
|
-
collector
|
59
|
-
end
|
60
|
-
|
61
55
|
def run
|
62
56
|
start
|
63
57
|
@reader.wait if @reader
|
@@ -579,25 +573,34 @@ module RSMP
|
|
579
573
|
end
|
580
574
|
|
581
575
|
def wait_for_acknowledgement parent_task, options={}, m_id
|
582
|
-
|
583
|
-
|
584
|
-
num: 1
|
585
|
-
})) do |message|
|
576
|
+
collector = Collector.new self, options.merge(task: parent_task, type: ['MessageAck','MessageNotAck'])
|
577
|
+
collector.collect do |message|
|
586
578
|
if message.is_a?(MessageNotAck)
|
587
579
|
if message.attribute('oMId') == m_id
|
588
|
-
# set result to an exception, but don't raise it.
|
589
|
-
# this will be returned by the task and stored as the task result
|
590
|
-
# when the parent task call wait() on the task, the exception
|
591
|
-
# will be raised in the parent task, and caught by rspec.
|
592
|
-
# rspec will then show the error and record the test as failed
|
593
580
|
m_id_short = RSMP::Message.shorten_m_id m_id, 8
|
594
|
-
|
595
|
-
next true # done, no more messages wanted
|
581
|
+
raise RSMP::MessageRejected.new "Aggregated status request #{m_id_short} was rejected with '#{message.attribute('rea')}'"
|
596
582
|
end
|
597
583
|
elsif message.is_a?(MessageAck)
|
598
|
-
|
584
|
+
collector.complete if message.attribute('oMId') == m_id
|
585
|
+
end
|
586
|
+
end
|
587
|
+
end
|
588
|
+
|
589
|
+
def send_and_optionally_collect message, options, &block
|
590
|
+
collect_options = options[:collect] || options[:collect!]
|
591
|
+
if collect_options
|
592
|
+
task = @task.async do |task|
|
593
|
+
collector = yield collect_options # call block to create collector
|
594
|
+
collector.collect
|
595
|
+
collector.ok! if options[:collect!] # raise any errors if the bang version was specified
|
596
|
+
collector
|
599
597
|
end
|
600
|
-
|
598
|
+
|
599
|
+
send_message message, validate: options[:validate]
|
600
|
+
{ sent: message, collector: task.wait }
|
601
|
+
else
|
602
|
+
send_message message, validate: options[:validate]
|
603
|
+
return { sent: message }
|
601
604
|
end
|
602
605
|
end
|
603
606
|
end
|
data/lib/rsmp/site.rb
CHANGED
@@ -9,9 +9,9 @@ module RSMP
|
|
9
9
|
attr_reader :rsmp_versions, :site_settings, :logger, :proxies
|
10
10
|
|
11
11
|
def initialize options={}
|
12
|
+
super options
|
12
13
|
initialize_components
|
13
14
|
handle_site_settings options
|
14
|
-
super options
|
15
15
|
@proxies = []
|
16
16
|
@sleep_condition = Async::Notification.new
|
17
17
|
@proxies_condition = Async::Notification.new
|
@@ -95,7 +95,8 @@ module RSMP
|
|
95
95
|
ip: supervisor_settings['ip'],
|
96
96
|
port: supervisor_settings['port'],
|
97
97
|
logger: @logger,
|
98
|
-
archive: @archive
|
98
|
+
archive: @archive,
|
99
|
+
collect: @collect
|
99
100
|
})
|
100
101
|
@proxies << proxy
|
101
102
|
@proxies_condition.signal
|