Pro Expiring Jobs

Mike Perham edited this page Nov 28, 2018 · 1 revision

Faktory Pro 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)

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

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.