Class: RSMP::Validator::Tester
- Inherits:
-
Object
- Object
- RSMP::Validator::Tester
- Includes:
- Log
- Defined in:
- lib/rsmp/validator/tester.rb
Overview
Base class for testing either a site or a supervisor. Handles running the corresponding local site/supervisor inside an Async reactor.
Direct Known Subclasses
Class Method Summary collapse
Instance Method Summary collapse
- #config ⇒ Object
-
#connected(options = {}) {|Async::Task.current, @node, @proxy| ... } ⇒ Object
Ensures that the site is connected.
-
#disconnected {|Async::Task.current| ... } ⇒ Object
Disconnects the site if connected before calling the block.
-
#isolated(options = {}) {|Async::Task.current, @node, @proxy| ... } ⇒ Object
Like connected, except that the connection is closed after the test.
-
#reconnected(options = {}) {|Async::Task.current, @node, @proxy| ... } ⇒ Object
Disconnects the site if connected, then waits until the site is connected before calling the block.
-
#stop(why = nil) ⇒ Object
Stop the rsmp supervisor.
Methods included from Log
Class Method Details
.sentinel_errors ⇒ Object
11 12 13 |
# File 'lib/rsmp/validator/tester.rb', line 11 def self.sentinel_errors @sentinel_errors ||= [] end |
Instance Method Details
#config ⇒ Object
15 16 17 |
# File 'lib/rsmp/validator/tester.rb', line 15 def config RSMP::Validator.config end |
#connected(options = {}) {|Async::Task.current, @node, @proxy| ... } ⇒ Object
Ensures that the site is connected. If the site is already connected, the block will be called immediately. Otherwise waits until the site is connected before calling the block.
22 23 24 25 26 |
# File 'lib/rsmp/validator/tester.rb', line 22 def connected( = {}) start , 'Connecting' wait_for_proxy yield Async::Task.current, @node, @proxy end |
#disconnected {|Async::Task.current| ... } ⇒ Object
Disconnects the site if connected before calling the block.
47 48 49 50 |
# File 'lib/rsmp/validator/tester.rb', line 47 def disconnected stop 'Disconnecting' yield Async::Task.current end |
#isolated(options = {}) {|Async::Task.current, @node, @proxy| ... } ⇒ Object
Like connected, except that the connection is closed after the test.
38 39 40 41 42 43 44 |
# File 'lib/rsmp/validator/tester.rb', line 38 def isolated( = {}) stop 'Isolating' start , 'Connecting' wait_for_proxy yield Async::Task.current, @node, @proxy stop 'Isolating' end |
#reconnected(options = {}) {|Async::Task.current, @node, @proxy| ... } ⇒ Object
Disconnects the site if connected, then waits until the site is connected before calling the block.
30 31 32 33 34 35 |
# File 'lib/rsmp/validator/tester.rb', line 30 def reconnected( = {}) stop 'Reconnecting' start wait_for_proxy yield Async::Task.current, @node, @proxy end |
#stop(why = nil) ⇒ Object
Stop the rsmp supervisor
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/rsmp/validator/tester.rb', line 53 def stop(why = nil) if @node log why if why @node.ignore_errors RSMP::DisconnectError do @node.stop end end @node = nil @proxy = nil end |