Module: Conflow::Flow::JobHandler
- Included in:
- Conflow::Flow
- Defined in:
- lib/conflow/flow/job_handler.rb
Overview
Handles running and finishing jobs
Instance Method Summary collapse
-
#finish(job, result = nil) ⇒ Object
Finishes job, changes its status, assigns result of the job and queues new available jobs.
-
#run(job_class, params: {}, after: []) ⇒ Conflow::Job
Enqueued job.
-
#start(job) ⇒ void
private
Starts the job - resolves it’s promises.
Instance Method Details
#finish(job, result = nil) ⇒ Object
Finishes job, changes its status, assigns result of the job and queues new available jobs
34 35 36 37 38 39 |
# File 'lib/conflow/flow/job_handler.rb', line 34 def finish(job, result = nil) job.result = result if result.is_a?(Hash) && result.any? call_script(Conflow::Redis::CompleteJobScript, job) queue_available_jobs destroy! if finished? end |
#run(job_class, params: {}, after: []) ⇒ Conflow::Job
Returns enqueued job.
13 14 15 16 17 18 19 20 |
# File 'lib/conflow/flow/job_handler.rb', line 13 def run(job_class, params: {}, after: []) job, dependencies = job_builder.call(job_class, params, after) call_script(Conflow::Redis::AddJobScript, job, after: dependencies) queue_available_jobs job end |
#start(job) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Starts the job - resolves it’s promises. It’s called by Worker before it yields parameters
27 28 29 |
# File 'lib/conflow/flow/job_handler.rb', line 27 def start(job) call_script(Conflow::Redis::ResolvePromisesScript, job) end |