Module: Dynflow::Action::Rescue
- Included in:
- Dynflow::Action
- Defined in:
- lib/dynflow/action/rescue.rb
Constant Summary collapse
- Strategy =
Algebrick.type do variants Skip = atom, Pause = atom end
- SuggestedStrategy =
Algebrick.type do fields! action: Action, strategy: Strategy end
Instance Method Summary collapse
-
#combine_suggested_strategies(suggested_strategies) ⇒ Object
Override when different appraoch should be taken for combining the suggested strategies.
-
#rescue_strategy ⇒ Object
What strategy should be used for rescuing from error in the action or its sub actions.
-
#rescue_strategy_for_planned_action(action) ⇒ Object
Override when the action should override the rescue strategy of an action it planned.
-
#rescue_strategy_for_self ⇒ Object
Override when another strategy should be used for rescuing from error on the action.
Instance Method Details
#combine_suggested_strategies(suggested_strategies) ⇒ Object
Override when different appraoch should be taken for combining the suggested strategies
49 50 51 52 53 54 55 56 |
# File 'lib/dynflow/action/rescue.rb', line 49 def combine_suggested_strategies(suggested_strategies) if suggested_strategies.empty? || suggested_strategies.all? { |suggested_strategy| suggested_strategy.strategy == Skip } return Skip else return Pause end end |
#rescue_strategy ⇒ Object
What strategy should be used for rescuing from error in the action or its sub actions
When determining the strategy, the algorithm starts from the entry action that by default takes the strategy from #rescue_strategy_for_self and #rescue_strategy_for_planned_actions and combines them together.
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/dynflow/action/rescue.rb', line 21 def rescue_strategy suggested_strategies = [] if self.steps.compact.any? { |step| step.state == :error } suggested_strategies << SuggestedStrategy[self, rescue_strategy_for_self] end self.planned_actions.each do |planned_action| suggested_strategies << SuggestedStrategy[planned_action, rescue_strategy_for_planned_action(planned_action)] end combine_suggested_strategies(suggested_strategies) end |
#rescue_strategy_for_planned_action(action) ⇒ Object
Override when the action should override the rescue strategy of an action it planned
43 44 45 |
# File 'lib/dynflow/action/rescue.rb', line 43 def rescue_strategy_for_planned_action(action) action.rescue_strategy end |
#rescue_strategy_for_self ⇒ Object
Override when another strategy should be used for rescuing from error on the action
37 38 39 |
# File 'lib/dynflow/action/rescue.rb', line 37 def rescue_strategy_for_self return Pause end |