sidekiq-expiring-jobs 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/README.md +2 -4
- data/lib/sidekiq_expiring_jobs/middleware.rb +18 -10
- data/lib/sidekiq_expiring_jobs/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 881ada6ecc27a5b6a80fb5f95153d924cb4a8d89eeb95d066756ca038aedfd7c
|
4
|
+
data.tar.gz: 2fcea2ff6040393dcc73adb27e94bab7ef612b817cfe21bc1a94ef32ce64e50e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24979411d040e8da8298a30936b656478d53d94adb6df1766374dac6c529a17bf08350dea2afbf583efef119e782f56956307413c275db8f277fdf6a1f12e270
|
7
|
+
data.tar.gz: 299072e39583f57f9fecf25c9aade5ef18c6fce0a8c3f502181112e3aab8545c3aa97af3d909eb0c4889ceb49ba9c886d995b833b33d9ad5f314009f4bbd0d6a
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
## master (unreleased)
|
2
2
|
|
3
|
+
## 0.2.0 (2025-09-15)
|
4
|
+
|
5
|
+
- Do not recalculate `expires_at` if already exists
|
6
|
+
- Drop support for Ruby < 3.2 and Sidekiq < 8.0
|
7
|
+
|
8
|
+
## 0.1.1 (2024-01-14)
|
9
|
+
|
10
|
+
- Raise when `:expires_in` is an absolute time
|
11
|
+
|
3
12
|
## 0.1.0 (2023-04-12)
|
4
13
|
|
5
14
|
- First release
|
data/README.md
CHANGED
@@ -15,8 +15,8 @@ Note: Sidekiq Pro has this feature, so please consider upgrading if you can.
|
|
15
15
|
|
16
16
|
## Requirements
|
17
17
|
|
18
|
-
- Ruby 2
|
19
|
-
- Sidekiq
|
18
|
+
- Ruby 3.2+
|
19
|
+
- Sidekiq 8.0+
|
20
20
|
|
21
21
|
## Installation
|
22
22
|
|
@@ -72,8 +72,6 @@ SidekiqExpiringJobs.expiration_callback = ->(job) {}
|
|
72
72
|
|
73
73
|
## Development
|
74
74
|
|
75
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
76
|
-
|
77
75
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
78
76
|
|
79
77
|
## Contributing
|
@@ -4,9 +4,21 @@ module SidekiqExpiringJobs
|
|
4
4
|
module Middleware
|
5
5
|
class Client
|
6
6
|
def call(_worker_class, job, _queue, _redis_pool)
|
7
|
-
|
8
|
-
|
9
|
-
job[
|
7
|
+
# The job is requeued, e.g. by sidekiq-throttled gem. Do not update the expiration time.
|
8
|
+
if job["expires_at"] && job["expires_at"] < Time.now.to_f
|
9
|
+
Sidekiq.logger.info("[SidekiqExpiringJobs] Expired #{job['class']} job (jid=#{job['jid']}) is skipped")
|
10
|
+
SidekiqExpiringJobs.expiration_callback&.call(job)
|
11
|
+
|
12
|
+
return false
|
13
|
+
end
|
14
|
+
|
15
|
+
if (expires_in = job.delete("expires_in")) && job["expires_at"].nil?
|
16
|
+
expires_in = expires_in.to_f
|
17
|
+
raise ArgumentError, ":expires_in must be a relative time, not absolute time" if expires_in > 1_000_000_000
|
18
|
+
|
19
|
+
# created_at is stored in milliseconds starting from sidekiq 8.0.
|
20
|
+
at = job["at"] || (job["created_at"] / 1000.0)
|
21
|
+
job["expires_at"] = at + expires_in
|
10
22
|
end
|
11
23
|
yield
|
12
24
|
end
|
@@ -14,13 +26,9 @@ module SidekiqExpiringJobs
|
|
14
26
|
|
15
27
|
class Server
|
16
28
|
def call(_worker, job, _queue)
|
17
|
-
if
|
18
|
-
|
19
|
-
|
20
|
-
else
|
21
|
-
Sidekiq.logger.info("[SidekiqExpiringJobs] Expired #{job['class']} job (jid=#{job['jid']}) is skipped")
|
22
|
-
SidekiqExpiringJobs.expiration_callback&.call(job)
|
23
|
-
end
|
29
|
+
if job["expires_at"] && job["expires_at"] < Time.now.to_f
|
30
|
+
Sidekiq.logger.info("[SidekiqExpiringJobs] Expired #{job['class']} job (jid=#{job['jid']}) is skipped")
|
31
|
+
SidekiqExpiringJobs.expiration_callback&.call(job)
|
24
32
|
else
|
25
33
|
yield
|
26
34
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sidekiq-expiring-jobs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- fatkodima
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-09-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sidekiq
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '8.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '8.0'
|
27
27
|
description: |
|
28
28
|
Support for Sidekiq jobs which expire after a certain length of time.
|
29
29
|
Jobs that are set to expire can run as long as they want, but an expiring job
|
@@ -56,14 +56,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
56
56
|
requirements:
|
57
57
|
- - ">="
|
58
58
|
- !ruby/object:Gem::Version
|
59
|
-
version: 2.
|
59
|
+
version: 3.2.0
|
60
60
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
61
|
requirements:
|
62
62
|
- - ">="
|
63
63
|
- !ruby/object:Gem::Version
|
64
64
|
version: '0'
|
65
65
|
requirements: []
|
66
|
-
rubygems_version: 3.4.
|
66
|
+
rubygems_version: 3.4.19
|
67
67
|
signing_key:
|
68
68
|
specification_version: 4
|
69
69
|
summary: Expiring jobs support for Sidekiq.
|