job-iteration 1.12.0 → 1.13.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: 4a851271cdcba188da01fad33b65fa92cdbbe27d6515c44ee950d27d761e1519
4
- data.tar.gz: e15477e57d43194a00067d026dc445c9edbc9225ba4bef2b0de60f91618d9874
3
+ metadata.gz: 3d53eb98ba08338c2ec09152aec97a0b5533f19a333e28251dd72bd9ddb9f086
4
+ data.tar.gz: ac7130a6c0ddc18a72611d7b84511bd298fb152edd7860e6cee9b0ac5812f5ae
5
5
  SHA512:
6
- metadata.gz: a7abcf968843fcfc5c260adae6998f905398308acdd3b42fd8a4208556e3207c1cd0650724b2f48f07a7d23f84cc1740ede0fc6066ee8c211109de556b83357d
7
- data.tar.gz: d8ebd653153f30e87d91951be33b38a7c8644a58865e7bff1c76603cd5287301fe596116c9eac412cd93a5b571e1062e6ef766b38b8debd6d93c20b44f9af4b8
6
+ metadata.gz: b1d9ae0dab247bc4e6407fb801f93abfe321a81c1fb3192bad329d4aab0ceaa73f3c198873fb225f63324dc7ade9bd826456ad05f838b6a54d4de7f9dd196962
7
+ data.tar.gz: 93bba42a0e0267df4d8437e1afc8cf34fa06d3d80b695fb0f45d5f538b3eac35bb9943891c8a918fa1d600d3316152ceabaf5fc2158e8e77eec662292bf828c6
data/CHANGELOG.md CHANGED
@@ -1,5 +1,5 @@
1
1
  ## Main (unreleased)
2
-
2
+
3
3
  ### Breaking Changes
4
4
 
5
5
  nil
@@ -16,6 +16,24 @@ nil
16
16
 
17
17
  nil
18
18
 
