Class: Orchestra::Execution::Operation
- Inherits:
-
Object
- Object
- Orchestra::Execution::Operation
- Extended by:
- Forwardable
- Includes:
- Observable
- Defined in:
- lib/orchestra/execution.rb
Instance Attribute Summary collapse
-
#conductor ⇒ Object
readonly
Returns the value of attribute conductor.
-
#input ⇒ Object
readonly
Returns the value of attribute input.
-
#node ⇒ Object
readonly
Returns the value of attribute node.
-
#registry ⇒ Object
readonly
Returns the value of attribute registry.
-
#run_list ⇒ Object
readonly
Returns the value of attribute run_list.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
Instance Method Summary collapse
- #ensure_inputs_are_present! ⇒ Object
- #execute ⇒ Object
-
#initialize(conductor, run_list, input, node) ⇒ Operation
constructor
A new instance of Operation.
- #output ⇒ Object
- #process(name, step) ⇒ Object
- #publish(event, *payload) ⇒ Object
- #thread_pool ⇒ Object
Constructor Details
#initialize(conductor, run_list, input, node) ⇒ Operation
Returns a new instance of Operation.
26 27 28 29 30 31 32 33 |
# File 'lib/orchestra/execution.rb', line 26 def initialize conductor, run_list, input, node @conductor = conductor @input = input.dup @node = node @run_list = run_list @registry = conductor.build_registry self @state = registry.merge input end |
Instance Attribute Details
#conductor ⇒ Object (readonly)
Returns the value of attribute conductor.
24 25 26 |
# File 'lib/orchestra/execution.rb', line 24 def conductor @conductor end |
#input ⇒ Object (readonly)
Returns the value of attribute input.
24 25 26 |
# File 'lib/orchestra/execution.rb', line 24 def input @input end |
#node ⇒ Object (readonly)
Returns the value of attribute node.
24 25 26 |
# File 'lib/orchestra/execution.rb', line 24 def node @node end |
#registry ⇒ Object (readonly)
Returns the value of attribute registry.
24 25 26 |
# File 'lib/orchestra/execution.rb', line 24 def registry @registry end |
#run_list ⇒ Object (readonly)
Returns the value of attribute run_list.
24 25 26 |
# File 'lib/orchestra/execution.rb', line 24 def run_list @run_list end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
24 25 26 |
# File 'lib/orchestra/execution.rb', line 24 def state @state end |
Instance Method Details
#ensure_inputs_are_present! ⇒ Object
58 59 60 61 62 |
# File 'lib/orchestra/execution.rb', line 58 def ensure_inputs_are_present! has_dep = state.method :[] missing_input = required_dependencies.reject &has_dep raise MissingInputError.new missing_input unless missing_input.empty? end |
#execute ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/orchestra/execution.rb', line 35 def execute publish :operation_entered, node, node.input if node ensure_inputs_are_present! run_list.each do |name, step| process name, step end publish :operation_exited, node, output if node output rescue => error publish :error_raised, error raise error end |
#output ⇒ Object
46 47 48 |
# File 'lib/orchestra/execution.rb', line 46 def output state.fetch run_list.result end |
#process(name, step) ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/orchestra/execution.rb', line 50 def process name, step output = Step.execute step, name, self state.merge! output rescue MissingProvisionError => error error.name = name.inspect raise error end |
#publish(event, *payload) ⇒ Object
64 65 66 67 |
# File 'lib/orchestra/execution.rb', line 64 def publish event, *payload changed notify_observers event, *payload end |
#thread_pool ⇒ Object
69 70 71 |
# File 'lib/orchestra/execution.rb', line 69 def thread_pool conductor.thread_pool end |