6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/sidekiq_expiring_jobs/middleware.rb', line 6
def call(_worker_class, job, _queue, _redis_pool)
if job["expires_at"] && job["expires_at"] < Time.now.to_f
Sidekiq.logger.info("[SidekiqExpiringJobs] Expired #{job['class']} job (jid=#{job['jid']}) is skipped")
SidekiqExpiringJobs.expiration_callback&.call(job)
return false
end
if (expires_in = job.delete("expires_in")) && job["expires_at"].nil?
expires_in = expires_in.to_f
raise ArgumentError, ":expires_in must be a relative time, not absolute time" if expires_in > 1_000_000_000
at = job["at"] || (job["created_at"] / 1000.0)
job["expires_at"] = at + expires_in
end
yield
end
|