Class: DurableFlow::Dispatcher
- Inherits:
-
Object
- Object
- DurableFlow::Dispatcher
- Defined in:
- lib/durable_flow/dispatcher.rb
Class Method Summary collapse
Class Method Details
.dispatch(event) ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/durable_flow/dispatcher.rb', line 6 def dispatch(event) WorkflowWait.pending.where(event_name: event.name).find_each do |wait| next unless wait.matches_event?(event) wait.update!(status: "matched", workflow_event: event) wait.workflow_run.update!(status: "ready") enqueue(wait.workflow_run) end end |
.enqueue(workflow_run) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/durable_flow/dispatcher.rb', line 16 def enqueue(workflow_run) return if workflow_run.terminal? return if workflow_run.serialized_job.blank? job = ActiveJob::Base.deserialize(workflow_run.serialized_job) job.scheduled_at = nil job.enqueue end |