job-iteration 1.1.8 → 1.1.9

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: 99e26756140f1346b646a3931dc6cc8de1181a67a27916d9a0d85deb1d4dddeb
4
- data.tar.gz: '058d65ec35e8cebbf74ba37c2227aa63cb1b5fbf183c81ee4c1b4f1cc3a9d033'
3
+ metadata.gz: 1a4821d55797f7597b3c916d6fbca2195c054bd3aab0ffcc40c9ce21ae0b1ec4
4
+ data.tar.gz: e71ce0fb7ec744b502f018ccfc7ea5e819bfe06f9fb2ca5a32c70cc1b875abc7
5
5
  SHA512:
6
- metadata.gz: 86a6a0f8ef55ab7502215fc4efcd6bc6e7b7a0b4737decf470db964d2302705d42ab1d16eff904e0d2c914f7ac30ca66cd2b99fffcb6aeaf1db904619fd89418
7
- data.tar.gz: 7d9c9d5023f56365e2a1040fc7ccbb57f01c73f50c7addeaaedcf64edc2dab5cf2383d56cda46b832cdc6acce367abf87757dbd1113971335f51d675883e4141
6
+ metadata.gz: 943795fabf60cff76fa7b8678f1f5d5a83bd98340194e142092dc891ff1abe991c0410572cebd09155c6c220ff96aa5530fb27e1b4fe119c6bbbf22fe12670ef
7
+ data.tar.gz: 11ea6f0165aa31350c6486236a33d66c94316a08f52905aeaab049388b433c229ccf52e69ae3e43eb8bca9a5c56dc4aae46803aae4add9d2a052d5d49af14d8d
@@ -4,6 +4,10 @@
4
4
 
5
5
  #### Bug fix
6
6
 
7
+ ## v1.1.9 (January 6, 2021)
8
+
9
+ - [61](https://github.com/Shopify/job-iteration/pull/61) Call `super` in `method_added`
10
+
7
11
  ## v1.1.8 (June 8, 2020)
8
12
 
9
13
  - Preserve ruby2_keywords tags in arguments on Ruby 2.7
data/README.md CHANGED
@@ -9,7 +9,7 @@ Meet Iteration, an extension for [ActiveJob](https://github.com/rails/rails/tree
9
9
  Imagine the following job:
10
10
 
11
11
  ```ruby
12
- class SimpleJob < ActiveJob::Base
12
+ class SimpleJob < ApplicationJob
13
13
  def perform
14
14
  User.find_each do |user|
15
15
  user.notify_about_something
@@ -43,7 +43,7 @@ And then execute:
43
43
  In the job, include `JobIteration::Iteration` module and start describing the job with two methods (`build_enumerator` and `each_iteration`) instead of `perform`:
44
44
 
45
45
  ```ruby
46
- class NotifyUsersJob < ActiveJob::Base
46
+ class NotifyUsersJob < ApplicationJob
47
47
  include JobIteration::Iteration
48
48
 
49
49
  def build_enumerator(cursor:)
@@ -64,7 +64,9 @@ end
64
64
  Check out more examples of Iterations:
65
65
 
66
66
  ```ruby
67
- class BatchesJob < ActiveJob::Iteration
67
+ class BatchesJob < ApplicationJob
68
+ include JobIteration::Iteration
69
+
68
70
  def build_enumerator(product_id, cursor:)
69
71
  enumerator_builder.active_record_on_batches(
70
72
  Product.find(product_id).comments,
@@ -81,7 +83,9 @@ end
81
83
  ```
82
84
 
83
85
  ```ruby
84
- class ArrayJob < ActiveJob::Iteration
86
+ class ArrayJob < ApplicationJob
87
+ include JobIteration::Iteration
88
+
85
89
  def build_enumerator(cursor:)
86
90
  enumerator_builder.array(['build', 'enumerator', 'from', 'any', 'array'], cursor: cursor)
87
91
  end
@@ -93,7 +97,9 @@ end
93
97
  ```
94
98
 
95
99
  ```ruby
96
- class CsvJob < ActiveJob::Iteration
100
+ class CsvJob < ApplicationJob
101
+ include JobIteration::Iteration
102
+
97
103
  def build_enumerator(import_id, cursor:)
98
104
  import = Import.find(import_id)
99
105
  JobIteration::CsvEnumerator.new(import.csv).rows(cursor: cursor)
@@ -153,7 +159,7 @@ There a few configuration assumptions that are required for Iteration to work wi
153
159
  **My job has a complex flow. How do I write my own Enumerator?** Iteration API takes care of persisting the cursor (that you may use to calculate an offset) and controlling the job state. The power of Enumerator object is that you can use the cursor in any way you want. One example is a cursorless job that pops records from a datastore until the job is interrupted:
154
160
 
155
161
  ```ruby
156
- class MyJob < ActiveJob::Base
162
+ class MyJob < ApplicationJob
157
163
  include JobIteration::Iteration
158
164
 
159
165
  def build_enumerator(cursor:)
@@ -72,3 +72,5 @@ end
72
72
  ```
73
73
 
74
74
  We recommend that you read the implementation of the other enumerators that come with the library (`CsvEnumerator`, `ActiveRecordEnumerator`) to gain a better understanding of building Enumerator objects.
75
+
76
+ Code that is written after the `yield` in a custom enumerator is not guaranteed to execute. In the case that a job is forced to exit ie `job_should_exit?` is true, then the job is re-enqueued during the yield and the rest of the code in the enumerator does not run. You can follow that logic [here](https://github.com/Shopify/job-iteration/blob/9641f455b9126efff2214692c0bef423e0d12c39/lib/job-iteration/iteration.rb#L128-L131).
@@ -22,6 +22,7 @@ module JobIteration
22
22
  module ClassMethods
23
23
  def method_added(method_name)
24
24
  ban_perform_definition if method_name.to_sym == :perform
25
+ super
25
26
  end
26
27
 
27
28
  def on_start(*filters, &blk)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JobIteration
4
- VERSION = "1.1.8"
4
+ VERSION = "1.1.9"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: job-iteration
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.8
4
+ version: 1.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-08 00:00:00.000000000 Z
11
+ date: 2021-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord