class Conveyor::Belt
- Conveyor::Belt
- Reference
- Object
Overview
The Conveyor::Belt
processes your Job
instances sequentially. Each job
is fetched from Redis and placed on the belt to be processed. If the job
does not complete successfully, it is removed from the belt and placed back
in the queue, waiting an exponential amount of
time before retrying.
Your application can have one or more Conveyor::Belt
s, allowing you to process multiple jobs concurrently. You can configure this by setting Configuration#concurrency
:
Conveyor.configure do |config|
# ...
c.concurrency = 10
end
The Orchestrator
will manage your Belt
instances throughout their entire
lifecycle, so you shouldn't need to deal with Conveyor::Belt
directly in
your application, but it's a good idea to know that it exists.
Defined in:
belt.crConstructors
Instance Method Summary
- #clear_queues!
- #delete(id : String) : self
- #fetch : JobData | Nil
- #id : String
- #jobs_per_second
- #on_error(&on_error : ::Exception -> Nil)
-
#reenqueue(job_data : JobData, max_attempts : Int32, exception : ::Exception | Nil) : self
Reschedule the job to run after an amount of time based on the number of times the job has been attempted has passed.
-
#run_one : Nil
Fetch and perform a single job
- #running? : Bool
-
#start(&)
Start up this belt to begin processing jobs from the queues that feed into it.
- #state : State
-
#stop
Stop processing jobs on this belt.
- #work(data : JobData)
Constructor Detail
Instance Method Detail
Retrieves JobData
from Redis, if there are any pending jobs in any of
the queues passed to this Belt
's constructor. This method also marks the
job in Redis as pending
and assigned to this Belt
.
Reschedule the job to run after an amount of time based on the number of times the job has been attempted has passed.
Start up this belt to begin processing jobs from the queues that feed
into it. This is called by the Orchestrator
on start.
Stop processing jobs on this belt. The currently processing job will finish as long as the process does not exit beforehand, but no new jobs will be processed on this belt.
The Orchestrator
typically calls this method.
Deserializes the job payload provided by the given JobData
and calls the
job type's Job#call
method. If an exception occurs while processing the
job, the belt's #on_error
block is invoked and the job is rescheduled to
run on an exponential-backoff schedule based on how many times the job has
been attempted.