Class: Dynflow::ExecutionPlan::Steps::Abstract
- Inherits:
-
Serializable
- Object
- Serializable
- Dynflow::ExecutionPlan::Steps::Abstract
- Includes:
- Algebrick::TypeCheck, Stateful
- Defined in:
- lib/dynflow/execution_plan/steps/abstract.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#action_class ⇒ Object
readonly
Returns the value of attribute action_class.
-
#action_id ⇒ Object
readonly
Returns the value of attribute action_id.
-
#ended_at ⇒ Object
readonly
Returns the value of attribute ended_at.
-
#error ⇒ Object
Returns the value of attribute error.
-
#execution_plan_id ⇒ Object
readonly
Returns the value of attribute execution_plan_id.
-
#execution_time ⇒ Object
readonly
Returns the value of attribute execution_time.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
- #progress_weight ⇒ Object
-
#real_time ⇒ Object
readonly
Returns the value of attribute real_time.
-
#started_at ⇒ Object
readonly
Returns the value of attribute started_at.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
-
#world ⇒ Object
readonly
Returns the value of attribute world.
Class Method Summary collapse
Instance Method Summary collapse
-
#action(execution_plan) ⇒ Action
details, human outputs, etc.
- #action_logger ⇒ Object
- #cancellable? ⇒ Boolean
-
#default_progress_done ⇒ Object
in specific states it’s clear what progress the step is in.
- #execute(*args) ⇒ Object
-
#initialize(execution_plan_id, id, state, action_class, action_id, error, world, started_at = nil, ended_at = nil, execution_time = 0.0, real_time = 0.0, progress_done = nil, progress_weight = nil) ⇒ Abstract
constructor
A new instance of Abstract.
- #mark_to_skip ⇒ Object
- #persistence ⇒ Object
- #phase ⇒ Object
- #progress_done ⇒ Object
- #save ⇒ Object
- #skippable? ⇒ Boolean
- #to_hash ⇒ Object
- #to_s ⇒ Object
Methods included from Stateful
included, #set_state, #state_transitions, #states
Methods inherited from Serializable
Constructor Details
#initialize(execution_plan_id, id, state, action_class, action_id, error, world, started_at = nil, ended_at = nil, execution_time = 0.0, real_time = 0.0, progress_done = nil, progress_weight = nil) ⇒ Abstract
Returns a new instance of Abstract.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/dynflow/execution_plan/steps/abstract.rb', line 11 def initialize(execution_plan_id, id, state, action_class, action_id, error, world, started_at = nil, ended_at = nil, execution_time = 0.0, real_time = 0.0, progress_done = nil, progress_weight = nil) @id = id || raise(ArgumentError, 'missing id') @execution_plan_id = Type! execution_plan_id, String @world = Type! world, World @error = Type! error, ExecutionPlan::Steps::Error, NilClass @started_at = Type! started_at, Time, NilClass @ended_at = Type! ended_at, Time, NilClass @execution_time = Type! execution_time, Numeric @real_time = Type! real_time, Numeric @progress_done = Type! progress_done, Numeric, NilClass @progress_weight = Type! progress_weight, Numeric, NilClass self.state = state.to_sym Child! action_class, Action @action_class = action_class @action_id = action_id || raise(ArgumentError, 'missing action_id') end |
Instance Attribute Details
#action_class ⇒ Object (readonly)
Returns the value of attribute action_class.
7 8 9 |
# File 'lib/dynflow/execution_plan/steps/abstract.rb', line 7 def action_class @action_class end |
#action_id ⇒ Object (readonly)
Returns the value of attribute action_id.
7 8 9 |
# File 'lib/dynflow/execution_plan/steps/abstract.rb', line 7 def action_id @action_id end |
#ended_at ⇒ Object (readonly)
Returns the value of attribute ended_at.
7 8 9 |
# File 'lib/dynflow/execution_plan/steps/abstract.rb', line 7 def ended_at @ended_at end |
#error ⇒ Object
Returns the value of attribute error.
9 10 11 |
# File 'lib/dynflow/execution_plan/steps/abstract.rb', line 9 def error @error end |
#execution_plan_id ⇒ Object (readonly)
Returns the value of attribute execution_plan_id.
7 8 9 |
# File 'lib/dynflow/execution_plan/steps/abstract.rb', line 7 def execution_plan_id @execution_plan_id end |
#execution_time ⇒ Object (readonly)
Returns the value of attribute execution_time.
7 8 9 |
# File 'lib/dynflow/execution_plan/steps/abstract.rb', line 7 def execution_time @execution_time end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
7 8 9 |
# File 'lib/dynflow/execution_plan/steps/abstract.rb', line 7 def id @id end |
#progress_weight ⇒ Object
107 108 109 |
# File 'lib/dynflow/execution_plan/steps/abstract.rb', line 107 def progress_weight @progress_weight || 0 # 0 means not calculated yet end |
#real_time ⇒ Object (readonly)
Returns the value of attribute real_time.
7 8 9 |
# File 'lib/dynflow/execution_plan/steps/abstract.rb', line 7 def real_time @real_time end |
#started_at ⇒ Object (readonly)
Returns the value of attribute started_at.
7 8 9 |
# File 'lib/dynflow/execution_plan/steps/abstract.rb', line 7 def started_at @started_at end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
7 8 9 |
# File 'lib/dynflow/execution_plan/steps/abstract.rb', line 7 def state @state end |
#world ⇒ Object (readonly)
Returns the value of attribute world.
7 8 9 |
# File 'lib/dynflow/execution_plan/steps/abstract.rb', line 7 def world @world end |
Class Method Details
.states ⇒ Object
65 66 67 |
# File 'lib/dynflow/execution_plan/steps/abstract.rb', line 65 def self.states @states ||= [:pending, :running, :success, :suspended, :skipping, :skipped, :error] end |
Instance Method Details
#action(execution_plan) ⇒ Action
details, human outputs, etc.
115 116 117 118 |
# File 'lib/dynflow/execution_plan/steps/abstract.rb', line 115 def action(execution_plan) attributes = world.persistence.adapter.load_action(execution_plan_id, action_id) Action.from_hash(attributes.update(phase: Action::Present, execution_plan: execution_plan), world) end |
#action_logger ⇒ Object
45 46 47 |
# File 'lib/dynflow/execution_plan/steps/abstract.rb', line 45 def action_logger @world.action_logger end |
#cancellable? ⇒ Boolean
124 125 126 |
# File 'lib/dynflow/execution_plan/steps/abstract.rb', line 124 def cancellable? false end |
#default_progress_done ⇒ Object
in specific states it’s clear what progress the step is in
98 99 100 101 102 103 104 105 |
# File 'lib/dynflow/execution_plan/steps/abstract.rb', line 98 def default_progress_done case self.state when :success, :skipped 1 when :pending 0 end end |
#execute(*args) ⇒ Object
69 70 71 |
# File 'lib/dynflow/execution_plan/steps/abstract.rb', line 69 def execute(*args) raise NotImplementedError end |
#mark_to_skip ⇒ Object
53 54 55 |
# File 'lib/dynflow/execution_plan/steps/abstract.rb', line 53 def mark_to_skip raise NotImplementedError end |
#persistence ⇒ Object
57 58 59 |
# File 'lib/dynflow/execution_plan/steps/abstract.rb', line 57 def persistence world.persistence end |
#phase ⇒ Object
49 50 51 |
# File 'lib/dynflow/execution_plan/steps/abstract.rb', line 49 def phase raise NotImplementedError end |
#progress_done ⇒ Object
93 94 95 |
# File 'lib/dynflow/execution_plan/steps/abstract.rb', line 93 def progress_done default_progress_done || @progress_done || 0 end |
#save ⇒ Object
61 62 63 |
# File 'lib/dynflow/execution_plan/steps/abstract.rb', line 61 def save persistence.save_step(self) end |
#skippable? ⇒ Boolean
120 121 122 |
# File 'lib/dynflow/execution_plan/steps/abstract.rb', line 120 def skippable? self.state == :error end |
#to_hash ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/dynflow/execution_plan/steps/abstract.rb', line 77 def to_hash recursive_to_hash execution_plan_id: execution_plan_id, id: id, state: state, class: self.class.to_s, action_class: action_class.to_s, action_id: action_id, error: error, started_at: time_to_str(started_at), ended_at: time_to_str(ended_at), execution_time: execution_time, real_time: real_time, progress_done: progress_done, progress_weight: progress_weight end |
#to_s ⇒ Object
73 74 75 |
# File 'lib/dynflow/execution_plan/steps/abstract.rb', line 73 def to_s "#<#{self.class.name}:#{execution_plan_id}:#{id}>" end |