contribsys / faktory

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

Feature Request: Unique jobs even after completion #464

Closed Deekor closed 6 months ago

Deekor commented 9 months ago

Just like the unique_for ENT feature, but keep the unique constraint after the job has finished.

For example: You have a job you are meant to only queue once a day, putting unique_after: 23.hours would prevent queuing that job again for another 23 hours even if there is no instances of that job running.

mperham commented 9 months ago

Huh, no one's ever asked for that before.

My initial reaction is negative. Locks should be used sparingly and jobs should be idempotent. Imagine an hourly periodic job; It would be easy for the app to store the "last_run_at" timestamp and only execute if 24 hours has passed. The other 23 instances would just return early and do nothing.

Deekor commented 9 months ago

It would be easy for the app to store the "last_run_at" timestamp and only execute if 24 hours has passed. The other 23 instances would just return early and do nothing.

Sure, and that is what were doing, seemed like it would be nice if faktory handled it for us.