Class: Tasker::Orchestration::TaskFinalizer::DelayCalculator
- Inherits:
-
Object
- Object
- Tasker::Orchestration::TaskFinalizer::DelayCalculator
- Defined in:
- lib/tasker/orchestration/task_finalizer.rb
Overview
Service class to calculate delays Reduces complexity by organizing delay calculation logic
Class Method Summary collapse
-
.backoff_config ⇒ Tasker::Types::BackoffConfig
Get backoff configuration with memoization.
-
.calculate_reenqueue_delay(context) ⇒ Integer
Calculate intelligent re-enqueue delay based on execution context and step backoff timing.
-
.default_delay ⇒ Object
Default delay for unclear states or no context.
-
.delay_map ⇒ Object
Frozen hash for O(1) delay lookups with descriptive comments Values now use configurable backoff progression.
-
.maximum_delay ⇒ Object
Maximum delay cap.
Class Method Details
.backoff_config ⇒ Tasker::Types::BackoffConfig
Get backoff configuration with memoization
442 443 444 |
# File 'lib/tasker/orchestration/task_finalizer.rb', line 442 def backoff_config @backoff_config ||= Tasker::Configuration.configuration.backoff end |
.calculate_reenqueue_delay(context) ⇒ Integer
Calculate intelligent re-enqueue delay based on execution context and step backoff timing
This method considers the actual backoff timing of failed steps to avoid reenqueuing tasks before any steps are ready for retry.
473 474 475 476 477 478 479 480 481 482 483 |
# File 'lib/tasker/orchestration/task_finalizer.rb', line 473 def calculate_reenqueue_delay(context) return default_delay unless context # For waiting_for_dependencies status, check if we have failed steps with backoff timing if context.execution_status == Constants::TaskExecution::ExecutionStatus::WAITING_FOR_DEPENDENCIES optimal_delay = calculate_optimal_backoff_delay(context.task_id) return optimal_delay if optimal_delay.positive? end delay_map.fetch(context.execution_status, default_delay) end |
.default_delay ⇒ Object
Default delay for unclear states or no context
457 458 459 |
# File 'lib/tasker/orchestration/task_finalizer.rb', line 457 def default_delay backoff_config.default_reenqueue_delay end |
.delay_map ⇒ Object
Frozen hash for O(1) delay lookups with descriptive comments Values now use configurable backoff progression
448 449 450 451 452 453 454 |
# File 'lib/tasker/orchestration/task_finalizer.rb', line 448 def delay_map @delay_map ||= { Constants::TaskExecution::ExecutionStatus::HAS_READY_STEPS => backoff_config.reenqueue_delays[:has_ready_steps], Constants::TaskExecution::ExecutionStatus::WAITING_FOR_DEPENDENCIES => backoff_config.reenqueue_delays[:waiting_for_dependencies], Constants::TaskExecution::ExecutionStatus::PROCESSING => backoff_config.reenqueue_delays[:processing] }.freeze end |
.maximum_delay ⇒ Object
Maximum delay cap
462 463 464 |
# File 'lib/tasker/orchestration/task_finalizer.rb', line 462 def maximum_delay backoff_config.max_backoff_seconds end |