-
Notifications
You must be signed in to change notification settings - Fork 230
Ent Expiring Jobs
Faktory Enterprise can automatically expire jobs which have passed a preset time. Expiring jobs are very useful for actions which aren't useful after some time: things like cache invalidation, creating time-sensitive reports, etc.
You provide an expiration time in the job's custom data:
require 'time'
one_hour_from_now = (Time.now + 3600).utc
job = {
'jobtype' => 'SomeJob',
'args' => [1,2,3],
'custom' => { 'expires_at' => one_hour_from_now.iso8601 } # "2018-10-10T21:19:35Z"
}
client = Faktory::Client.new
client.push(job)
In v1.5.5+, you can also provide a relative time in seconds using expires_in
. Assume you want to issue a cron job every minute BUT you don't want duplicates. Just configure it to expire in 60 seconds:
[[cron]]
schedule = "* * * * *"
[cron.job]
type = "MinutelyJob"
queue = "critical"
[cron.job.custom]
expires_in = 60
Faktory will log a message when it expires a job; this is so jobs don't just "disappear" and there is a record of their expiration.
D 2018-10-08T21:24:05.846Z JID 3374020d83e39c34: Halt: job expired
Jobs are expired when a worker fetches a job from the queue; they will accumulate in queue if no workers are fetching jobs from that queue.
Home | Installation | Getting Started Ruby | Job Errors | FAQ | Related Projects
This wiki is tracked by git and publicly editable. You are welcome to fix errors and typos. Any defacing or vandalism of content will result in your changes being reverted and you being blocked.