job-iteration 0.9.1 → 0.9.2

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
  SHA1:
3
- metadata.gz: 744271afc9d1de8f525a2228d4969e182118affa
4
- data.tar.gz: fa9d46fc8fbafba32134de730525d2ada4efc784
3
+ metadata.gz: 86ee54cb82b9d6c5e1b97b9bf2e01eed332ce87c
4
+ data.tar.gz: f05e54ca8459b37f472bfcd4f9cf47d9a005dc8b
5
5
  SHA512:
6
- metadata.gz: 83e1ca25924c4d273b1ed5a19eed81565479f90aaebdadd50c12c5c19643437bfc330798328dc10abc1a10f7fc63b755cbcbd2c5d34e162a4ff723979757edb9
7
- data.tar.gz: 34b83d31905e210800ca4237bb786c1492842e80e3aeadad137dae40e96b9eb92d675521c8941c4c43ae419e2e0967d2b1389220164c803954eb800abc449ef8
6
+ metadata.gz: aabb890775e006f0097bb886fddd6c9bdbeb442616e5fbb0c12d96ad8fe453ca1119ac1018cab36b9756188a0ccd28944a3e836032b1099a899f54b078c7ba64
7
+ data.tar.gz: 5133e2eff873e88d009aa255d3eb01bde85b589e24e9f1f660dbe60f15022c24585dded574b3a397ff8fb503dc97fda55b13f1ad24be5fadd1917a94c474c564
@@ -11,4 +11,5 @@ before_install:
11
11
  script:
12
12
  - bundle exec rake test
13
13
  - bundle exec rubocop
14
+ - bundle exec yardoc --no-output --no-save --no-stats --fail-on-warning
14
15
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- job-iteration (0.9.1)
4
+ job-iteration (0.9.2)
5
5
  activejob (~> 5.2)
6
6
 
7
7
  GEM
@@ -11,9 +11,30 @@ module JobIteration
11
11
 
12
12
  extend self
13
13
 
14
- attr_accessor :max_job_runtime, :interruption_adapter
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:, columns: nil, batch_size: nil)
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
- columns: columns,
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:, columns: nil, batch_size: nil)
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
- columns: columns,
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:, columns:, batch_size:)
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
- columns: columns,
140
- batch_size: batch_size,
141
- cursor: cursor,
142
- }.compact
136
+ cursor: cursor,
137
+ **args
143
138
  )
144
139
  end
145
140
  end
@@ -75,7 +75,7 @@ module JobIteration
75
75
  private
76
76
 
77
77
  def enumerator_builder
78
- JobIteration::EnumeratorBuilder.new(self)
78
+ JobIteration.enumerator_builder.new(self)
79
79
  end
80
80
 
81
81
  def interruptible_perform(*arguments)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JobIteration
4
- VERSION = "0.9.1"
4
+ VERSION = "0.9.2"
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: 0.9.1
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-14 00:00:00.000000000 Z
11
+ date: 2018-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activejob