Class: RSMP::Node
- Inherits:
-
Object
- Object
- RSMP::Node
- Defined in:
- lib/rsmp/node/node.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#archive ⇒ Object
readonly
Returns the value of attribute archive.
-
#clock ⇒ Object
readonly
Returns the value of attribute clock.
-
#collector ⇒ Object
readonly
Returns the value of attribute collector.
-
#deferred ⇒ Object
readonly
Returns the value of attribute deferred.
-
#error_queue ⇒ Object
readonly
Returns the value of attribute error_queue.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#task ⇒ Object
readonly
Returns the value of attribute task.
Instance Method Summary collapse
- #author ⇒ Object
- #check_required_settings(settings, required) ⇒ Object
- #clear_deferred ⇒ Object
- #defer(key, item = nil) ⇒ Object
- #distribute_error(error, options = {}) ⇒ Object
- #do_deferred(key, item = nil) ⇒ Object
- #ignore_errors(classes) ⇒ Object
-
#initialize(options = {}) ⇒ Node
constructor
A new instance of Node.
- #now ⇒ Object
- #process_deferred ⇒ Object
-
#stop_subtasks ⇒ Object
stop proxies, then call super.
Methods included from Task
#initialize_task, #restart, #run, #start, #stop, #stop_task, #task_status, #wait, #wait_for_condition
Methods included from Inspect
Methods included from Logging
Constructor Details
#initialize(options = {}) ⇒ Node
Returns a new instance of Node.
11 12 13 14 15 16 17 18 19 |
# File 'lib/rsmp/node/node.rb', line 11 def initialize( = {}) initialize_logging initialize_task @deferred = [] @clock = Clock.new @error_queue = Async::Queue.new @ignore_errors = [] @collect = [:collect] end |
Instance Attribute Details
#archive ⇒ Object (readonly)
Returns the value of attribute archive.
9 10 11 |
# File 'lib/rsmp/node/node.rb', line 9 def archive @archive end |
#clock ⇒ Object (readonly)
Returns the value of attribute clock.
9 10 11 |
# File 'lib/rsmp/node/node.rb', line 9 def clock @clock end |
#collector ⇒ Object (readonly)
Returns the value of attribute collector.
9 10 11 |
# File 'lib/rsmp/node/node.rb', line 9 def collector @collector end |
#deferred ⇒ Object (readonly)
Returns the value of attribute deferred.
9 10 11 |
# File 'lib/rsmp/node/node.rb', line 9 def deferred @deferred end |
#error_queue ⇒ Object (readonly)
Returns the value of attribute error_queue.
9 10 11 |
# File 'lib/rsmp/node/node.rb', line 9 def error_queue @error_queue end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
9 10 11 |
# File 'lib/rsmp/node/node.rb', line 9 def logger @logger end |
#task ⇒ Object (readonly)
Returns the value of attribute task.
9 10 11 |
# File 'lib/rsmp/node/node.rb', line 9 def task @task end |
Instance Method Details
#author ⇒ Object
76 77 78 |
# File 'lib/rsmp/node/node.rb', line 76 def site_id end |
#check_required_settings(settings, required) ⇒ Object
68 69 70 71 72 73 74 |
# File 'lib/rsmp/node/node.rb', line 68 def check_required_settings(settings, required) raise ArgumentError, 'Settings is empty' unless settings required.each do |setting| raise ArgumentError, "Missing setting: #{setting}" unless settings.include? setting.to_s end end |
#clear_deferred ⇒ Object
64 65 66 |
# File 'lib/rsmp/node/node.rb', line 64 def clear_deferred @deferred.clear end |
#defer(key, item = nil) ⇒ Object
50 51 52 |
# File 'lib/rsmp/node/node.rb', line 50 def defer(key, item = nil) @deferred << [key, item] end |
#distribute_error(error, options = {}) ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'lib/rsmp/node/node.rb', line 40 def distribute_error(error, = {}) return if @ignore_errors.find { |klass| error.is_a? klass } if [:level] == :internal log ["#{error} in task: #{Async::Task.current}", error.backtrace].flatten.join("\n"), level: :error end @error_queue.enqueue error end |
#do_deferred(key, item = nil) ⇒ Object
62 |
# File 'lib/rsmp/node/node.rb', line 62 def do_deferred(key, item = nil); end |
#ignore_errors(classes) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/rsmp/node/node.rb', line 32 def ignore_errors(classes) was = @ignore_errors @ignore_errors = [classes].flatten yield ensure @ignore_errors = was end |
#now ⇒ Object
21 22 23 |
# File 'lib/rsmp/node/node.rb', line 21 def now clock.now end |
#process_deferred ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/rsmp/node/node.rb', line 54 def process_deferred cloned = @deferred.clone # clone in case do_deferred restarts the current task @deferred.clear cloned.each do |pair| do_deferred pair.first, pair.last end end |
#stop_subtasks ⇒ Object
stop proxies, then call super
26 27 28 29 30 |
# File 'lib/rsmp/node/node.rb', line 26 def stop_subtasks @proxies.each(&:stop) @proxies.clear super end |