job-iteration 1.8.0 → 1.10.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: a38399b1ad6f7c81b2dd731e39abc75b4febcbac50ea9c310c6c96ada5f802ff
4
- data.tar.gz: 96182f4dcdd4594c9fde855b2394b96a516e7134671a18905ebd3ae6b13ddcfa
3
+ metadata.gz: 4470d17b555f82240c1849477ebfb46d7385c27524748072c0dcf93af588d9eb
4
+ data.tar.gz: 1dc09430105ac34917aace4451c2ec7255cca9319a5ada563ed840857add81b6
5
5
  SHA512:
6
- metadata.gz: 515d1e0106c1b7c20ce3058df4df1c0c2a29dfb0ebe297bc3ac81da5365b7c8d68cf1058dc5de9c1c37331570260065e59aa86b1801f3b821a70d504aa3b25ac
7
- data.tar.gz: 27303a6ea6910734d7d23f6ef0570cf7b2e6f011b1776731829e8366d93e2ad1032c1fce4bf44dee42e1c253f209f97cda8c761824ab7b81f8bfa51a339b0218
6
+ metadata.gz: d1c25928d819bcff005e83e8cc7183e323a4e69d74b16b43884b1a1c1b8f531b54a8ece05004e7a6dfe28c94542454fefa11ff239b16e8c92cdb9d1508a3fd79
7
+ data.tar.gz: 3a8bfcfd03312d82be3ba3974fceecac5d8c53aa9129cb59f9321875ec10a448ffe4cd50b9949cf9da79a6f47c7e586fe266356c9e20111f8f60d48f775ed5a1
@@ -13,52 +13,32 @@ jobs:
13
13
  ports:
14
14
  - 6379:6379
15
15
  strategy:
16
+ fail-fast: false
16
17
  matrix:
17
- ruby: ["2.6", "2.7", "3.0", "3.1", "3.2", "3.3"]
18
- rails: ["5.2", "6.0", "6.1", "7.0", "7.1", "7.2", "edge"]
18
+ ruby: ["3.0", "3.1", "3.2", "3.3", "3.4"]
19
+ rails: ["6.1", "7.0", "7.1", "7.2", "8.0", "edge"]
19
20
  gemfile: [rails_gems]
20
21
  exclude:
21
- - ruby: "2.6"
22
- rails: "7.0"
23
- - ruby: "2.6"
24
- rails: "7.1"
25
- - ruby: "2.6"
26
- rails: "7.2"
27
- - ruby: "2.6"
28
- rails: "edge"
29
- - ruby: "2.7"
30
- rails: "7.1"
31
- - ruby: "2.7"
32
- rails: "7.2"
33
- - ruby: "2.7"
34
- rails: "edge"
35
- - ruby: "3.0"
36
- rails: "5.2"
37
22
  - ruby: "3.0"
38
23
  rails: "7.1"
39
24
  - ruby: "3.0"
40
25
  rails: "7.2"
26
+ - ruby: "3.0"
27
+ rails: "8.0"
41
28
  - ruby: "3.0"
42
29
  rails: "edge"
43
30
  - ruby: "3.1"
44
- rails: "5.2"
45
- - ruby: "3.1"
46
- rails: "6.0"
31
+ rails: "8.0"
47
32
  - ruby: "3.1"
48
33
  rails: "edge"
49
- - ruby: "3.2"
50
- rails: "5.2"
51
- - ruby: "3.2"
52
- rails: "6.0"
53
34
  - ruby: "3.2"
54
35
  rails: "6.1"
55
- - ruby: "3.3"
56
- rails: "5.2"
57
- - ruby: "3.3"
58
- rails: "6.0"
59
36
  - ruby: "3.3"
60
37
  rails: "6.1"
61
-
38
+ - ruby: "3.4"
39
+ rails: "6.1"
40
+ - ruby: "3.4"
41
+ rails: "7.0"
62
42
  include:
63
43
  - ruby: head
