Class: Validator::AutoNode
- Inherits:
-
Object
- Object
- Validator::AutoNode
- Defined in:
- spec/support/auto_node.rb
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 This method should be called from within the reactor context.
-
#stop ⇒ Object
Stop the auto node.
Constructor Details
#initialize ⇒ AutoNode
Returns a new instance of AutoNode.
13 14 15 16 |
# File 'spec/support/auto_node.rb', line 13 def initialize @node = nil @task = nil end |
Instance Attribute Details
#node ⇒ Object (readonly)
Returns the value of attribute node.
11 12 13 |
# File 'spec/support/auto_node.rb', line 11 def node @node end |
#task ⇒ Object (readonly)
Returns the value of attribute task.
11 12 13 |
# File 'spec/support/auto_node.rb', line 11 def task @task end |
Instance Method Details
#running? ⇒ Boolean
Check if the auto node is running
49 50 51 |
# File 'spec/support/auto_node.rb', line 49 def running? @node && @task end |
#start ⇒ Object
Start the auto node inside the async reactor This method should be called from within the reactor context
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'spec/support/auto_node.rb', line 20 def start return if @node @node = build_node # Run the node in a separate async task within the same reactor @task = Async do |task| task.annotate "auto_#{node_type}" Validator::Log.log_block("Starting auto #{node_type}") do @node.start # This will keep running until stopped end end end |
#stop ⇒ Object
Stop the auto node
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'spec/support/auto_node.rb', line 35 def stop if @node Validator::Log.log "Stopping auto #{node_type}", level: :info @node.ignore_errors RSMP::DisconnectError do @node.stop end end @task&.stop ensure @task = nil @node = nil end |