job-iteration 1.12.0 → 1.13.1

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: e8e5e3fa1240a67b88f2b83290f7b01fcadb28b4a7be257f646d199cff9c2e97
4
+ data.tar.gz: 6a2130de073c8c5eb29c13934f7e4bb73af31cf15fc33af74b5738b420a9b38b
5
5
  SHA512:
6
- metadata.gz: a7abcf968843fcfc5c260adae6998f905398308acdd3b42fd8a4208556e3207c1cd0650724b2f48f07a7d23f84cc1740ede0fc6066ee8c211109de556b83357d
7
- data.tar.gz: d8ebd653153f30e87d91951be33b38a7c8644a58865e7bff1c76603cd5287301fe596116c9eac412cd93a5b571e1062e6ef766b38b8debd6d93c20b44f9af4b8
6
+ metadata.gz: b6316aa38f0e6f7df7874a478253b6e285db61c6077089c43ef1edfce408ec1835cdd7d50d4ccf257e096677cc4fcdb23e67cc609efc48998ae91a0667a8974a
7
+ data.tar.gz: ac9fdbf6afeb440010323c70aa1fcdf60288460788893b0a0dbc536684caeca3291a0e90c80142439c7aac4efbf4853039b482ae37078d2b2c69ab2d565680be
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,30 @@ nil
16
16
 
17
17
  nil
18
18
 
19
+ ## v1.13.1 (Apr 28, 2026)
20
+
21
+ ### Bug fixes
22
+
23
+ - [#699](https://github.com/Shopify/job-iteration/pull/699) - Fix tapioca compiler dropping empty FixedHash `{}` params.
24
+
25
+ ## v1.13.0 (Mar 23, 2026)
26
+
27
+ ### Breaking Changes
28
+
29
+ - [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.
30
+
31
+ ### Changes
32
+
33
+ nil
34
+
35
+ ### Features
36
+
37
+ - [683](https://github.com/Shopify/job-iteration/pull/683) Add support for logging interruption reasons from the interruption_adapters and job_should_exit? hooks
38
+
39
+ ### Bug fixes
40
+
41
+ nil
42
+
19
43
  ## v1.12.0 (Jan 16, 2026)
20
44
 
21
45
  ### 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.1"
5
5
  end
@@ -38,13 +38,7 @@ module Tapioca
38
38
  fixed_hash_args = signature.arg_types.select { |arg_type| T::Types::FixedHash === arg_type[1] }.to_h
39
39
  expanded_parameters = parameters.flat_map do |typed_param|
40
40
  if (hash_type = fixed_hash_args[typed_param.param.name.to_sym])
41
- hash_type.types.map do |key, value|
42
- if value.name.start_with?("T.nilable")
43
- create_kw_opt_param(key.to_s, type: value.to_s, default: "nil")
44
- else
45
- create_kw_param(key.to_s, type: value.to_s)
46
- end
47
- end
41
+ expand_fixed_hash(typed_param, hash_type)
48
42
  else
49
43
  typed_param
50
44
  end
@@ -89,6 +83,21 @@ module Tapioca
89
83
 
90
84
  private
91
85
 
86
+ sig { params(typed_param: RBI::TypedParam, hash_type: T::Types::FixedHash).returns(T.any(RBI::TypedParam, T::Array[RBI::TypedParam])) }
87
+ def expand_fixed_hash(typed_param, hash_type)
88
+ if hash_type.types.empty?
89
+ typed_param
90
+ else
91
+ hash_type.types.map do |key, value|
92
+ if value.name.start_with?("T.nilable")
93
+ create_kw_opt_param(key.to_s, type: value.to_s, default: "nil")
94
+ else
95
+ create_kw_param(key.to_s, type: value.to_s)
96
+ end
97
+ end
98
+ end
99
+ end
100
+
92
101
  sig do
93
102
  params(
94
103
  parameters: T::Array[RBI::TypedParam],
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.1
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.10
81
81
  specification_version: 4
82
82
  summary: Makes your background jobs interruptible and resumable.
83
83
  test_files: []