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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bb92ddcc1f401edb1b9f9462e599c9800ec8ea9550bc7568f16aab9bbf88ae88
4
- data.tar.gz: 9f2e2483ec683668a512f7580d93de0dac245ee7a1179c81b36e1da21d711532
3
+ metadata.gz: 881ada6ecc27a5b6a80fb5f95153d924cb4a8d89eeb95d066756ca038aedfd7c
4
+ data.tar.gz: 2fcea2ff6040393dcc73adb27e94bab7ef612b817cfe21bc1a94ef32ce64e50e
5
5
  SHA512:
6
- metadata.gz: a01c577b380b0f4a4d5cb02660bcca4d82cb33995c7f6042b99c9a28a9aa5185e15f2d6a5408e837843b37c0df9fd304efa52c870e2aa793811ff53597af6367
7
- data.tar.gz: c30d348d3d9bba82c26bf482e58572e05f06fb6a578a1a902d3b31d21ecbf82e383255f510718c6f6331b46c49abf727e2f511660e09124f1d3340f28f745b9c
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.7+
19
- - Sidekiq 6.0+
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
- if (expires_in = job.delete("expires_in"))
8
- at = job["at"] || job["created_at"]
9
- job["expires_at"] = at + expires_in.to_f
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 (expires_at = job["expires_at"])
18
- if expires_at >= Time.now.to_f
19
- yield
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SidekiqExpiringJobs
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  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.1.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: 2023-04-12 00:00:00.000000000 Z
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: '6.0'
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: '6.0'
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.7.0
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.7
66
+ rubygems_version: 3.4.19
67
67
  signing_key:
68
68
  specification_version: 4
69
69
  summary: Expiring jobs support for Sidekiq.