job-iteration 1.1.9 → 1.1.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +47 -0
- data/.rubocop.yml +2 -2
- data/CHANGELOG.md +4 -0
- data/Gemfile +13 -13
- data/gemfiles/rails_5_2.gemfile +3 -3
- data/gemfiles/rails_6_0.gemfile +3 -3
- data/gemfiles/rails_edge.gemfile +3 -3
- data/job-iteration.gemspec +1 -1
- data/lib/job-iteration.rb +2 -2
- data/lib/job-iteration/active_record_cursor.rb +6 -4
- data/lib/job-iteration/active_record_enumerator.rb +1 -1
- data/lib/job-iteration/integrations/resque.rb +1 -1
- data/lib/job-iteration/integrations/sidekiq.rb +1 -1
- data/lib/job-iteration/iteration.rb +7 -7
- data/lib/job-iteration/version.rb +1 -1
- metadata +3 -3
- data/.travis.yml +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7868f8da1aee096abee4d4a1848c2242d0a7ac9bb1b456ad8385cfe6421a902e
|
4
|
+
data.tar.gz: fd82a4cdfcbff16220363e1c53aa064b0cd5e599e17290aa968fdb01d8fe4002
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42a601bb25a38571c97d108a8847317892a5289e2d3f8d818b68c99a49fc6d142dffcdd9191350261a89db65bf24aa3b0691057238f2416e2a0140bf16c47485
|
7
|
+
data.tar.gz: 364868992c7fe4602f31d453891f4597d73d0b7b76482510d7ae9d3d3de7baf951465c5df7fcf9923592abb05b3584a9206f104bd610ab52dbbf3625c03be3f6
|
@@ -0,0 +1,47 @@
|
|
1
|
+
name: Ruby
|
2
|
+
|
3
|
+
on: [push]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
name: Ruby ${{ matrix.ruby }}
|
9
|
+
services:
|
10
|
+
redis:
|
11
|
+
image: redis
|
12
|
+
ports:
|
13
|
+
- 6379:6379
|
14
|
+
strategy:
|
15
|
+
matrix:
|
16
|
+
ruby: [2.5, 2.6, 2.7, 3.0]
|
17
|
+
gemfile: [rails_5_2, rails_6_0, rails_edge]
|
18
|
+
exclude:
|
19
|
+
- ruby: 2.5
|
20
|
+
gemfile: rails_edge
|
21
|
+
- ruby: 2.6
|
22
|
+
gemfile: rails_edge
|
23
|
+
- ruby: 3.0
|
24
|
+
gemfile: rails_5_2
|
25
|
+
env:
|
26
|
+
BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile
|
27
|
+
steps:
|
28
|
+
- name: Check out code
|
29
|
+
uses: actions/checkout@v2
|
30
|
+
- name: Set up Ruby ${{ matrix.ruby }}
|
31
|
+
uses: ruby/setup-ruby@v1
|
32
|
+
with:
|
33
|
+
ruby-version: ${{ matrix.ruby }}
|
34
|
+
bundler-cache: true
|
35
|
+
- name: Start MySQL and create DB
|
36
|
+
run: |
|
37
|
+
sudo systemctl start mysql.service
|
38
|
+
mysql -uroot -h localhost -proot -e "CREATE DATABASE job_iteration_test;"
|
39
|
+
- name: Rubocop
|
40
|
+
run: bundle exec rubocop
|
41
|
+
- name: Ruby tests
|
42
|
+
run: bundle exec rake test
|
43
|
+
env:
|
44
|
+
REDIS_HOST: localhost
|
45
|
+
REDIS_PORT: ${{ job.services.redis.ports[6379] }}
|
46
|
+
- name: Documentation correctly written
|
47
|
+
run: bundle exec yardoc --no-output --no-save --no-stats --fail-on-warning
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,10 @@
|
|
4
4
|
|
5
5
|
#### Bug fix
|
6
6
|
|
7
|
+
## v1.1.10 (March 30, 2021)
|
8
|
+
|
9
|
+
- [69](https://github.com/Shopify/job-iteration/pull/69) Fix memory leak in ActiveRecordCursor
|
10
|
+
|
7
11
|
## v1.1.9 (January 6, 2021)
|
8
12
|
|
9
13
|
- [61](https://github.com/Shopify/job-iteration/pull/61) Call `super` in `method_added`
|
data/Gemfile
CHANGED
@@ -8,21 +8,21 @@ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
|
8
8
|
gemspec
|
9
9
|
|
10
10
|
# for integration testing
|
11
|
-
gem
|
12
|
-
gem
|
11
|
+
gem "sidekiq"
|
12
|
+
gem "resque"
|
13
13
|
|
14
|
-
gem
|
15
|
-
gem
|
16
|
-
gem
|
17
|
-
gem
|
18
|
-
gem
|
14
|
+
gem "mysql2", "~> 0.5"
|
15
|
+
gem "globalid"
|
16
|
+
gem "i18n"
|
17
|
+
gem "redis"
|
18
|
+
gem "database_cleaner"
|
19
19
|
|
20
|
-
gem
|
21
|
-
gem
|
20
|
+
gem "pry"
|
21
|
+
gem "mocha"
|
22
22
|
|
23
|
-
gem
|
24
|
-
gem
|
25
|
-
gem
|
23
|
+
gem "rubocop-shopify", require: false
|
24
|
+
gem "yard"
|
25
|
+
gem "rake"
|
26
26
|
|
27
27
|
# for unit testing optional sorbet support
|
28
|
-
gem
|
28
|
+
gem "sorbet-runtime"
|
data/gemfiles/rails_5_2.gemfile
CHANGED
data/gemfiles/rails_6_0.gemfile
CHANGED
data/gemfiles/rails_edge.gemfile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
eval_gemfile
|
3
|
+
eval_gemfile "../Gemfile"
|
4
4
|
|
5
|
-
gem
|
6
|
-
gem
|
5
|
+
gem "activejob", github: "rails/rails", branch: "main"
|
6
|
+
gem "activerecord", github: "rails/rails", branch: "main"
|
data/job-iteration.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.authors = %w(Shopify)
|
11
11
|
spec.email = ["ops-accounts+shipit@shopify.com"]
|
12
12
|
|
13
|
-
spec.summary =
|
13
|
+
spec.summary = "Makes your background jobs interruptible and resumable."
|
14
14
|
spec.description = spec.summary
|
15
15
|
spec.homepage = "https://github.com/shopify/job-iteration"
|
16
16
|
spec.license = "MIT"
|
data/lib/job-iteration.rb
CHANGED
@@ -54,11 +54,11 @@ module JobIteration
|
|
54
54
|
def load_integration(integration)
|
55
55
|
unless INTEGRATIONS.include?(integration)
|
56
56
|
raise IntegrationLoadError,
|
57
|
-
"#{integration} integration is not supported. Available integrations: #{INTEGRATIONS.join(
|
57
|
+
"#{integration} integration is not supported. Available integrations: #{INTEGRATIONS.join(", ")}"
|
58
58
|
end
|
59
59
|
|
60
60
|
require_relative "./job-iteration/integrations/#{integration}"
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
|
-
JobIteration.load_integrations unless ENV[
|
64
|
+
JobIteration.load_integrations unless ENV["ITERATION_DISABLE_AUTOCONFIGURE"]
|
@@ -23,7 +23,7 @@ module JobIteration
|
|
23
23
|
@columns = Array.wrap(columns)
|
24
24
|
self.position = Array.wrap(position)
|
25
25
|
raise ArgumentError, "Must specify at least one column" if columns.empty?
|
26
|
-
if relation.joins_values.present? && !@columns.all? { |column| column.to_s.include?(
|
26
|
+
if relation.joins_values.present? && !@columns.all? { |column| column.to_s.include?(".") }
|
27
27
|
raise ArgumentError, "You need to specify fully-qualified columns if you join a table"
|
28
28
|
end
|
29
29
|
|
@@ -31,7 +31,7 @@ module JobIteration
|
|
31
31
|
raise ConditionNotSupportedError
|
32
32
|
end
|
33
33
|
|
34
|
-
@base_relation = relation.reorder(@columns.join(
|
34
|
+
@base_relation = relation.reorder(@columns.join(","))
|
35
35
|
@reached_end = false
|
36
36
|
end
|
37
37
|
|
@@ -50,7 +50,7 @@ module JobIteration
|
|
50
50
|
|
51
51
|
def update_from_record(record)
|
52
52
|
self.position = @columns.map do |column|
|
53
|
-
method = column.to_s.split(
|
53
|
+
method = column.to_s.split(".").last
|
54
54
|
record.send(method.to_sym)
|
55
55
|
end
|
56
56
|
end
|
@@ -64,7 +64,9 @@ module JobIteration
|
|
64
64
|
relation = relation.where(*conditions)
|
65
65
|
end
|
66
66
|
|
67
|
-
records = relation.
|
67
|
+
records = relation.uncached do
|
68
|
+
relation.to_a
|
69
|
+
end
|
68
70
|
|
69
71
|
update_from_record(records.last) unless records.empty?
|
70
72
|
@reached_end = records.size < batch_size
|
@@ -40,7 +40,7 @@ module JobIteration
|
|
40
40
|
|
41
41
|
def cursor_value(record)
|
42
42
|
positions = @columns.map do |column|
|
43
|
-
attribute_name = column.to_s.split(
|
43
|
+
attribute_name = column.to_s.split(".").last
|
44
44
|
column_value(record, attribute_name)
|
45
45
|
end
|
46
46
|
return positions.first if positions.size == 1
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "active_support/all"
|
4
4
|
|
5
5
|
module JobIteration
|
6
6
|
module Iteration
|
@@ -54,17 +54,17 @@ module JobIteration
|
|
54
54
|
|
55
55
|
def serialize # @private
|
56
56
|
super.merge(
|
57
|
-
|
58
|
-
|
59
|
-
|
57
|
+
"cursor_position" => cursor_position,
|
58
|
+
"times_interrupted" => times_interrupted,
|
59
|
+
"total_time" => total_time,
|
60
60
|
)
|
61
61
|
end
|
62
62
|
|
63
63
|
def deserialize(job_data) # @private
|
64
64
|
super
|
65
|
-
self.cursor_position = job_data[
|
66
|
-
self.times_interrupted = job_data[
|
67
|
-
self.total_time = job_data[
|
65
|
+
self.cursor_position = job_data["cursor_position"]
|
66
|
+
self.times_interrupted = job_data["times_interrupted"] || 0
|
67
|
+
self.total_time = job_data["total_time"] || 0
|
68
68
|
end
|
69
69
|
|
70
70
|
def perform(*params) # @private
|
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.
|
4
|
+
version: 1.1.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shopify
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-03-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -45,9 +45,9 @@ executables: []
|
|
45
45
|
extensions: []
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
|
+
- ".github/workflows/ruby.yml"
|
48
49
|
- ".gitignore"
|
49
50
|
- ".rubocop.yml"
|
50
|
-
- ".travis.yml"
|
51
51
|
- ".yardopts"
|
52
52
|
- CHANGELOG.md
|
53
53
|
- CODE_OF_CONDUCT.md
|
data/.travis.yml
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
services:
|
2
|
-
- mysql
|
3
|
-
- redis-server
|
4
|
-
language: ruby
|
5
|
-
rvm:
|
6
|
-
- 2.5
|
7
|
-
- 2.6
|
8
|
-
- 2.7
|
9
|
-
before_install:
|
10
|
-
- mysql -e 'CREATE DATABASE job_iteration_test;'
|
11
|
-
script:
|
12
|
-
- bundle exec rake test
|
13
|
-
- bundle exec rubocop
|
14
|
-
- bundle exec yardoc --no-output --no-save --no-stats --fail-on-warning
|
15
|
-
|
16
|
-
gemfile:
|
17
|
-
- 'gemfiles/rails_5_2.gemfile'
|
18
|
-
- 'gemfiles/rails_6_0.gemfile'
|
19
|
-
- 'gemfiles/rails_edge.gemfile'
|