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
Constant Summary
Constants inherited from Serializable
Serializable::LEGACY_TIME_FORMAT, Serializable::TIME_FORMAT
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.
-
#delayed_events ⇒ Object
readonly
Returns the value of attribute delayed_events.
-
#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
-
#queue ⇒ Object
readonly
Returns the value of attribute queue.
-
#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
-
#==(other) ⇒ Object
rubocop:enable Metrics/ParameterLists.
-
#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, queue = nil) ⇒ Abstract
constructor
rubocop:disable Metrics/ParameterLists.
- #mark_to_skip ⇒ Object
- #persistence ⇒ Object
- #phase ⇒ Object
- #progress_done ⇒ Object
- #save(conditions = {}) ⇒ Object
- #skippable? ⇒ Boolean
- #to_hash ⇒ Object
- #to_s ⇒ Object
- #with_sub_plans? ⇒ Boolean
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, queue = nil) ⇒ Abstract
rubocop:disable Metrics/ParameterLists
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 44 45 46 47 48 49 |
# File 'lib/dynflow/execution_plan/steps/abstract.rb', line 14 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, queue = 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 @queue = Type! queue, Symbol, 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.
9 10 11 |
# File 'lib/dynflow/execution_plan/steps/abstract.rb', line 9 def action_class @action_class end |
#action_id ⇒ Object (readonly)
Returns the value of attribute action_id.
9 10 11 |
# File 'lib/dynflow/execution_plan/steps/abstract.rb', line 9 def action_id @action_id end |
#delayed_events ⇒ Object (readonly)
Returns the value of attribute delayed_events.
9 10 11 |
# File 'lib/dynflow/execution_plan/steps/abstract.rb', line 9 def delayed_events @delayed_events end |
#ended_at ⇒ Object (readonly)
Returns the value of attribute ended_at.
9 10 11 |
# File 'lib/dynflow/execution_plan/steps/abstract.rb', line 9 def ended_at @ended_at end |
#error ⇒ Object
Returns the value of attribute error.
11 12 13 |
# File 'lib/dynflow/execution_plan/steps/abstract.rb', line 11 def error @error end |
#execution_plan_id ⇒ Object (readonly)
Returns the value of attribute execution_plan_id.
9 10 11 |
# File 'lib/dynflow/execution_plan/steps/abstract.rb', line 9 def execution_plan_id @execution_plan_id end |
#execution_time ⇒ Object (readonly)
Returns the value of attribute execution_time.
9 10 11 |
# File 'lib/dynflow/execution_plan/steps/abstract.rb', line 9 def execution_time @execution_time end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
9 10 11 |
# File 'lib/dynflow/execution_plan/steps/abstract.rb', line 9 def id @id end |
#progress_weight ⇒ Object
119 120 121 |
# File 'lib/dynflow/execution_plan/steps/abstract.rb', line 119 def progress_weight @progress_weight || 0 # 0 means not calculated yet end |
#queue ⇒ Object (readonly)
Returns the value of attribute queue.
9 10 11 |
# File 'lib/dynflow/execution_plan/steps/abstract.rb', line 9 def queue @queue end |
#real_time ⇒ Object (readonly)
Returns the value of attribute real_time.
9 10 11 |
# File 'lib/dynflow/execution_plan/steps/abstract.rb', line 9 def real_time @real_time end |
#started_at ⇒ Object (readonly)
Returns the value of attribute started_at.
9 10 11 |
# File 'lib/dynflow/execution_plan/steps/abstract.rb', line 9 def started_at @started_at end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
9 10 11 |
# File 'lib/dynflow/execution_plan/steps/abstract.rb', line 9 def state @state end |
#world ⇒ Object (readonly)
Returns the value of attribute world.
9 10 11 |
# File 'lib/dynflow/execution_plan/steps/abstract.rb', line 9 def world @world end |
Class Method Details
.states ⇒ Object
76 77 78 |
# File 'lib/dynflow/execution_plan/steps/abstract.rb', line 76 def self.states @states ||= [:scheduling, :pending, :running, :success, :suspended, :skipping, :skipped, :error, :cancelled] end |
Instance Method Details
#==(other) ⇒ Object
rubocop:enable Metrics/ParameterLists
52 53 54 |
# File 'lib/dynflow/execution_plan/steps/abstract.rb', line 52 def ==(other) other.class == self.class && other.execution_plan_id == self.execution_plan_id && other.id == self.id end |
#action(execution_plan) ⇒ Action
details, human outputs, etc.
127 128 129 |
# File 'lib/dynflow/execution_plan/steps/abstract.rb', line 127 def action(execution_plan) world.persistence.load_action_for_presentation(execution_plan, action_id, self) end |
#action_logger ⇒ Object
56 57 58 |
# File 'lib/dynflow/execution_plan/steps/abstract.rb', line 56 def action_logger @world.action_logger end |
#cancellable? ⇒ Boolean
135 136 137 |
# File 'lib/dynflow/execution_plan/steps/abstract.rb', line 135 def cancellable? false end |
#default_progress_done ⇒ Object
in specific states it’s clear what progress the step is in
110 111 112 113 114 115 116 117 |
# File 'lib/dynflow/execution_plan/steps/abstract.rb', line 110 def default_progress_done case self.state when :success, :skipped 1 when :pending 0 end end |
#execute(*args) ⇒ Object
80 81 82 |
# File 'lib/dynflow/execution_plan/steps/abstract.rb', line 80 def execute(*args) raise NotImplementedError end |
#mark_to_skip ⇒ Object
64 65 66 |
# File 'lib/dynflow/execution_plan/steps/abstract.rb', line 64 def mark_to_skip raise NotImplementedError end |
#persistence ⇒ Object
68 69 70 |
# File 'lib/dynflow/execution_plan/steps/abstract.rb', line 68 def persistence world.persistence end |
#phase ⇒ Object
60 61 62 |
# File 'lib/dynflow/execution_plan/steps/abstract.rb', line 60 def phase raise NotImplementedError end |
#progress_done ⇒ Object
105 106 107 |
# File 'lib/dynflow/execution_plan/steps/abstract.rb', line 105 def progress_done default_progress_done || @progress_done || 0 end |
#save(conditions = {}) ⇒ Object
72 73 74 |
# File 'lib/dynflow/execution_plan/steps/abstract.rb', line 72 def save(conditions = {}) persistence.save_step(self, conditions) end |
#skippable? ⇒ Boolean
131 132 133 |
# File 'lib/dynflow/execution_plan/steps/abstract.rb', line 131 def skippable? self.state == :error end |
#to_hash ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/dynflow/execution_plan/steps/abstract.rb', line 88 def to_hash recursive_to_hash execution_plan_uuid: 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: started_at, ended_at: ended_at, execution_time: execution_time, real_time: real_time, progress_done: progress_done, progress_weight: progress_weight, queue: queue end |
#to_s ⇒ Object
84 85 86 |
# File 'lib/dynflow/execution_plan/steps/abstract.rb', line 84 def to_s "#<#{self.class.name}:#{execution_plan_id}:#{id}>" end |
#with_sub_plans? ⇒ Boolean
139 140 141 |
# File 'lib/dynflow/execution_plan/steps/abstract.rb', line 139 def with_sub_plans? false end |