Class: RSMP::Validator::AutoNode
- Inherits:
-
Object
- Object
- RSMP::Validator::AutoNode
- Includes:
- Log
- Defined in:
- lib/rsmp/validator/auto_node.rb
Overview
Base class for automatically starting a local RSMP node (site or supervisor) when testing the validator or RSMP gem itself.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#node ⇒ Object
readonly
Returns the value of attribute node.
-
#task ⇒ Object
readonly
Returns the value of attribute task.
Instance Method Summary collapse
-
#initialize ⇒ AutoNode
constructor
A new instance of AutoNode.
-
#running? ⇒ Boolean
Check if the auto node is running.
-
#start ⇒ Object
Start the auto node inside the async reactor.
-
#stop ⇒ Object
Stop the auto node.
Methods included from Log
Constructor Details
#initialize ⇒ AutoNode
Returns a new instance of AutoNode.
12 13 14 15 |
# File 'lib/rsmp/validator/auto_node.rb', line 12 def initialize @node = nil @task = nil end |
Instance Attribute Details
#node ⇒ Object (readonly)
Returns the value of attribute node.
10 11 12 |
# File 'lib/rsmp/validator/auto_node.rb', line 10 def node @node end |
#task ⇒ Object (readonly)
Returns the value of attribute task.
10 11 12 |
# File 'lib/rsmp/validator/auto_node.rb', line 10 def task @task end |
Instance Method Details
#running? ⇒ Boolean
Check if the auto node is running
47 48 49 |
# File 'lib/rsmp/validator/auto_node.rb', line 47 def running? @node && @task end |
#start ⇒ Object
Start the auto node inside the async reactor
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/rsmp/validator/auto_node.rb', line 18 def start return if @node @node = build_node @task = Async do |task| task.annotate "auto_#{node_type}" log("Starting auto #{node_type}") @node.start rescue Async::TimeoutError raise RSMP::TimeoutError, "Timeout while starting auto #{node_type}" end end |
#stop ⇒ Object
Stop the auto node
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/rsmp/validator/auto_node.rb', line 33 def stop if @node log("Stopping auto #{node_type}") @node.ignore_errors RSMP::DisconnectError do @node.stop end end @task&.stop ensure @task = nil @node = nil end |