job-iteration 0.9.8 → 1.0.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 +4 -4
- data/.gitignore +2 -0
- data/.travis.yml +4 -5
- data/CHANGELOG.md +12 -0
- data/Gemfile +1 -0
- data/README.md +1 -1
- data/dev.yml +1 -1
- data/gemfiles/{activejob_5_2.gemfile → rails_5_2.gemfile} +1 -0
- data/gemfiles/{activejob_edge.gemfile → rails_edge.gemfile} +0 -0
- data/job-iteration.gemspec +0 -5
- data/lib/job-iteration/active_record_enumerator.rb +15 -4
- data/lib/job-iteration/enumerator_builder.rb +1 -0
- data/lib/job-iteration/iteration.rb +3 -7
- data/lib/job-iteration/version.rb +1 -1
- metadata +4 -61
- data/Gemfile.lock +0 -115
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d2d963a3239101fbb564b9864936a7f06413aead04540979b8d3737c7fc1429
|
4
|
+
data.tar.gz: e8b7e4d4d75f263633883d6b24b1af0adfe549b0d8778d2fb57aeb937a482c03
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3140b3feff8927f989a1ac2ad9c118254793e23119aabe56c405e6a35d0bd944ea176f3398e07fd5e1f0f3f43a7eac053bcf4565dfcc23341c1c26a67e58044
|
7
|
+
data.tar.gz: 4b71e936e4801192f62e1990761dcd544425d5fdffb7020bcabe9f0d91778c50b599d14f341ce04b8491797dff774b02ee26db8ff6dbc8ed1f1a2f0b42d2aa56
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -3,10 +3,9 @@ services:
|
|
3
3
|
- redis-server
|
4
4
|
language: ruby
|
5
5
|
rvm:
|
6
|
-
- 2.
|
7
|
-
- 2.
|
6
|
+
- 2.5.5
|
7
|
+
- 2.6.2
|
8
8
|
before_install:
|
9
|
-
- gem install bundler
|
10
9
|
- mysql -e 'CREATE DATABASE job_iteration_test;'
|
11
10
|
script:
|
12
11
|
- bundle exec rake test
|
@@ -14,5 +13,5 @@ script:
|
|
14
13
|
- bundle exec yardoc --no-output --no-save --no-stats --fail-on-warning
|
15
14
|
|
16
15
|
gemfile:
|
17
|
-
- 'gemfiles/
|
18
|
-
- 'gemfiles/
|
16
|
+
- 'gemfiles/rails_5_2.gemfile'
|
17
|
+
- 'gemfiles/rails_edge.gemfile'
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,18 @@
|
|
4
4
|
|
5
5
|
#### Bug fix
|
6
6
|
|
7
|
+
### v1.0.0 (April 29, 2019)
|
8
|
+
|
9
|
+
It’s been in production at Shopify since 2017. It has support for Rails 5 and 6 :tada:
|
10
|
+
|
11
|
+
### Deprecations
|
12
|
+
|
13
|
+
- [34](https://github.com/Shopify/job-iteration/pull/34) - remove supports_interruption?
|
14
|
+
|
15
|
+
### Internal
|
16
|
+
|
17
|
+
- [30](https://github.com/Shopify/job-iteration/pull/30) - Better #each_iteration argument names
|
18
|
+
|
7
19
|
### v0.9.8 (December 5, 2018)
|
8
20
|
|
9
21
|
#### Bug fix
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -195,4 +195,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
195
195
|
|
196
196
|
## Code of Conduct
|
197
197
|
|
198
|
-
Everyone interacting in the Job::Iteration project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/
|
198
|
+
Everyone interacting in the Job::Iteration project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/Shopify/job-iteration/blob/master/CODE_OF_CONDUCT.md).
|
data/dev.yml
CHANGED
File without changes
|
data/job-iteration.gemspec
CHANGED
@@ -25,9 +25,4 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.metadata["changelog_uri"] = "https://github.com/Shopify/job-iteration/blob/master/CHANGELOG.md"
|
26
26
|
|
27
27
|
spec.add_dependency("activejob", ">= 5.2")
|
28
|
-
|
29
|
-
spec.add_development_dependency("bundler", "~> 1.16")
|
30
|
-
spec.add_development_dependency("rake", "~> 10.0")
|
31
|
-
spec.add_development_dependency("minitest", "~> 5.0")
|
32
|
-
spec.add_development_dependency("activerecord")
|
33
28
|
end
|
@@ -4,6 +4,8 @@ module JobIteration
|
|
4
4
|
# Builds Enumerator based on ActiveRecord Relation. Supports enumerating on rows and batches.
|
5
5
|
# @see EnumeratorBuilder
|
6
6
|
class ActiveRecordEnumerator
|
7
|
+
SQL_DATETIME_WITH_NSEC = "%Y-%m-%d %H:%M:%S.%N"
|
8
|
+
|
7
9
|
def initialize(relation, columns: nil, batch_size: 100, cursor: nil)
|
8
10
|
@relation = relation
|
9
11
|
@batch_size = batch_size
|
@@ -24,7 +26,7 @@ module JobIteration
|
|
24
26
|
def batches
|
25
27
|
cursor = finder_cursor
|
26
28
|
Enumerator.new(method(:size)) do |yielder|
|
27
|
-
while records = cursor.next_batch(@batch_size)
|
29
|
+
while (records = cursor.next_batch(@batch_size))
|
28
30
|
yielder.yield(records, cursor_value(records.last)) if records.any?
|
29
31
|
end
|
30
32
|
end
|
@@ -38,9 +40,8 @@ module JobIteration
|
|
38
40
|
|
39
41
|
def cursor_value(record)
|
40
42
|
positions = @columns.map do |column|
|
41
|
-
|
42
|
-
|
43
|
-
attribute.is_a?(Time) ? attribute.to_s(:db) : attribute
|
43
|
+
attribute_name = column.to_s.split('.').last
|
44
|
+
column_value(record, attribute_name)
|
44
45
|
end
|
45
46
|
return positions.first if positions.size == 1
|
46
47
|
positions
|
@@ -49,5 +50,15 @@ module JobIteration
|
|
49
50
|
def finder_cursor
|
50
51
|
JobIteration::ActiveRecordCursor.new(@relation, @columns, @cursor)
|
51
52
|
end
|
53
|
+
|
54
|
+
def column_value(record, attribute)
|
55
|
+
value = record.read_attribute(attribute.to_sym)
|
56
|
+
case record.class.columns_hash.fetch(attribute).type
|
57
|
+
when :datetime
|
58
|
+
value.strftime(SQL_DATETIME_WITH_NSEC)
|
59
|
+
else
|
60
|
+
value
|
61
|
+
end
|
62
|
+
end
|
52
63
|
end
|
53
64
|
end
|
@@ -36,10 +36,6 @@ module JobIteration
|
|
36
36
|
set_callback(:complete, :after, *filters, &blk)
|
37
37
|
end
|
38
38
|
|
39
|
-
def supports_interruption?
|
40
|
-
true
|
41
|
-
end
|
42
|
-
|
43
39
|
private
|
44
40
|
|
45
41
|
def ban_perform_definition
|
@@ -73,7 +69,7 @@ module JobIteration
|
|
73
69
|
end
|
74
70
|
|
75
71
|
def retry_job(*)
|
76
|
-
super unless @retried
|
72
|
+
super unless defined?(@retried) && @retried
|
77
73
|
@retried = true
|
78
74
|
end
|
79
75
|
|
@@ -121,9 +117,9 @@ module JobIteration
|
|
121
117
|
|
122
118
|
def iterate_with_enumerator(enumerator, arguments)
|
123
119
|
arguments = arguments.dup.freeze
|
124
|
-
enumerator.each do |
|
120
|
+
enumerator.each do |object_from_enumerator, index|
|
125
121
|
record_unit_of_work do
|
126
|
-
each_iteration(
|
122
|
+
each_iteration(object_from_enumerator, *arguments)
|
127
123
|
self.cursor_position = index
|
128
124
|
end
|
129
125
|
|
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.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shopify
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activejob
|
@@ -24,62 +24,6 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '5.2'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: bundler
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '1.16'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '1.16'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rake
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '10.0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '10.0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: minitest
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '5.0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '5.0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: activerecord
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
27
|
description: Makes your background jobs interruptible and resumable.
|
84
28
|
email:
|
85
29
|
- ops-accounts+shipit@shopify.com
|
@@ -94,14 +38,13 @@ files:
|
|
94
38
|
- CHANGELOG.md
|
95
39
|
- CODE_OF_CONDUCT.md
|
96
40
|
- Gemfile
|
97
|
-
- Gemfile.lock
|
98
41
|
- LICENSE.txt
|
99
42
|
- README.md
|
100
43
|
- Rakefile
|
101
44
|
- bin/setup
|
102
45
|
- dev.yml
|
103
|
-
- gemfiles/
|
104
|
-
- gemfiles/
|
46
|
+
- gemfiles/rails_5_2.gemfile
|
47
|
+
- gemfiles/rails_edge.gemfile
|
105
48
|
- guides/best-practices.md
|
106
49
|
- guides/custom-enumerator.md
|
107
50
|
- guides/iteration-how-it-works.md
|
data/Gemfile.lock
DELETED
@@ -1,115 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
job-iteration (0.9.8)
|
5
|
-
activejob (>= 5.2)
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: https://rubygems.org/
|
9
|
-
specs:
|
10
|
-
activejob (5.2.0)
|
11
|
-
activesupport (= 5.2.0)
|
12
|
-
globalid (>= 0.3.6)
|
13
|
-
activemodel (5.2.0)
|
14
|
-
activesupport (= 5.2.0)
|
15
|
-
activerecord (5.2.0)
|
16
|
-
activemodel (= 5.2.0)
|
17
|
-
activesupport (= 5.2.0)
|
18
|
-
arel (>= 9.0)
|
19
|
-
activesupport (5.2.0)
|
20
|
-
concurrent-ruby (~> 1.0, >= 1.0.2)
|
21
|
-
i18n (>= 0.7, < 2)
|
22
|
-
minitest (~> 5.1)
|
23
|
-
tzinfo (~> 1.1)
|
24
|
-
arel (9.0.0)
|
25
|
-
ast (2.4.0)
|
26
|
-
coderay (1.1.2)
|
27
|
-
concurrent-ruby (1.0.5)
|
28
|
-
connection_pool (2.2.2)
|
29
|
-
database_cleaner (1.7.0)
|
30
|
-
globalid (0.4.1)
|
31
|
-
activesupport (>= 4.2.0)
|
32
|
-
i18n (1.0.1)
|
33
|
-
concurrent-ruby (~> 1.0)
|
34
|
-
jaro_winkler (1.5.1)
|
35
|
-
metaclass (0.0.4)
|
36
|
-
method_source (0.9.0)
|
37
|
-
minitest (5.11.3)
|
38
|
-
mocha (1.5.0)
|
39
|
-
metaclass (~> 0.0.1)
|
40
|
-
mono_logger (1.1.0)
|
41
|
-
multi_json (1.13.1)
|
42
|
-
mustermann (1.0.2)
|
43
|
-
mysql2 (0.4.10)
|
44
|
-
parallel (1.12.1)
|
45
|
-
parser (2.5.1.0)
|
46
|
-
ast (~> 2.4.0)
|
47
|
-
powerpack (0.1.2)
|
48
|
-
pry (0.11.3)
|
49
|
-
coderay (~> 1.1.0)
|
50
|
-
method_source (~> 0.9.0)
|
51
|
-
rack (2.0.5)
|
52
|
-
rack-protection (2.0.3)
|
53
|
-
rack
|
54
|
-
rainbow (3.0.0)
|
55
|
-
rake (10.5.0)
|
56
|
-
redis (4.0.1)
|
57
|
-
redis-namespace (1.6.0)
|
58
|
-
redis (>= 3.0.4)
|
59
|
-
resque (1.27.4)
|
60
|
-
mono_logger (~> 1.0)
|
61
|
-
multi_json (~> 1.0)
|
62
|
-
redis-namespace (~> 1.3)
|
63
|
-
sinatra (>= 0.9.2)
|
64
|
-
vegas (~> 0.1.2)
|
65
|
-
rubocop (0.57.2)
|
66
|
-
jaro_winkler (~> 1.5.1)
|
67
|
-
parallel (~> 1.10)
|
68
|
-
parser (>= 2.5)
|
69
|
-
powerpack (~> 0.1)
|
70
|
-
rainbow (>= 2.2.2, < 4.0)
|
71
|
-
ruby-progressbar (~> 1.7)
|
72
|
-
unicode-display_width (~> 1.0, >= 1.0.1)
|
73
|
-
ruby-progressbar (1.9.0)
|
74
|
-
sidekiq (5.1.3)
|
75
|
-
concurrent-ruby (~> 1.0)
|
76
|
-
connection_pool (~> 2.2, >= 2.2.0)
|
77
|
-
rack-protection (>= 1.5.0)
|
78
|
-
redis (>= 3.3.5, < 5)
|
79
|
-
sinatra (2.0.3)
|
80
|
-
mustermann (~> 1.0)
|
81
|
-
rack (~> 2.0)
|
82
|
-
rack-protection (= 2.0.3)
|
83
|
-
tilt (~> 2.0)
|
84
|
-
thread_safe (0.3.6)
|
85
|
-
tilt (2.0.8)
|
86
|
-
tzinfo (1.2.5)
|
87
|
-
thread_safe (~> 0.1)
|
88
|
-
unicode-display_width (1.4.0)
|
89
|
-
vegas (0.1.11)
|
90
|
-
rack (>= 1.0.0)
|
91
|
-
yard (0.9.15)
|
92
|
-
|
93
|
-
PLATFORMS
|
94
|
-
ruby
|
95
|
-
|
96
|
-
DEPENDENCIES
|
97
|
-
activerecord
|
98
|
-
bundler (~> 1.16)
|
99
|
-
database_cleaner
|
100
|
-
globalid
|
101
|
-
i18n
|
102
|
-
job-iteration!
|
103
|
-
minitest (~> 5.0)
|
104
|
-
mocha
|
105
|
-
mysql2 (~> 0.4.4)
|
106
|
-
pry
|
107
|
-
rake (~> 10.0)
|
108
|
-
redis
|
109
|
-
resque
|
110
|
-
rubocop
|
111
|
-
sidekiq
|
112
|
-
yard
|
113
|
-
|
114
|
-
BUNDLED WITH
|
115
|
-
1.17.1
|