64
44
  rails: "edge"
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.3.3
1
+ 3.4.2
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ### Main (unreleased)
2
2
 
3
+ ### Breaking Changes
4
+
5
+ nil
6
+
3
7
  ### Changes
4
8
 
5
9
  nil
@@ -12,6 +16,23 @@ nil
12
16
 
13
17
  nil
14
18
 
19
+ ## v1.10.0 (Mar 20, 2025)
20
+
21
+ ### Breaking Changes
22
+
23
+ - [544](https://github.com/Shopify/job-iteration/pull/544) - Drop support for Ruby 2.6 and 2.7, and Rails 5.2 and 6.0. The minimum supported Ruby version is now 3.0, and the minimum supported Rails version is 6.1.
24
+
25
+ ### Features
26
+
27
+ - [547](https://github.com/Shopify/job-iteration/pull/547) Add interruption adapter for [DelayedJob](https://github.com/collectiveidea/delayed_job).
28
+ - [556](https://github.com/Shopify/job-iteration/pull/556) Add support for generic job classes in the Tapioca Sorbet compiler.
29
+
30
+ ## v1.9.0 (Feb 3, 2025)
31
+
32
+ ### Features
33
+
34
+ - [533](https://github.com/Shopify/job-iteration/pull/533) Added a custom compiler for [Tapioca](https://github.com/Shopify/tapioca) that generates Sorbet types for `MyJob.perform_later` if `MyJob` includes `JobIteration::Iteration` and has defined a type for `build_enumerator`.
35
+
15
36
  ## v1.8.0 (Dec 10, 2024)
16
37
 
17
38
  ### Changes
data/Gemfile CHANGED
@@ -10,16 +10,19 @@ gemspec
10
10
  # for integration testing
11
11
  gem "sidekiq"
12
12
  gem "resque"
13
+ gem "delayed_job"
13
14
 
14
15
  if defined?(@rails_gems_requirements) && @rails_gems_requirements
15
16
  # We avoid the `gem "..."` syntax here so Dependabot doesn't try to update these gems.
16
17
  [
17
18
  "activejob",
18
19
  "activerecord",
20
+ "railties",
19
21
  ].each { |name| gem name, @rails_gems_requirements }
20
22
  else
21
23
  # gem "activejob" # Set in gemspec
22
24
  gem "activerecord"
25
+ gem "railties"
23
26
  end
24
27
 
25
28
  gem "mysql2", github: "brianmario/mysql2"
@@ -37,3 +40,6 @@ gem "csv" # required for Ruby 3.4+
37
40
 
38
41
  # for unit testing optional sorbet support
39
42
  gem "sorbet-runtime"
43
+ gem "tapioca"
44
+
45
+ gem "logger"
data/Gemfile.lock CHANGED
@@ -1,6 +1,6 @@
1
1
  GIT
2
2
  remote: https://github.com/brianmario/mysql2
3
- revision: 58f8d009a0d107776dd6d24c9906426fe0f7b856
3
+ revision: 57b8df188c963ae0e4d4e1123d3e9de2bbcab637
4
4
  specs:
5
5
  mysql2 (0.5.6)
6
6
  bigdecimal
@@ -8,138 +8,259 @@ GIT
8
8
  PATH
9
9
  remote: .
10
10
  specs:
11
- job-iteration (1.8.0)
12
- activejob (>= 5.2)
11
+ job-iteration (1.10.0)
12
+ activejob (>= 6.1)
13
13
 
14
14
  GEM
15
15
  remote: https://rubygems.org/
16
16
  specs:
17
- activejob (7.1.3.4)
18
- activesupport (= 7.1.3.4)
17
+ actionpack (8.0.1)
18
+ actionview (= 8.0.1)
19
+ activesupport (= 8.0.1)
20
+ nokogiri (>= 1.8.5)
21
+ rack (>= 2.2.4)
22
+ rack-session (>= 1.0.1)
23
+ rack-test (>= 0.6.3)
24
+ rails-dom-testing (~> 2.2)
25
+ rails-html-sanitizer (~> 1.6)
26
+ useragent (~> 0.16)
27
+ actionview (8.0.1)
28
+ activesupport (= 8.0.1)
29
+ builder (~> 3.1)
30
+ erubi (~> 1.11)
31
+ rails-dom-testing (~> 2.2)
32
+ rails-html-sanitizer (~> 1.6)
33
+ activejob (8.0.1)
34
+ activesupport (= 8.0.1)
19
35
  globalid (>= 0.3.6)
20
- activemodel (7.1.3.4)
21
- activesupport (= 7.1.3.4)
22
- activerecord (7.1.3.4)
23
- activemodel (= 7.1.3.4)
24
- activesupport (= 7.1.3.4)
36
+ activemodel (8.0.1)
37
+ activesupport (= 8.0.1)
38
+ activerecord (8.0.1)
39
+ activemodel (= 8.0.1)
40
+ activesupport (= 8.0.1)
25
41
  timeout (>= 0.4.0)
26
- activesupport (7.1.3.4)
42
+ activesupport (8.0.1)
27
43
  base64
44
+ benchmark (>= 0.3)
28
45
  bigdecimal
29
- concurrent-ruby (~> 1.0, >= 1.0.2)
46
+ concurrent-ruby (~> 1.0, >= 1.3.1)
30
47
  connection_pool (>= 2.2.5)
31
48
  drb
32
49
  i18n (>= 1.6, < 2)
50
+ logger (>= 1.4.2)
33
51
  minitest (>= 5.1)
34
- mutex_m
35
- tzinfo (~> 2.0)
52
+ securerandom (>= 0.3)
53
+ tzinfo (~> 2.0, >= 2.0.5)
54
+ uri (>= 0.13.1)
36
55
  ast (2.4.2)
37
56
  base64 (0.2.0)
38
- bigdecimal (3.1.8)
57
+ benchmark (0.4.0)
58
+ bigdecimal (3.1.9)
59
+ builder (3.3.0)
39
60
  coderay (1.1.3)
40
- concurrent-ruby (1.3.4)
41
- connection_pool (2.4.1)
42
- csv (3.3.0)
61
+ concurrent-ruby (1.3.5)
62
+ connection_pool (2.5.0)
63
+ crass (1.0.6)
64
+ csv (3.3.2)
65
+ date (3.4.1)
66
+ delayed_job (4.1.13)
67
+ activesupport (>= 3.0, < 9.0)
43
68
  drb (2.2.1)
69
+ erubi (1.13.1)
44
70
  globalid (1.2.1)
45
71
  activesupport (>= 6.1)
46
- i18n (1.14.6)
72
+ i18n (1.14.7)
47
73
  concurrent-ruby (~> 1.0)
48
- json (2.7.2)
49
- language_server-protocol (3.17.0.3)
74
+ io-console (0.8.0)
75
+ irb (1.15.1)
76
+ pp (>= 0.6.0)
77
+ rdoc (>= 4.0.0)
78
+ reline (>= 0.4.2)
79
+ json (2.10.1)
80
+ language_server-protocol (3.17.0.4)
81
+ lint_roller (1.1.0)
82
+ logger (1.6.6)
83
+ loofah (2.24.0)
84
+ crass (~> 1.0.2)
85
+ nokogiri (>= 1.12.0)
50
86
  method_source (1.1.0)
51
- minitest (5.24.0)
52
- mocha (2.7.0)
87
+ minitest (5.25.4)
88
+ mocha (2.7.1)
53
89
  ruby2_keywords (>= 0.0.5)
54
90
  mono_logger (1.1.2)
55
91
  multi_json (1.15.0)
56
- mustermann (3.0.0)
92
+ mustermann (3.0.3)
57
93
  ruby2_keywords (~> 0.0.1)
58
- mutex_m (0.2.0)
59
- parallel (1.25.1)
60
- parser (3.3.3.0)
94
+ netrc (0.11.0)
95
+ nokogiri (1.18.3-arm64-darwin)
96
+ racc (~> 1.4)
97
+ nokogiri (1.18.3-x86_64-darwin)
98
+ racc (~> 1.4)
99
+ nokogiri (1.18.3-x86_64-linux-gnu)
100
+ racc (~> 1.4)
101
+ parallel (1.26.3)
102
+ parser (3.3.7.1)
61
103
  ast (~> 2.4.1)
62
104
  racc
63
- pry (0.15.0)
105
+ pp (0.6.2)
106
+ prettyprint
107
+ prettyprint (0.2.0)
108
+ prism (1.3.0)
109
+ pry (0.15.2)
64
110
  coderay (~> 1.1)
65
111
  method_source (~> 1.0)
66
- racc (1.8.0)
67
- rack (3.1.5)
68
- rack-protection (4.0.0)
112
+ psych (5.2.3)
113
+ date
114
+ stringio
115
+ racc (1.8.1)
116
+ rack (3.1.12)
117
+ rack-protection (4.1.1)
69
118
  base64 (>= 0.1.0)
119
+ logger (>= 1.6.0)
70
120
  rack (>= 3.0.0, < 4)
71
- rack-session (2.0.0)
121
+ rack-session (2.1.0)
122
+ base64 (>= 0.1.0)
72
123
  rack (>= 3.0.0)
124
+ rack-test (2.2.0)
125
+ rack (>= 1.3)
126
+ rackup (2.2.1)
127
+ rack (>= 3)
128
+ rails-dom-testing (2.2.0)
129
+ activesupport (>= 5.0.0)
130
+ minitest
131
+ nokogiri (>= 1.6)
132
+ rails-html-sanitizer (1.6.2)
133
+ loofah (~> 2.21)
134
+ nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
135
+ railties (8.0.1)
136
+ actionpack (= 8.0.1)
137
+ activesupport (= 8.0.1)
138
+ irb (~> 1.13)
139
+ rackup (>= 1.0.0)
140
+ rake (>= 12.2)
141
+ thor (~> 1.0, >= 1.2.2)
142
+ zeitwerk (~> 2.6)
73
143
  rainbow (3.1.1)
74
144
  rake (13.2.1)
75
- redis (5.3.0)
145
+ rbi (0.3.0)
146
+ prism (~> 1.0)
147
+ rbs (>= 3.4.4)
148
+ sorbet-runtime (>= 0.5.9204)
149
+ rbs (3.8.1)
150
+ logger
151
+ rdoc (6.12.0)
152
+ psych (>= 4.0.0)
153
+ redis (5.4.0)
76
154
  redis-client (>= 0.22.0)
77
- redis-client (0.22.2)
155
+ redis-client (0.24.0)
78
156
  connection_pool
79
157
  redis-namespace (1.11.0)
80
158
  redis (>= 4)
81
- regexp_parser (2.9.2)
82
- resque (2.6.0)
83
- mono_logger (~> 1.0)
159
+ regexp_parser (2.10.0)
160
+ reline (0.6.0)
161
+ io-console (~> 0.5)
162
+ resque (2.7.0)
163
+ mono_logger (~> 1)
84
164
  multi_json (~> 1.0)
85
165
  redis-namespace (~> 1.6)
86
166
  sinatra (>= 0.9.2)
87
- rexml (3.3.9)
88
- rubocop (1.64.1)
167
+ rubocop (1.73.2)
89
168
  json (~> 2.3)
90
- language_server-protocol (>= 3.17.0)
169
+ language_server-protocol (~> 3.17.0.2)
170
+ lint_roller (~> 1.1.0)
91
171
  parallel (~> 1.10)
92
172
  parser (>= 3.3.0.2)
93
173
  rainbow (>= 2.2.2, < 4.0)
94
- regexp_parser (>= 1.8, < 3.0)
95
- rexml (>= 3.2.5, < 4.0)
96
- rubocop-ast (>= 1.31.1, < 2.0)
174
+ regexp_parser (>= 2.9.3, < 3.0)
175
+ rubocop-ast (>= 1.38.0, < 2.0)
97
176
  ruby-progressbar (~> 1.7)
98
- unicode-display_width (>= 2.4.0, < 3.0)
99
- rubocop-ast (1.31.3)
177
+ unicode-display_width (>= 2.4.0, < 4.0)
178
+ rubocop-ast (1.38.1)
100
179
  parser (>= 3.3.1.0)
101
- rubocop-shopify (2.15.1)
102
- rubocop (~> 1.51)
180
+ rubocop-shopify (2.16.0)
181
+ rubocop (~> 1.62)
103
182
  ruby-progressbar (1.13.0)
104
183
  ruby2_keywords (0.0.5)
105
- sidekiq (7.2.4)
106
- concurrent-ruby (< 2)
107
- connection_pool (>= 2.3.0)
108
- rack (>= 2.2.4)
109
- redis-client (>= 0.19.0)
110
- sinatra (4.0.0)
184
+ securerandom (0.4.1)
185
+ sidekiq (8.0.1)
186
+ connection_pool (>= 2.5.0)
187
+ json (>= 2.9.0)
188
+ logger (>= 1.6.2)
189
+ rack (>= 3.1.0)
190
+ redis-client (>= 0.23.2)
191
+ sinatra (4.1.1)
192
+ logger (>= 1.6.0)
111
193
  mustermann (~> 3.0)
112
194
  rack (>= 3.0.0, < 4)
113
- rack-protection (= 4.0.0)
195
+ rack-protection (= 4.1.1)
114
196
  rack-session (>= 2.0.0, < 3)
115
197
  tilt (~> 2.0)
116
- sorbet-runtime (0.5.11460)
117
- tilt (2.4.0)
118
- timeout (0.4.1)
198
+ sorbet (0.5.11915)
199
+ sorbet-static (= 0.5.11915)
200
+ sorbet-runtime (0.5.11915)
201
+ sorbet-static (0.5.11915-universal-darwin)
202
+ sorbet-static (0.5.11915-x86_64-linux)
203
+ sorbet-static-and-runtime (0.5.11915)
204
+ sorbet (= 0.5.11915)
205
+ sorbet-runtime (= 0.5.11915)
206
+ spoom (1.6.0)
207
+ erubi (>= 1.10.0)
208
+ prism (>= 0.28.0)
209
+ rbi (>= 0.2.3)
210
+ sorbet-static-and-runtime (>= 0.5.10187)
211
+ thor (>= 0.19.2)
212
+ stringio (3.1.5)
213
+ tapioca (0.16.11)
214
+ benchmark
215
+ bundler (>= 2.2.25)
216
+ netrc (>= 0.11.0)
217
+ parallel (>= 1.21.0)
218
+ rbi (~> 0.2)
219
+ sorbet-static-and-runtime (>= 0.5.11087)
220
+ spoom (>= 1.2.0)
221
+ thor (>= 1.2.0)
222
+ yard-sorbet
223
+ thor (1.3.2)
224
+ tilt (2.6.0)
225
+ timeout (0.4.3)
119
226
  tzinfo (2.0.6)
120
227
  concurrent-ruby (~> 1.0)
121
- unicode-display_width (2.5.0)
228
+ unicode-display_width (3.1.4)
229
+ unicode-emoji (~> 4.0, >= 4.0.4)
230
+ unicode-emoji (4.0.4)
231
+ uri (1.0.3)
232
+ useragent (0.16.11)
122
233
  yard (0.9.37)
234
+ yard-sorbet (0.9.0)
235
+ sorbet-runtime
236
+ yard
237
+ zeitwerk (2.7.2)
123
238
 
124
239
  PLATFORMS
125
- ruby
240
+ arm64-darwin
241
+ x86_64-darwin
242
+ x86_64-linux
126
243
 
127
244
  DEPENDENCIES
128
245
  activerecord
129
246
  csv
247
+ delayed_job
130
248
  globalid
131
249
  i18n
132
250
  job-iteration!
251
+ logger
133
252
  mocha
134
253
  mysql2!
135
254
  pry
255
+ railties
136
256
  rake
137
257
  redis
138
258
  resque
139
259
  rubocop-shopify
140
260
  sidekiq
141
261
  sorbet-runtime
262
+ tapioca
142
263
  yard
143
264
 
144
265
  BUNDLED WITH
145
- 2.5.14
266
+ 2.6.1
data/README.md CHANGED
@@ -151,7 +151,25 @@ class NestedIterationJob < ApplicationJob
151
151
  end
152
152
  ```
153
153
 
154
- Iteration hooks into Sidekiq and Resque out of the box to support graceful interruption. No extra configuration is required.
154
+ Iteration hooks into most popular queue adapters out of the box to support graceful interruption. No extra configuration is required.
155
+
156
+ ## Supported dependencies
157
+
158
+ Job-iteration currently supports the following queue adapters (in order of implementation):
159
+
160
+ - [Resque](https://github.com/resque/resque)
161
+ - [Sidekiq](https://github.com/sidekiq/sidekiq/)
162
+ - [GoodJob](https://github.com/bensheldon/good_job)
163
+ - [Solid Queue](https://github.com/rails/solid_queue)
164
+ - [Amazon SQS](https://github.com/aws/aws-activejob-sqs-ruby)
165
+ - [Delayed::Job](https://github.com/collectiveidea/delayed_job)
166
+
167
+ It supports the following platforms:
168
+
169
+ - Ruby 3.0 and later
170
+ - Rails 6.1 and later
171
+
172
+ Support for older platforms that have reached end of life may occasionally be dropped if maintaining backwards compatibility is cumbersome.
155
173
 
156
174
  ## Guides
157
175
 
@@ -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 = ">= 2.6"
8
+ spec.required_ruby_version = ">= 3.0"
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", ">= 5.2")
29
+ spec.add_dependency("activejob", ">= 6.1")
30
30
  end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ begin
4
+ require "delayed_job"
5
+ rescue LoadError
6
+ # DelayedJobb is not available, no need to load the adapter
7
+ return
8
+ end
9
+
10
+ begin
11
+ # Delayed::Worker#stop? was introduced in DelayedJob 3.0.3
12
+ gem("delayed_job", ">= 3.0.3")
13
+ rescue Gem::LoadError
14
+ warn("job-iteration's interruption adapter for DelayedJob requires DelayedJob 3.0.3 or newer")
15
+ return
16
+ end
17
+
18
+ module JobIteration
19
+ module InterruptionAdapters
20
+ module DelayedJobAdapter
21
+ class << self
22
+ attr_accessor :delayed_worker, :delayed_worker_started
23
+
24
+ def call
25
+ if delayed_worker_started
26
+ delayed_worker.nil? || delayed_worker.stop?
27
+ else
28
+ false
29
+ end
30
+ end
31
+ end
32
+
33
+ self.delayed_worker_started = false
34
+
35
+ class DelayedJobPlugin < Delayed::Plugin
36
+ callbacks do |lifecycle|
37
+ lifecycle.before(:execute) do |worker|
38
+ DelayedJobAdapter.delayed_worker = worker
39
+ DelayedJobAdapter.delayed_worker_started = true
40
+ end
41
+
42
+ lifecycle.after(:execute) do |_worker|
43
+ DelayedJobAdapter.delayed_worker = nil
44
+ end
45
+ end
46
+ end
47
+ private_constant :DelayedJobPlugin
48
+
49
+ Delayed::Worker.plugins << DelayedJobPlugin
50
+ end
51
+
52
+ register(:delayed_job, DelayedJobAdapter)
53
+ end
54
+ end
@@ -4,7 +4,7 @@ require_relative "interruption_adapters/null_adapter"
4
4
 
5
5
  module JobIteration
6
6
  module InterruptionAdapters
7
- BUNDLED_ADAPTERS = [:good_job, :resque, :sidekiq, :solid_queue, :sqs].freeze # @api private
7
+ BUNDLED_ADAPTERS = [:delayed_job, :good_job, :resque, :sidekiq, :solid_queue, :sqs].freeze # @api private
8
8
 
9
9
  class << self
10
10
  # Returns adapter for specified name.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JobIteration
4
- VERSION = "1.8.0"
4
+ VERSION = "1.10.0"
5
5
  end
@@ -0,0 +1,120 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ return unless defined?(JobIteration::Iteration)
5
+
6
+ module Tapioca
7
+ module Dsl
8
+ module Compilers
9
+ class JobIteration < Compiler
10
+ extend T::Sig
11
+
12
+ ConstantType = type_member { { fixed: T.class_of(::JobIteration::Iteration) } }
13
+ PARAM_TYPES_IN_ORDER = [
14
+ RBI::Param,
15
+ RBI::OptParam,
16
+ RBI::RestParam,
17
+ RBI::KwParam,
18
+ RBI::KwOptParam,
19
+ RBI::KwRestParam,
20
+ RBI::BlockParam,
21
+ ].freeze
22
+
23
+ sig { override.void }
24
+ def decorate
25
+ return unless constant.instance_methods(false).include?(:build_enumerator)
26
+
27
+ root.create_path(constant) do |job|
28
+ method = constant.instance_method(:build_enumerator)
29
+ constant_name = name_of(constant)
30
+ signature = signature_of(method)
31
+
32
+ parameters = compile_method_parameters_to_rbi(method).reject do |typed_param|
33
+ typed_param.param.name == "cursor"
34
+ end
35
+
36
+ if signature
37
+ fixed_hash_args = signature.arg_types.select { |arg_type| T::Types::FixedHash === arg_type[1] }.to_h
38
+ expanded_parameters = parameters.flat_map do |typed_param|
39
+ if (hash_type = fixed_hash_args[typed_param.param.name.to_sym])
40
+ hash_type.types.map do |key, value|
41
+ if value.name.start_with?("T.nilable")
42
+ create_kw_opt_param(key.to_s, type: value.to_s, default: "nil")
43
+ else
44
+ create_kw_param(key.to_s, type: value.to_s)
45
+ end
46
+ end
47
+ else
48
+ typed_param
49
+ end
50
+ end
51
+ else
52
+ expanded_parameters = parameters
53
+ end
54
+
55
+ # Sorbet expects optional keyword arguments to be after required keyword arguments.
56
+ expanded_parameters.sort_by! { |typed_param| PARAM_TYPES_IN_ORDER.index(typed_param.param.class) }
57
+
58
+ number_of_generic_type_members = Tapioca::Runtime::GenericTypeRegistry.lookup_type_variables(constant)&.size
59
+
60
+ returned_job_class = if number_of_generic_type_members&.nonzero?
61
+ "#{constant_name}[#{number_of_generic_type_members.times.map { "T.untyped" }.join(", ")}]"
62
+ else
63
+ constant_name
64
+ end
65
+
66
+ job.create_method(
67
+ "perform_later",
68
+ parameters: perform_later_parameters(expanded_parameters, returned_job_class),
69
+ return_type: "T.any(#{returned_job_class}, FalseClass)",
70
+ class_method: true,
71
+ )
72
+
73
+ job.create_method(
74
+ "perform_now",
75
+ parameters: expanded_parameters,
76
+ return_type: "T.any(NilClass, Exception)",
77
+ class_method: true,
78
+ )
79
+
80
+ job.create_method(
81
+ "perform",
82
+ parameters: expanded_parameters,
83
+ return_type: "void",
84
+ class_method: false,
85
+ )
86
+ end
87
+ end
88
+
89
+ private
90
+
91
+ sig do
92
+ params(
93
+ parameters: T::Array[RBI::TypedParam],
94
+ returned_job_class: String,
95
+ ).returns(T::Array[RBI::TypedParam])
96
+ end
97
+ def perform_later_parameters(parameters, returned_job_class)
98
+ if ::Gem::Requirement.new(">= 7.0").satisfied_by?(::ActiveJob.gem_version)
99
+ parameters.reject! { |typed_param| RBI::BlockParam === typed_param.param }
100
+ parameters + [create_block_param(
101
+ "block",
102
+ type: "T.nilable(T.proc.params(job: #{returned_job_class}).void)",
103
+ )]
104
+ else
105
+ parameters
106
+ end
107
+ end
108
+
109
+ class << self
110
+ extend T::Sig
111
+
112
+ sig { override.returns(T::Enumerable[Module]) }
113
+ def gather_constants
114
+ all_classes.select { |c| ::JobIteration::Iteration > c }
115
+ end
116
+ end
117
+ end
118
+ end
119
+ end
120
+ end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: job-iteration
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.0
4
+ version: 1.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2024-12-10 00:00:00.000000000 Z
10
+ date: 2025-03-20 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: activejob
@@ -16,14 +15,14 @@ dependencies:
16
15
  requirements:
17
16
  - - ">="
18
17
  - !ruby/object:Gem::Version
19
- version: '5.2'
18
+ version: '6.1'
20
19
  type: :runtime
21
20
  prerelease: false
22
21
  version_requirements: !ruby/object:Gem::Requirement
23
22
  requirements:
24
23
  - - ">="
25
24
  - !ruby/object:Gem::Version
26
- version: '5.2'
25
+ version: '6.1'
27
26
  description: Makes your background jobs interruptible and resumable.
28
27
  email:
29
28
  - ops-accounts+shipit@shopify.com
@@ -62,6 +61,7 @@ files:
62
61
  - lib/job-iteration/csv_enumerator.rb
63
62
  - lib/job-iteration/enumerator_builder.rb
64
63
  - lib/job-iteration/interruption_adapters.rb
64
+ - lib/job-iteration/interruption_adapters/delayed_job_adapter.rb
65
65
  - lib/job-iteration/interruption_adapters/good_job_adapter.rb
66
66
  - lib/job-iteration/interruption_adapters/null_adapter.rb
67
67
  - lib/job-iteration/interruption_adapters/resque_adapter.rb
@@ -75,13 +75,13 @@ files:
75
75
  - lib/job-iteration/test_helper.rb
76
76
  - lib/job-iteration/throttle_enumerator.rb
77
77
  - lib/job-iteration/version.rb
78
+ - lib/tapioca/dsl/compilers/job_iteration.rb
78
79
  homepage: https://github.com/shopify/job-iteration
79
80
  licenses:
80
81
  - MIT
81
82
  metadata:
82
83
  changelog_uri: https://github.com/Shopify/job-iteration/blob/main/CHANGELOG.md
83
84
  allowed_push_host: https://rubygems.org
84
- post_install_message:
85
85
  rdoc_options: []
86
86
  require_paths:
87
87
  - lib
@@ -89,15 +89,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
89
89
  requirements:
90
90
  - - ">="
91
91
  - !ruby/object:Gem::Version
92
- version: '2.6'
92
+ version: '3.0'
93
93
  required_rubygems_version: !ruby/object:Gem::Requirement
94
94
  requirements:
95
95
  - - ">="
96
96
  - !ruby/object:Gem::Version
97
97
  version: '0'
98
98
  requirements: []
99
- rubygems_version: 3.5.23
100
- signing_key:
99
+ rubygems_version: 3.6.6
101
100
  specification_version: 4
102
101
  summary: Makes your background jobs interruptible and resumable.
103
102
  test_files: []