Module: Actions::RecurringAction
- Included in:
- CheckLongRunningTasks
- Defined in:
- app/lib/actions/recurring_action.rb
Class Method Summary collapse
-
.included(base) ⇒ Object
When included sets the base action to use the RecurringLogic middleware and configures #trigger_repeat to be called when appropriate to trigger the next repeat.
Instance Method Summary collapse
-
#trigger_repeat(execution_plan) ⇒ Object
Hook to be called when a repetition needs to be triggered.
Class Method Details
.included(base) ⇒ Object
When included sets the base action to use the RecurringLogic middleware and configures
#trigger_repeat to be called when appropriate to trigger the next repeat.
7 8 9 10 |
# File 'app/lib/actions/recurring_action.rb', line 7 def self.included(base) base.middleware.use Actions::Middleware::RecurringLogic base.execution_plan_hooks.use :trigger_repeat, :on => [:planned, :failure] end |
Instance Method Details
#trigger_repeat(execution_plan) ⇒ Object
Hook to be called when a repetition needs to be triggered. This either happens when the plan goes into planned state
or when it fails.
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/lib/actions/recurring_action.rb', line 14 def trigger_repeat(execution_plan) request_id = ::Logging.mdc['request'] ::Logging.mdc['request'] = SecureRandom.uuid if execution_plan.delay_record && recurring_logic_task_group args = execution_plan.delay_record.args logic = recurring_logic_task_group.recurring_logic task_start_at = [task.start_at, Time.zone.now].max logic.trigger_repeat_after(task_start_at, self.class, *args) end ensure ::Logging.mdc['request'] = request_id end |