rsmp 0.8.2 → 0.8.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/documentation/collecting_message.md +1 -1
- data/lib/rsmp/collect/collector.rb +13 -5
- data/lib/rsmp/collect/{status_update_or_response_collector.rb → status_collector.rb} +5 -2
- data/lib/rsmp/node.rb +0 -1
- data/lib/rsmp/proxy.rb +15 -19
- data/lib/rsmp/site.rb +2 -1
- data/lib/rsmp/site_proxy.rb +34 -46
- data/lib/rsmp/supervisor_proxy.rb +2 -10
- data/lib/rsmp/version.rb +1 -1
- data/lib/rsmp.rb +1 -3
- metadata +3 -5
- data/lib/rsmp/collect/status_response_collector.rb +0 -11
- data/lib/rsmp/collect/status_update_collector.rb +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f54121873905da2e5ffa4914f4f454fc4b59c7283e482b6b89b4035d686b7779
|
4
|
+
data.tar.gz: 523d2e310ebec8f4df07592fcb501d91f604ba8ea1c4625482c7d8d011340a6f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 807d2283a18f4a9c4e45594d4ae85e75464cde3792eb941342a825e8765a00d21f7d541fac03191680e28eb7e4af4c6624cb6ce80486da191cf3bc2b3f2d6431
|
7
|
+
data.tar.gz: 6adc50becc91e2deab2c8099808a492a2440d072188227147742bd51ec1310f8a1075e3bed72f2989581ba11125b9beeda8134704d8a42e131ac1dac9a76eca1
|
data/Gemfile.lock
CHANGED
@@ -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
|
|
@@ -192,8 +200,8 @@ module RSMP
|
|
192
200
|
@condition.signal
|
193
201
|
end
|
194
202
|
|
195
|
-
#
|
196
|
-
# Check if
|
203
|
+
# An error occured upstream.
|
204
|
+
# Check if we should cancel.
|
197
205
|
def notify_error error, options={}
|
198
206
|
case error
|
199
207
|
when RSMP::SchemaError
|
@@ -1,8 +1,11 @@
|
|
1
1
|
module RSMP
|
2
2
|
# Base class for waiting for status updates or responses
|
3
|
-
class
|
3
|
+
class StatusCollector < StateCollector
|
4
4
|
def initialize proxy, want, options={}
|
5
|
-
super proxy, want, options.merge(
|
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
|
6
9
|
end
|
7
10
|
|
8
11
|
def build_query want
|
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,27 @@ 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
|
599
585
|
end
|
600
|
-
|
586
|
+
end
|
587
|
+
end
|
588
|
+
|
589
|
+
def send_and_optionally_collect message, options, &block
|
590
|
+
if options[:collect]
|
591
|
+
task = @task.async { |task| yield task }
|
592
|
+
send_message message, validate: options[:validate]
|
593
|
+
{ sent: message, collector: task.wait }
|
594
|
+
else
|
595
|
+
send_message message, validate: options[:validate]
|
596
|
+
return { sent: message }
|
601
597
|
end
|
602
598
|
end
|
603
599
|
end
|
data/lib/rsmp/site.rb
CHANGED
data/lib/rsmp/site_proxy.rb
CHANGED
@@ -101,8 +101,13 @@ module RSMP
|
|
101
101
|
"cId" => component,
|
102
102
|
"mId" => m_id
|
103
103
|
})
|
104
|
-
|
105
|
-
|
104
|
+
send_and_optionally_collect message, options do |task|
|
105
|
+
collector = AggregatedStatusCollector.new(
|
106
|
+
self,
|
107
|
+
options[:collect].merge(task:@task,m_id: m_id, num:1)
|
108
|
+
)
|
109
|
+
collector.collect
|
110
|
+
collector
|
106
111
|
end
|
107
112
|
end
|
108
113
|
|
@@ -174,8 +179,14 @@ module RSMP
|
|
174
179
|
"sS" => request_list,
|
175
180
|
"mId" => m_id
|
176
181
|
})
|
177
|
-
|
178
|
-
|
182
|
+
send_and_optionally_collect message, options do |task|
|
183
|
+
collector = StatusCollector.new(
|
184
|
+
self,
|
185
|
+
status_list,
|
186
|
+
options[:collect].merge(task:@task,m_id: m_id)
|
187
|
+
)
|
188
|
+
collector.collect
|
189
|
+
collector
|
179
190
|
end
|
180
191
|
end
|
181
192
|
|
@@ -186,17 +197,6 @@ module RSMP
|
|
186
197
|
acknowledge message
|
187
198
|
end
|
188
199
|
|
189
|
-
def send_and_collect_if_needed message, options, &block
|
190
|
-
if options[:collect]
|
191
|
-
task = @task.async { |task| yield task }
|
192
|
-
send_message message, validate: options[:validate]
|
193
|
-
{ sent: message, collector: task.wait }
|
194
|
-
else
|
195
|
-
send_message message, validate: options[:validate]
|
196
|
-
return { sent: message }
|
197
|
-
end
|
198
|
-
end
|
199
|
-
|
200
200
|
def subscribe_to_status component_id, status_list, options={}
|
201
201
|
validate_ready 'subscribe to status'
|
202
202
|
m_id = options[:m_id] || RSMP::Message.make_m_id
|
@@ -215,8 +215,14 @@ module RSMP
|
|
215
215
|
"sS" => subscribe_list,
|
216
216
|
'mId' => m_id
|
217
217
|
})
|
218
|
-
|
219
|
-
|
218
|
+
send_and_optionally_collect message, options do |task|
|
219
|
+
collector = StatusCollector.new(
|
220
|
+
self,
|
221
|
+
status_list,
|
222
|
+
options[:collect].merge(task:@task,m_id: m_id)
|
223
|
+
)
|
224
|
+
collector.collect
|
225
|
+
collector
|
220
226
|
end
|
221
227
|
end
|
222
228
|
|
@@ -261,8 +267,14 @@ module RSMP
|
|
261
267
|
"arg" => command_list,
|
262
268
|
"mId" => m_id
|
263
269
|
})
|
264
|
-
|
265
|
-
|
270
|
+
send_and_optionally_collect message, options do |task|
|
271
|
+
collector = CommandResponseCollector.new(
|
272
|
+
self,
|
273
|
+
command_list,
|
274
|
+
options[:collect].merge(task:@task,m_id: m_id)
|
275
|
+
)
|
276
|
+
collector.collect
|
277
|
+
collector
|
266
278
|
end
|
267
279
|
end
|
268
280
|
|
@@ -339,37 +351,13 @@ module RSMP
|
|
339
351
|
distribute_error e, options
|
340
352
|
end
|
341
353
|
|
342
|
-
def collect_alarms
|
343
|
-
collect(
|
354
|
+
def collect_alarms options={}
|
355
|
+
collect(@task,options.merge(type: "Alarm")) do |alarm|
|
344
356
|
next if options[:aCId] && options[:aCId] != alarm.attribute("aCId")
|
345
357
|
next if options[:aSp] && options[:aSp] != alarm.attribute("aSp")
|
346
358
|
next if options[:aS] && options[:aS] != alarm.attribute("aS")
|
347
|
-
|
359
|
+
:keep
|
348
360
|
end
|
349
361
|
end
|
350
|
-
|
351
|
-
def collect_status_updates task, status_list, options
|
352
|
-
collector = StatusUpdateCollector.new(self, status_list, options.merge(task:task))
|
353
|
-
collector.collect
|
354
|
-
collector
|
355
|
-
end
|
356
|
-
|
357
|
-
def collect_status_responses task, status_list, options
|
358
|
-
collector = StatusResponseCollector.new(self, status_list, options.merge(task:task))
|
359
|
-
collector.collect
|
360
|
-
collector
|
361
|
-
end
|
362
|
-
|
363
|
-
def collect_command_responses task, command_list, options
|
364
|
-
collector = CommandResponseCollector.new(self, command_list, options.merge(task:task))
|
365
|
-
collector.collect
|
366
|
-
collector
|
367
|
-
end
|
368
|
-
|
369
|
-
def collect_aggregated_status task, options
|
370
|
-
collector = AggregatedStatusCollector.new(self, options.merge(task:task))
|
371
|
-
collector.collect
|
372
|
-
collector
|
373
|
-
end
|
374
362
|
end
|
375
363
|
end
|
@@ -138,16 +138,8 @@ module RSMP
|
|
138
138
|
"mId" => m_id,
|
139
139
|
})
|
140
140
|
|
141
|
-
|
142
|
-
|
143
|
-
task = @task.async do |task|
|
144
|
-
wait_for_acknowledgement task, options[:collect], m_id
|
145
|
-
end
|
146
|
-
send_message message, validate: options[:validate]
|
147
|
-
return message, task.wait
|
148
|
-
else
|
149
|
-
send_message message, validate: options[:validate]
|
150
|
-
message
|
141
|
+
send_and_optionally_collect message, options do |task|
|
142
|
+
wait_for_acknowledgement task, options[:collect], m_id
|
151
143
|
end
|
152
144
|
end
|
153
145
|
|
data/lib/rsmp/version.rb
CHANGED
data/lib/rsmp.rb
CHANGED
@@ -25,9 +25,7 @@ require 'rsmp/collect/filter'
|
|
25
25
|
require 'rsmp/collect/query'
|
26
26
|
require 'rsmp/collect/status_query'
|
27
27
|
require 'rsmp/collect/command_query'
|
28
|
-
require 'rsmp/collect/
|
29
|
-
require 'rsmp/collect/status_response_collector'
|
30
|
-
require 'rsmp/collect/status_update_collector'
|
28
|
+
require 'rsmp/collect/status_collector'
|
31
29
|
require 'rsmp/collect/command_response_collector'
|
32
30
|
require 'rsmp/collect/aggregated_status_collector'
|
33
31
|
require 'rsmp/component'
|
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.8.
|
4
|
+
version: 0.8.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Emil Tin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-01-
|
11
|
+
date: 2022-01-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: async
|
@@ -217,10 +217,8 @@ files:
|
|
217
217
|
- lib/rsmp/collect/notifier.rb
|
218
218
|
- lib/rsmp/collect/query.rb
|
219
219
|
- lib/rsmp/collect/state_collector.rb
|
220
|
+
- lib/rsmp/collect/status_collector.rb
|
220
221
|
- lib/rsmp/collect/status_query.rb
|
221
|
-
- lib/rsmp/collect/status_response_collector.rb
|
222
|
-
- lib/rsmp/collect/status_update_collector.rb
|
223
|
-
- lib/rsmp/collect/status_update_or_response_collector.rb
|
224
222
|
- lib/rsmp/component.rb
|
225
223
|
- lib/rsmp/components.rb
|
226
224
|
- lib/rsmp/convert/export/json_schema.rb
|
@@ -1,11 +0,0 @@
|
|
1
|
-
module RSMP
|
2
|
-
# Class for waiting for specific status responses
|
3
|
-
class StatusResponseCollector < StatusUpdateOrResponseCollector
|
4
|
-
def initialize proxy, want, options={}
|
5
|
-
super proxy, want, options.merge(
|
6
|
-
type: ['StatusResponse','MessageNotAck'],
|
7
|
-
title: 'status response'
|
8
|
-
)
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
module RSMP
|
2
|
-
# Class for waiting for specific status responses
|
3
|
-
class StatusUpdateCollector < StatusUpdateOrResponseCollector
|
4
|
-
def initialize proxy, want, options={}
|
5
|
-
super proxy, want, options.merge(
|
6
|
-
type: ['StatusUpdate','MessageNotAck'],
|
7
|
-
title:'status update'
|
8
|
-
)
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|