contribsys / faktory

Language-agnostic persistent background job server
https://contribsys.com/faktory/
Other
5.71k stars 228 forks source link

Allow `expires_in` relative timestamp #384

Closed mperham closed 2 years ago

mperham commented 2 years ago

It would be very useful to allow clients to specify a relative timestamp to Faktory ("expires in 60 seconds") and have Faktory expand that timestamp when the job is first pushed to Faktory. That is to say, if you push this:

{
  ...
  "custom": {
    "expires_in": 60
  }
}

Faktory will generate the exact timestamp and save that to Redis.

{
  ...
  "custom": {
    "expires_at": "2021-07-09T17:46:23.654443Z"
  }
}

I can't think of any reason why mutating the payload would pose a problem.

mperham commented 2 years ago

This will allow cron jobs to expire:

[[cron]]
  schedule = "*/5 * * * *"
  [cron.job]
    type = "FiveJob"
    queue = "critical"
    [cron.job.custom]
      expires_in = 60