job-iteration 1.8.0 → 1.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a38399b1ad6f7c81b2dd731e39abc75b4febcbac50ea9c310c6c96ada5f802ff
4
- data.tar.gz: 96182f4dcdd4594c9fde855b2394b96a516e7134671a18905ebd3ae6b13ddcfa
3
+ metadata.gz: b32eb2fd6eb2dc54f59eff462a3cde3882192134c2964ffc05b737957e3d4abb
4
+ data.tar.gz: 255864c2fac9d3cc0f75da1929d18c1aeb8e63ff83ea3dc6c19038c0e4894e54
5
5
  SHA512:
6
- metadata.gz: 515d1e0106c1b7c20ce3058df4df1c0c2a29dfb0ebe297bc3ac81da5365b7c8d68cf1058dc5de9c1c37331570260065e59aa86b1801f3b821a70d504aa3b25ac
7
- data.tar.gz: 27303a6ea6910734d7d23f6ef0570cf7b2e6f011b1776731829e8366d93e2ad1032c1fce4bf44dee42e1c253f209f97cda8c761824ab7b81f8bfa51a339b0218
6
+ metadata.gz: 7c241d626e4c92c4424dd08745feab35f1606fafbf6f0d610f34a704d16702a52623f646e5715925b331509257c737053b25bf90091f61a948b6fba2315cc659
7
+ data.tar.gz: 19b821e84f93954cea21b0709455ac5ad12b2633f70c2182ae93e75d2e883a0985dda1cf7c56ac89295caab1720ef3508857201d0c33f18b35ffad76996f093b
@@ -13,6 +13,7 @@ jobs:
13
13
  ports:
14
14
  - 6379:6379
15
15
  strategy:
16
+ fail-fast: false
16
17
  matrix:
17
18
  ruby: ["2.6", "2.7", "3.0", "3.1", "3.2", "3.3"]
18
19
  rails: ["5.2", "6.0", "6.1", "7.0", "7.1", "7.2", "edge"]
data/CHANGELOG.md CHANGED
@@ -12,6 +12,12 @@ nil
12
12
 
13
13
  nil
14
14
 