19
+ ## v1.13.0 (Mar 23, 2026)
20
+
21
+ ### Breaking Changes
22
+
23
+ - [673](https://github.com/Shopify/job-iteration/pull/673) - Drop support for Ruby 3.0 and Rails 6.1. The minimum supported Ruby version is now 3.1 and the minimum supported Rails version is now 7.0.
24
+
25
+ ### Changes
26
+
27
+ nil
28
+
29
+ ### Features
30
+
31
+ - [683](https://github.com/Shopify/job-iteration/pull/683) Add support for logging interruption reasons from the interruption_adapters and job_should_exit? hooks
32
+
33
+ ### Bug fixes
34
+
35
+ nil
36
+
19
37
  ## v1.12.0 (Jan 16, 2026)
20
38
 
21
39
  ### Features
data/README.md CHANGED
@@ -166,8 +166,8 @@ Job-iteration currently supports the following queue adapters (in order of imple
166
166
 
167
167
  It supports the following platforms:
168
168
 
169
- - Ruby 3.0 and later
170
- - Rails 6.1 and later
169
+ - Ruby 3.1 and later
170
+ - Rails 7.0 and later
171
171
 
172
172
  Support for older platforms that have reached end of life may occasionally be dropped if maintaining backwards compatibility is cumbersome.
173
173
 
@@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
  require "job-iteration/version"
6
6
 
7
7
  Gem::Specification.new do |spec|
8
- spec.required_ruby_version = ">= 3.0"
8
+ spec.required_ruby_version = ">= 3.1"
9
9
  spec.name = "job-iteration"
10
10
  spec.version = JobIteration::VERSION
11
11
  spec.authors = ["Shopify"]
@@ -26,5 +26,5 @@ Gem::Specification.new do |spec|
26
26
  spec.metadata["changelog_uri"] = "https://github.com/Shopify/job-iteration/blob/main/CHANGELOG.md"
27
27
  spec.metadata["allowed_push_host"] = "https://rubygems.org"
28
28
 
29
- spec.add_dependency("activejob", ">= 6.1")
29
+ spec.add_dependency("activejob", ">= 7.0")
30
30
  end
@@ -25,6 +25,11 @@ module JobIteration
25
25
 
26
26
  # Registers adapter for specified name.
27
27
  #
28
+ # The adapter must respond to +call+ and return a falsy value to continue iterating,
29
+ # or a truthy value to signal interruption. If the adapter returns a String, it will
30
+ # be used as the interruption reason in logs and the +interrupted.iteration+
31
+ # notification. Otherwise, the reason defaults to +"interrupted"+.
32
+ #
28
33
  # JobIteration::InterruptionAdapters.register(:sidekiq, MyCustomSidekiqAdapter)
29
34
  def register(name, adapter)
30
35
  raise ArgumentError, "adapter must be callable" unless adapter.respond_to?(:call)
@@ -188,10 +188,12 @@ module JobIteration
188
188
  self.cursor_position = cursor_from_enumerator
189
189
  end
190
190
 
191
- next unless job_should_exit?
191
+ reason = job_should_exit?
192
+ next unless reason
192
193
 
193
194
  self.executions -= 1 if executions > 1
194
195
  @needs_reenqueue = true
196
+ @interrupt_reason = reason.is_a?(String) ? reason : "unknown"
195
197
  return false
196
198
  end
197
199
 
@@ -206,7 +208,10 @@ module JobIteration
206
208
  end
207
209
 
208
210
  def reenqueue_iteration_job
209
- ActiveSupport::Notifications.instrument("interrupted.iteration", instrumentation_tags)
211
+ ActiveSupport::Notifications.instrument(
212
+ "interrupted.iteration",
213
+ instrumentation_tags.merge(reason: @interrupt_reason),
214
+ )
210
215
 
211
216
  self.times_interrupted += 1
212
217
 
@@ -289,9 +294,14 @@ module JobIteration
289
294
 
290
295
  def job_should_exit?
291
296
  max_job_runtime = job_iteration_max_job_runtime
292
- return true if max_job_runtime && start_time && (Time.now.utc - start_time) > max_job_runtime
297
+ if max_job_runtime && start_time && (Time.now.utc - start_time) > max_job_runtime
298
+ return "max_job_runtime_exceeded"
299
+ end
300
+
301
+ result = interruption_adapter.call
302
+ return (result.is_a?(String) ? result : "interrupted") if result
293
303
 
294
- interruption_adapter.call || (defined?(super) && super)
304
+ (defined?(super) && super) || false
295
305
  end
296
306
 
297
307
  def job_iteration_max_job_runtime
@@ -22,7 +22,7 @@ module JobIteration
22
22
  def interrupted(event)
23
23
  info do
24
24
  "[JobIteration::Iteration] Interrupting and re-enqueueing the job " \
25
- "cursor_position=#{event.payload[:cursor_position]}"
25
+ "cursor_position=#{event.payload[:cursor_position]} reason=#{event.payload[:reason] || "nil"}"
26
26
  end
27
27
  end
28
28
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JobIteration
4
- VERSION = "1.12.0"
4
+ VERSION = "1.13.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: job-iteration
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.12.0
4
+ version: 1.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
@@ -15,14 +15,14 @@ dependencies:
15
15
  requirements:
16
16
  - - ">="
17
17
  - !ruby/object:Gem::Version
18
- version: '6.1'
18
+ version: '7.0'
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - ">="
24
24
  - !ruby/object:Gem::Version
25
- version: '6.1'
25
+ version: '7.0'
26
26
  description: Makes your background jobs interruptible and resumable.
27
27
  email:
28
28
  - ops-accounts+shipit@shopify.com
@@ -70,14 +70,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
70
70
  requirements:
71
71
  - - ">="
72
72
  - !ruby/object:Gem::Version
73
- version: '3.0'
73
+ version: '3.1'
74
74
  required_rubygems_version: !ruby/object:Gem::Requirement
75
75
  requirements:
76
76
  - - ">="
77
77
  - !ruby/object:Gem::Version
78
78
  version: '0'
79
79
  requirements: []
80
- rubygems_version: 4.0.4
80
+ rubygems_version: 4.0.8
81
81
  specification_version: 4
82
82
  summary: Makes your background jobs interruptible and resumable.
83
83
  test_files: []