job-iteration 0.9.1 → 0.9.2
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 +4 -4
- data/.travis.yml +1 -0
- data/Gemfile.lock +1 -1
- data/lib/job-iteration.rb +22 -1
- data/lib/job-iteration/enumerator_builder.rb +7 -12
- data/lib/job-iteration/iteration.rb +1 -1
- data/lib/job-iteration/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 86ee54cb82b9d6c5e1b97b9bf2e01eed332ce87c
|
4
|
+
data.tar.gz: f05e54ca8459b37f472bfcd4f9cf47d9a005dc8b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aabb890775e006f0097bb886fddd6c9bdbeb442616e5fbb0c12d96ad8fe453ca1119ac1018cab36b9756188a0ccd28944a3e836032b1099a899f54b078c7ba64
|
7
|
+
data.tar.gz: 5133e2eff873e88d009aa255d3eb01bde85b589e24e9f1f660dbe60f15022c24585dded574b3a397ff8fb503dc97fda55b13f1ad24be5fadd1917a94c474c564
|
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
data/lib/job-iteration.rb
CHANGED
@@ -11,9 +11,30 @@ module JobIteration
|
|
11
11
|
|
12
12
|
extend self
|
13
13
|
|
14
|
-
|
14
|
+
# Use this to _always_ interrupt the job after it's been running for more than N seconds.
|
15
|
+
# @example
|
16
|
+
#
|
17
|
+
# JobIteration.max_job_runtime = 5.minutes
|
18
|
+
#
|
19
|
+
# This setting will make it to always interrupt a job after it's been iterating for 5 minutes.
|
20
|
+
# Defaults to nil which means that jobs will not be interrupted except on termination signal.
|
21
|
+
attr_accessor :max_job_runtime
|
22
|
+
|
23
|
+
# Used internally for hooking into job processing frameworks like Sidekiq and Resque.
|
24
|
+
attr_accessor :interruption_adapter
|
15
25
|
self.interruption_adapter = -> { false }
|
16
26
|
|
27
|
+
# Set if you want to use your own enumerator builder instead of default EnumeratorBuilder.
|
28
|
+
# @example
|
29
|
+
#
|
30
|
+
# class MyOwnBuilder < JobIteration::EnumeratorBuilder
|
31
|
+
# # ...
|
32
|
+
# end
|
33
|
+
#
|
34
|
+
# JobIteration.enumerator_builder = MyOwnBuilder
|
35
|
+
attr_accessor :enumerator_builder
|
36
|
+
self.enumerator_builder = JobIteration::EnumeratorBuilder
|
37
|
+
|
17
38
|
def load_integrations
|
18
39
|
loaded = nil
|
19
40
|
INTEGRATIONS.each do |integration|
|
@@ -94,12 +94,11 @@ module JobIteration
|
|
94
94
|
# WHERE (created_at > '$LAST_CREATED_AT_CURSOR'
|
95
95
|
# OR (created_at = '$LAST_CREATED_AT_CURSOR' AND (id > '$LAST_ID_CURSOR')))
|
96
96
|
# ORDER BY created_at, id LIMIT 100
|
97
|
-
def build_active_record_enumerator_on_records(scope, cursor:,
|
97
|
+
def build_active_record_enumerator_on_records(scope, cursor:, **args)
|
98
98
|
enum = build_active_record_enumerator(
|
99
99
|
scope,
|
100
100
|
cursor: cursor,
|
101
|
-
|
102
|
-
batch_size: batch_size,
|
101
|
+
**args
|
103
102
|
).records
|
104
103
|
wrap(self, enum)
|
105
104
|
end
|
@@ -110,12 +109,11 @@ module JobIteration
|
|
110
109
|
# +batch_size:+ sets how many records will be fetched in one batch. Defaults to 100.
|
111
110
|
#
|
112
111
|
# For the rest of arguments, see documentation for #build_active_record_enumerator_on_records
|
113
|
-
def build_active_record_enumerator_on_batches(scope, cursor:,
|
112
|
+
def build_active_record_enumerator_on_batches(scope, cursor:, **args)
|
114
113
|
enum = build_active_record_enumerator(
|
115
114
|
scope,
|
116
115
|
cursor: cursor,
|
117
|
-
|
118
|
-
batch_size: batch_size,
|
116
|
+
**args
|
119
117
|
).batches
|
120
118
|
wrap(self, enum)
|
121
119
|
end
|
@@ -128,18 +126,15 @@ module JobIteration
|
|
128
126
|
|
129
127
|
private
|
130
128
|
|
131
|
-
def build_active_record_enumerator(scope, cursor:,
|
129
|
+
def build_active_record_enumerator(scope, cursor:, **args)
|
132
130
|
unless scope.is_a?(ActiveRecord::Relation)
|
133
131
|
raise ArgumentError, "scope must be an ActiveRecord::Relation"
|
134
132
|
end
|
135
133
|
|
136
134
|
JobIteration::ActiveRecordEnumerator.new(
|
137
135
|
scope,
|
138
|
-
|
139
|
-
|
140
|
-
batch_size: batch_size,
|
141
|
-
cursor: cursor,
|
142
|
-
}.compact
|
136
|
+
cursor: cursor,
|
137
|
+
**args
|
143
138
|
)
|
144
139
|
end
|
145
140
|
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: 0.9.
|
4
|
+
version: 0.9.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shopify
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-08-
|
11
|
+
date: 2018-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activejob
|