Conveyor::Job
Inherits JSON::Serializable < Struct < Value < Object
The Job is the unit of work in Conveyor. A representation of it is stored
in Redis along with some metadata, and when it is time to execute that job,
it is deserialized and its call method is invoked.
Jobs are enqueued to be executed ASAP with the enqueue method or scheduled
with the schedule method. Enqueuing a job runs it as soon as there is an
available Conveyor::Belt.
Defining a job is a matter of defining a struct that inherits from
Conveyor::Job (either directly or indirectly) and overriding the call
method to perform its work. The call method is used as the calling
convention used by Proc instances.
Constructors
Class methods
Remove this job from all queues. This method will not unschedule the job.
Instance methods
Enqueues this job in the specified queue, or to the job's default queue if
the queue isn't provided explicitly, to be executed immediately. You can
also pass a Configuration instance to use different settings.
struct MyJob < Conveyor::Job
def initialize(@arg : String)
end
def call
# ...
end
end
MyJob.new("asdf").enqueue
Enqueues this job in the specified queue, or to the job's default queue if
the queue isn't provided, to be executed after the given amount of time.
You can also pass a Configuration instance to use different settings.
struct MyJob < Conveyor::Job
def initialize(@arg : String)
end
def call
# ...
end
end
MyJob.new("asdf").enqueue in: 1.minute
Enqueues this job in the specified queue, or to the job's default queue if
the queue isn't provided explicitly, to be executed at the specified
time. You can also pass a Configuration instance to use different
settings.
struct MyJob < Conveyor::Job
def initialize(@arg : String)
end
def call
# ...
end
end
MyJob.new("asdf").enqueue at: timestamp
Macros
Define the queue your job will enqueue on by default
struct SendEmail < Conveyor::Job
# Emails get their own queue
queue "email"
def initialize(@email_address : String, @body : String)
end
def call
# ...
end
end