rsmp 0.1.13 → 0.1.29
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 +4 -4
- data/.gitignore +1 -0
- data/.gitmodules +0 -4
- data/Gemfile.lock +52 -52
- data/README.md +7 -1
- data/config/supervisor.yaml +9 -15
- data/config/tlc.yaml +26 -28
- data/documentation/classes_and_modules.md +65 -0
- data/documentation/message_distribution.md +23 -0
- data/lib/rsmp.rb +14 -5
- data/lib/rsmp/archive.rb +23 -22
- data/lib/rsmp/cli.rb +133 -102
- data/lib/rsmp/collector.rb +102 -0
- data/lib/rsmp/component.rb +13 -4
- data/lib/rsmp/{site_base.rb → components.rb} +8 -6
- 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/error.rb +1 -1
- data/lib/rsmp/inspect.rb +46 -0
- data/lib/rsmp/listener.rb +23 -0
- data/lib/rsmp/logger.rb +6 -4
- data/lib/rsmp/{base.rb → logging.rb} +3 -3
- data/lib/rsmp/message.rb +46 -32
- data/lib/rsmp/node.rb +47 -12
- data/lib/rsmp/notifier.rb +29 -0
- data/lib/rsmp/proxy.rb +143 -71
- data/lib/rsmp/rsmp.rb +34 -23
- data/lib/rsmp/site.rb +35 -42
- data/lib/rsmp/site_proxy.rb +182 -78
- data/lib/rsmp/site_proxy_wait.rb +206 -0
- data/lib/rsmp/supervisor.rb +85 -49
- data/lib/rsmp/supervisor_proxy.rb +80 -34
- data/lib/rsmp/tlc.rb +761 -86
- data/lib/rsmp/version.rb +1 -1
- data/lib/rsmp/wait.rb +7 -8
- data/rsmp.gemspec +9 -21
- metadata +37 -142
- data/config/site.yaml +0 -40
- data/lib/rsmp/probe.rb +0 -114
- data/lib/rsmp/probe_collection.rb +0 -28
- data/lib/rsmp/supervisor_base.rb +0 -10
data/lib/rsmp/probe.rb
DELETED
@@ -1,114 +0,0 @@
|
|
1
|
-
# A probe checks incoming messages and store matches
|
2
|
-
# Once it has collected what it needs, it triggers a condition variable
|
3
|
-
# and the client wakes up.
|
4
|
-
|
5
|
-
module RSMP
|
6
|
-
class Probe
|
7
|
-
attr_reader :condition, :items, :done
|
8
|
-
|
9
|
-
# block should send a message and return message just sent
|
10
|
-
def self.collect_response proxy, options={}, &block
|
11
|
-
from = proxy.archive.current_index
|
12
|
-
sent = yield
|
13
|
-
raise RuntimeError unless sent && sent[:message].is_a?(RSMP::Message)
|
14
|
-
item = proxy.archive.capture(options.merge(from: from+1, num: 1, with_message: true)) do |item|
|
15
|
-
["CommandResponse","StatusResponse","MessageNotAck"].include?(item[:message].type)
|
16
|
-
end
|
17
|
-
if item
|
18
|
-
item[:message]
|
19
|
-
else
|
20
|
-
nil
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
|
25
|
-
def initialize archive
|
26
|
-
raise ArgumentError.new("Archive expected") unless archive.is_a? Archive
|
27
|
-
@archive = archive
|
28
|
-
@items = []
|
29
|
-
@condition = Async::Notification.new
|
30
|
-
end
|
31
|
-
|
32
|
-
def capture task, options={}, &block
|
33
|
-
@options = options
|
34
|
-
@block = block
|
35
|
-
@num = options[:num]
|
36
|
-
|
37
|
-
if options[:earliest]
|
38
|
-
from = find_timestamp_index options[:earliest]
|
39
|
-
backscan from
|
40
|
-
elsif options[:from]
|
41
|
-
backscan options[:from]
|
42
|
-
end
|
43
|
-
|
44
|
-
# if backscan didn't find enough items, then
|
45
|
-
# insert ourself as probe and sleep until enough items are captured
|
46
|
-
if @items.size < @num
|
47
|
-
begin
|
48
|
-
@archive.probes.add self
|
49
|
-
task.with_timeout(options[:timeout]) do
|
50
|
-
@condition.wait
|
51
|
-
end
|
52
|
-
ensure
|
53
|
-
@archive.probes.remove self
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
if @num == 1
|
58
|
-
@items.first # if one item was requested, return item instead of array
|
59
|
-
else
|
60
|
-
@items[0..@num-1] # return array, but ensure we never return more than requested
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
def find_timestamp_index earliest
|
65
|
-
(0..@archive.items.size).bsearch do |i| # use binary search to find item index
|
66
|
-
@archive.items[i][:timestamp] >= earliest
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
def backscan from
|
71
|
-
from.upto(@archive.items.size-1) do |i|
|
72
|
-
return if process @archive.items[i]
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
def reset
|
77
|
-
@items.clear
|
78
|
-
@done = false
|
79
|
-
end
|
80
|
-
|
81
|
-
def process item
|
82
|
-
raise ArgumentError unless item
|
83
|
-
return true if @done
|
84
|
-
if matches? item
|
85
|
-
@items << item
|
86
|
-
if @num && @items.size >= @num
|
87
|
-
@done = true
|
88
|
-
@condition.signal
|
89
|
-
return true
|
90
|
-
end
|
91
|
-
end
|
92
|
-
false
|
93
|
-
end
|
94
|
-
|
95
|
-
def matches? item
|
96
|
-
raise ArgumentError unless item
|
97
|
-
|
98
|
-
if @options[:type]
|
99
|
-
return false if item[:message] == nil
|
100
|
-
if @options[:type].is_a? Array
|
101
|
-
return false unless @options[:type].include? item[:message].type
|
102
|
-
else
|
103
|
-
return false unless item[:message].type == @options[:type]
|
104
|
-
end
|
105
|
-
end
|
106
|
-
return if @options[:level] && item[:level] != @options[:level]
|
107
|
-
return false if @options[:with_message] && !(item[:direction] && item[:message])
|
108
|
-
if @block
|
109
|
-
return false if @block.call(item) == false
|
110
|
-
end
|
111
|
-
true
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
# Collection of probes
|
2
|
-
|
3
|
-
module RSMP
|
4
|
-
class ProbeCollection
|
5
|
-
|
6
|
-
def initialize
|
7
|
-
@probes = []
|
8
|
-
end
|
9
|
-
|
10
|
-
def add probe
|
11
|
-
raise ArgumentError unless probe
|
12
|
-
@probes << probe
|
13
|
-
end
|
14
|
-
|
15
|
-
def remove probe
|
16
|
-
raise ArgumentError unless probe
|
17
|
-
@probes.delete probe
|
18
|
-
end
|
19
|
-
|
20
|
-
def process item
|
21
|
-
@probes.each { |probe| probe.process item }
|
22
|
-
end
|
23
|
-
|
24
|
-
def clear
|
25
|
-
@probes.each { |probe| probe.clear }
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|