mosquito-cr / mosquito

A background task runner for crystal applications supporting periodic (CRON) and manually queued jobs
MIT License
227 stars 24 forks source link

Provide an easy way to cancel a job without it being rescheduled #95

Closed robacarp closed 1 year ago

robacarp commented 2 years ago

For example:

class BetterSendItSoonJob < Mosquito::Job
  before do
    # only perform the job if this job was enqueued within the last 2 minutes
    fail "job is too stale to run", retry: false unless task.enqueue_time > 2.minutes.ago
  end

   def perform
      # ....
   end
end

Related #41