Class: ChronoForge::Workflow
- Inherits:
-
ApplicationRecord
- Object
- ChronoForge::Workflow
- Defined in:
- lib/chrono_forge/workflow.rb
Instance Method Summary collapse
- #ensure_retryable! ⇒ Object
- #executable? ⇒ Boolean
- #job_klass ⇒ Object
- #retry_later ⇒ Object
-
#retry_now ⇒ Object
Re-execute this workflow from its record, without constantizing the job class or re-passing the key.
-
#retryable? ⇒ Boolean
Only stalled or failed workflows can be re-executed.
Instance Method Details
#ensure_retryable! ⇒ Object
57 58 59 60 61 62 |
# File 'lib/chrono_forge/workflow.rb', line 57 def ensure_retryable! return if retryable? raise Executor::WorkflowNotRetryableError, "Cannot retry workflow(#{key}) in #{state} state. Only stalled or failed workflows can be retried." end |
#executable? ⇒ Boolean
48 49 50 |
# File 'lib/chrono_forge/workflow.rb', line 48 def executable? idle? || running? end |
#job_klass ⇒ Object
78 79 80 |
# File 'lib/chrono_forge/workflow.rb', line 78 def job_klass job_class.constantize end |
#retry_later ⇒ Object
73 74 75 76 |
# File 'lib/chrono_forge/workflow.rb', line 73 def retry_later(**) ensure_retryable! job_klass.retry_later(key, **) end |
#retry_now ⇒ Object
Re-execute this workflow from its record, without constantizing the job class or re-passing the key. Retryability is validated up front so a non-retryable workflow raises immediately rather than enqueuing a job that would fail in the worker.
68 69 70 71 |
# File 'lib/chrono_forge/workflow.rb', line 68 def retry_now(**) ensure_retryable! job_klass.retry_now(key, **) end |
#retryable? ⇒ Boolean
Only stalled or failed workflows can be re-executed.
53 54 55 |
# File 'lib/chrono_forge/workflow.rb', line 53 def retryable? stalled? || failed? end |