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
48 49 50 51 52 53 |
# File 'lib/chrono_forge/workflow.rb', line 48 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
39 40 41 |
# File 'lib/chrono_forge/workflow.rb', line 39 def executable? idle? || running? end |
#job_klass ⇒ Object
69 70 71 |
# File 'lib/chrono_forge/workflow.rb', line 69 def job_klass job_class.constantize end |
#retry_later ⇒ Object
64 65 66 67 |
# File 'lib/chrono_forge/workflow.rb', line 64 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.
59 60 61 62 |
# File 'lib/chrono_forge/workflow.rb', line 59 def retry_now(**) ensure_retryable! job_klass.retry_now(key, **) end |
#retryable? ⇒ Boolean
Only stalled or failed workflows can be re-executed.
44 45 46 |
# File 'lib/chrono_forge/workflow.rb', line 44 def retryable? stalled? || failed? end |