15
+ ## v1.9.0 (Feb 3, 2024)
16
+
17
+ ### Features
18
+
19
+ - [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`.
20
+
15
21
  ## v1.8.0 (Dec 10, 2024)
16
22
 
17
23
  ### Changes
data/Gemfile CHANGED
@@ -37,3 +37,6 @@ gem "csv" # required for Ruby 3.4+
37
37
 
38
38
  # for unit testing optional sorbet support
39
39
  gem "sorbet-runtime"
40
+ gem "tapioca"
41
+
42
+ 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,121 +8,166 @@ GIT
8
8
  PATH
9
9
  remote: .
10
10
  specs:
11
- job-iteration (1.8.0)
11
+ job-iteration (1.9.0)
12
12
  activejob (>= 5.2)
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
+ activejob (8.0.1)
18
+ activesupport (= 8.0.1)
19
19
  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)
20
+ activemodel (8.0.1)
21
+ activesupport (= 8.0.1)
22
+ activerecord (8.0.1)
23
+ activemodel (= 8.0.1)
24
+ activesupport (= 8.0.1)
25
25
  timeout (>= 0.4.0)
26
- activesupport (7.1.3.4)
26
+ activesupport (8.0.1)
27
27
  base64
28
+ benchmark (>= 0.3)
28
29
  bigdecimal
29
- concurrent-ruby (~> 1.0, >= 1.0.2)
30
+ concurrent-ruby (~> 1.0, >= 1.3.1)
30
31
  connection_pool (>= 2.2.5)
31
32
  drb
32
33
  i18n (>= 1.6, < 2)
34
+ logger (>= 1.4.2)
33
35
  minitest (>= 5.1)
34
- mutex_m
35
- tzinfo (~> 2.0)
36
+ securerandom (>= 0.3)
37
+ tzinfo (~> 2.0, >= 2.0.5)
38
+ uri (>= 0.13.1)
36
39
  ast (2.4.2)
37
40
  base64 (0.2.0)
38
- bigdecimal (3.1.8)
41
+ benchmark (0.4.0)
42
+ bigdecimal (3.1.9)
39
43
  coderay (1.1.3)
40
- concurrent-ruby (1.3.4)
41
- connection_pool (2.4.1)
42
- csv (3.3.0)
44
+ concurrent-ruby (1.3.5)
45
+ connection_pool (2.5.0)
46
+ csv (3.3.2)
43
47
  drb (2.2.1)
48
+ erubi (1.13.1)
44
49
  globalid (1.2.1)
45
50
  activesupport (>= 6.1)
46
- i18n (1.14.6)
51
+ i18n (1.14.7)
47
52
  concurrent-ruby (~> 1.0)
48
- json (2.7.2)
49
- language_server-protocol (3.17.0.3)
53
+ json (2.9.1)
54
+ language_server-protocol (3.17.0.4)
55
+ logger (1.6.5)
50
56
  method_source (1.1.0)
51
- minitest (5.24.0)
52
- mocha (2.7.0)
57
+ minitest (5.25.4)
58
+ mocha (2.7.1)
53
59
  ruby2_keywords (>= 0.0.5)
54
60
  mono_logger (1.1.2)
55
61
  multi_json (1.15.0)
56
- mustermann (3.0.0)
62
+ mustermann (3.0.3)
57
63
  ruby2_keywords (~> 0.0.1)
58
- mutex_m (0.2.0)
59
- parallel (1.25.1)
60
- parser (3.3.3.0)
64
+ netrc (0.11.0)
65
+ parallel (1.26.3)
66
+ parser (3.3.7.0)
61
67
  ast (~> 2.4.1)
62
68
  racc
63
- pry (0.15.0)
69
+ prism (1.3.0)
70
+ pry (0.15.2)
64
71
  coderay (~> 1.1)
65
72
  method_source (~> 1.0)
66
- racc (1.8.0)
67
- rack (3.1.5)
68
- rack-protection (4.0.0)
73
+ racc (1.8.1)
74
+ rack (3.1.8)
75
+ rack-protection (4.1.1)
69
76
  base64 (>= 0.1.0)
77
+ logger (>= 1.6.0)
70
78
  rack (>= 3.0.0, < 4)
71
- rack-session (2.0.0)
79
+ rack-session (2.1.0)
80
+ base64 (>= 0.1.0)
72
81
  rack (>= 3.0.0)
73
82
  rainbow (3.1.1)
74
83
  rake (13.2.1)
84
+ rbi (0.2.4)
85
+ prism (~> 1.0)
86
+ sorbet-runtime (>= 0.5.9204)
75
87
  redis (5.3.0)
76
88
  redis-client (>= 0.22.0)
77
- redis-client (0.22.2)
89
+ redis-client (0.23.2)
78
90
  connection_pool
79
91
  redis-namespace (1.11.0)
80
92
  redis (>= 4)
81
- regexp_parser (2.9.2)
82
- resque (2.6.0)
83
- mono_logger (~> 1.0)
93
+ regexp_parser (2.10.0)
94
+ resque (2.7.0)
95
+ mono_logger (~> 1)
84
96
  multi_json (~> 1.0)
85
97
  redis-namespace (~> 1.6)
86
98
  sinatra (>= 0.9.2)
87
- rexml (3.3.9)
88
- rubocop (1.64.1)
99
+ rubocop (1.71.0)
89
100
  json (~> 2.3)
90
101
  language_server-protocol (>= 3.17.0)
91
102
  parallel (~> 1.10)
92
103
  parser (>= 3.3.0.2)
93
104
  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)
105
+ regexp_parser (>= 2.9.3, < 3.0)
106
+ rubocop-ast (>= 1.36.2, < 2.0)
97
107
  ruby-progressbar (~> 1.7)
98
- unicode-display_width (>= 2.4.0, < 3.0)
99
- rubocop-ast (1.31.3)
108
+ unicode-display_width (>= 2.4.0, < 4.0)
109
+ rubocop-ast (1.38.0)
100
110
  parser (>= 3.3.1.0)
101
111
  rubocop-shopify (2.15.1)
102
112
  rubocop (~> 1.51)
103
113
  ruby-progressbar (1.13.0)
104
114
  ruby2_keywords (0.0.5)
105
- sidekiq (7.2.4)
106
- concurrent-ruby (< 2)
115
+ securerandom (0.4.1)
116
+ sidekiq (7.3.8)
117
+ base64
107
118
  connection_pool (>= 2.3.0)
119
+ logger
108
120
  rack (>= 2.2.4)
109
- redis-client (>= 0.19.0)
110
- sinatra (4.0.0)
121
+ redis-client (>= 0.22.2)
122
+ sinatra (4.1.1)
123
+ logger (>= 1.6.0)
111
124
  mustermann (~> 3.0)
112
125
  rack (>= 3.0.0, < 4)
113
- rack-protection (= 4.0.0)
126
+ rack-protection (= 4.1.1)
114
127
  rack-session (>= 2.0.0, < 3)
115
128
  tilt (~> 2.0)
116
- sorbet-runtime (0.5.11460)
117
- tilt (2.4.0)
118
- timeout (0.4.1)
129
+ sorbet (0.5.11787)
130
+ sorbet-static (= 0.5.11787)
131
+ sorbet-runtime (0.5.11787)
132
+ sorbet-static (0.5.11787-universal-darwin)
133
+ sorbet-static (0.5.11787-x86_64-linux)
134
+ sorbet-static-and-runtime (0.5.11787)
135
+ sorbet (= 0.5.11787)
136
+ sorbet-runtime (= 0.5.11787)
137
+ spoom (1.5.2)
138
+ erubi (>= 1.10.0)
139
+ prism (>= 0.28.0)
140
+ rbi (>= 0.2.3)
141
+ sorbet-static-and-runtime (>= 0.5.10187)
142
+ thor (>= 0.19.2)
143
+ tapioca (0.16.8)
144
+ benchmark
145
+ bundler (>= 2.2.25)
146
+ netrc (>= 0.11.0)
147
+ parallel (>= 1.21.0)
148
+ rbi (~> 0.2)
149
+ sorbet-static-and-runtime (>= 0.5.11087)
150
+ spoom (>= 1.2.0)
151
+ thor (>= 1.2.0)
152
+ yard-sorbet
153
+ thor (1.3.2)
154
+ tilt (2.6.0)
155
+ timeout (0.4.3)
119
156
  tzinfo (2.0.6)
120
157
  concurrent-ruby (~> 1.0)
121
- unicode-display_width (2.5.0)
158
+ unicode-display_width (3.1.4)
159
+ unicode-emoji (~> 4.0, >= 4.0.4)
160
+ unicode-emoji (4.0.4)
161
+ uri (1.0.2)
122
162
  yard (0.9.37)
163
+ yard-sorbet (0.9.0)
164
+ sorbet-runtime
165
+ yard
123
166
 
124
167
  PLATFORMS
125
- ruby
168
+ arm64-darwin
169
+ x86_64-darwin
170
+ x86_64-linux
126
171
 
127
172
  DEPENDENCIES
128
173
  activerecord
@@ -130,6 +175,7 @@ DEPENDENCIES
130
175
  globalid
131
176
  i18n
132
177
  job-iteration!
178
+ logger
133
179
  mocha
134
180
  mysql2!
135
181
  pry
@@ -139,7 +185,8 @@ DEPENDENCIES
139
185
  rubocop-shopify
140
186
  sidekiq
141
187
  sorbet-runtime
188
+ tapioca
142
189
  yard
143
190
 
144
191
  BUNDLED WITH
145
- 2.5.14
192
+ 2.6.1
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JobIteration
4
- VERSION = "1.8.0"
4
+ VERSION = "1.9.0"
5
5
  end
@@ -0,0 +1,112 @@
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
+ job.create_method(
59
+ "perform_later",
60
+ parameters: perform_later_parameters(expanded_parameters, constant_name),
61
+ return_type: "T.any(#{constant_name}, FalseClass)",
62
+ class_method: true,
63
+ )
64
+
65
+ job.create_method(
66
+ "perform_now",
67
+ parameters: expanded_parameters,
68
+ return_type: "T.any(NilClass, Exception)",
69
+ class_method: true,
70
+ )
71
+
72
+ job.create_method(
73
+ "perform",
74
+ parameters: expanded_parameters,
75
+ return_type: "void",
76
+ class_method: false,
77
+ )
78
+ end
79
+ end
80
+
81
+ private
82
+
83
+ sig do
84
+ params(
85
+ parameters: T::Array[RBI::TypedParam],
86
+ constant_name: T.nilable(String),
87
+ ).returns(T::Array[RBI::TypedParam])
88
+ end
89
+ def perform_later_parameters(parameters, constant_name)
90
+ if ::Gem::Requirement.new(">= 7.0").satisfied_by?(::ActiveJob.gem_version)
91
+ parameters.reject! { |typed_param| RBI::BlockParam === typed_param.param }
92
+ parameters + [create_block_param(
93
+ "block",
94
+ type: "T.nilable(T.proc.params(job: #{constant_name}).void)",
95
+ )]
96
+ else
97
+ parameters
98
+ end
99
+ end
100
+
101
+ class << self
102
+ extend T::Sig
103
+
104
+ sig { override.returns(T::Enumerable[Module]) }
105
+ def gather_constants
106
+ all_classes.select { |c| ::JobIteration::Iteration > c }
107
+ end
108
+ end
109
+ end
110
+ end
111
+ end
112
+ 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.9.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-02-03 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: activejob
@@ -75,13 +74,13 @@ files:
75
74
  - lib/job-iteration/test_helper.rb
76
75
  - lib/job-iteration/throttle_enumerator.rb
77
76
  - lib/job-iteration/version.rb
77
+ - lib/tapioca/dsl/compilers/job_iteration.rb
78
78
  homepage: https://github.com/shopify/job-iteration
79
79
  licenses:
80
80
  - MIT
81
81
  metadata:
82
82
  changelog_uri: https://github.com/Shopify/job-iteration/blob/main/CHANGELOG.md
83
83
  allowed_push_host: https://rubygems.org
84
- post_install_message:
85
84
  rdoc_options: []
86
85
  require_paths:
87
86
  - lib
@@ -96,8 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
96
95
  - !ruby/object:Gem::Version
97
96
  version: '0'
98
97
  requirements: []
99
- rubygems_version: 3.5.23
100
- signing_key:
98
+ rubygems_version: 3.6.3
101
99
  specification_version: 4
102
100
  summary: Makes your background jobs interruptible and resumable.
103
101
  test_files: []