rocketjob 4.1.0 → 4.1.1
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/lib/rocket_job/batch/io.rb +12 -0
- data/lib/rocket_job/jobs/on_demand_batch_job.rb +1 -1
- data/lib/rocket_job/jobs/on_demand_job.rb +1 -1
- data/lib/rocket_job/jobs/upload_file_job.rb +7 -2
- data/lib/rocket_job/plugins/retry.rb +3 -18
- data/lib/rocket_job/sliced/input.rb +0 -3
- data/lib/rocket_job/sliced/slices.rb +3 -1
- data/lib/rocket_job/sliced/writer/input.rb +2 -0
- data/lib/rocket_job/supervisor/shutdown.rb +2 -2
- data/lib/rocket_job/version.rb +1 -1
- data/lib/rocket_job/worker_pool.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a88179130b3f8b1570a98c02b22b1daa93d1cfff9e91231f12c08af3eb47c750
|
|
4
|
+
data.tar.gz: e6fc5a6cf000dc9faa61b61bb232aaef6bf77dec144959e6bfb2114e193845db
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cef575bafd6e780beb0c235bfae3efab3c79ae456cf907c1335372f664ccab1ea125cfd9cbcca17a7791b328b97f78750bc039adf80786bf48834d9d1e6079af
|
|
7
|
+
data.tar.gz: dd88230b68ecf82433c641f903fcec276b0e873c8849dd1873ed4ee14cd88d3e99fe93ca4ffaf3f973efca16d6837bb1daf3cb91202176ec909a8c19bf28fc08
|
data/lib/rocket_job/batch/io.rb
CHANGED
|
@@ -65,6 +65,18 @@ module RocketJob
|
|
|
65
65
|
count
|
|
66
66
|
end
|
|
67
67
|
|
|
68
|
+
def upload_arel(arel, *column_names, category: :main, &block)
|
|
69
|
+
count = input(category).upload_arel(arel, *column_names, &block)
|
|
70
|
+
self.record_count = (record_count || 0) + count
|
|
71
|
+
count
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def upload_mongo_query(criteria, *column_names, category: :main, &block)
|
|
75
|
+
count = input(category).upload_mongo_query(criteria, *column_names, &block)
|
|
76
|
+
self.record_count = (record_count || 0) + count
|
|
77
|
+
count
|
|
78
|
+
end
|
|
79
|
+
|
|
68
80
|
# Upload the supplied slices for processing by workers
|
|
69
81
|
#
|
|
70
82
|
# Updates the record_count after adding the records
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
require 'fileutils'
|
|
2
|
+
require 'uri'
|
|
3
|
+
|
|
2
4
|
begin
|
|
3
5
|
require 'iostreams'
|
|
4
6
|
rescue LoadError
|
|
@@ -91,9 +93,12 @@ module RocketJob
|
|
|
91
93
|
end
|
|
92
94
|
|
|
93
95
|
def file_exists
|
|
94
|
-
return if upload_file_name.nil?
|
|
96
|
+
return if upload_file_name.nil?
|
|
97
|
+
uri = URI.parse(upload_file_name)
|
|
98
|
+
return unless uri.scheme.nil? || uri.scheme == 'file'
|
|
99
|
+
return if File.exist?(upload_file_name)
|
|
95
100
|
errors.add(:upload_file_name, "Upload file: #{upload_file_name} does not exist.")
|
|
96
101
|
end
|
|
97
|
-
|
|
102
|
+
end
|
|
98
103
|
end
|
|
99
104
|
end
|
|
@@ -4,27 +4,12 @@ module RocketJob
|
|
|
4
4
|
module Plugins
|
|
5
5
|
# Automatically retry the job on failure.
|
|
6
6
|
#
|
|
7
|
-
# The following retry algorithm is used to automatically retry a job when it fails:
|
|
8
|
-
# Failed jobs are aborted so that they cannot be restarted since a new instance has there are workers
|
|
9
|
-
# available to run. For example if workers are busy working on higher priority jobs, then the job
|
|
10
|
-
# will only run once those jobs have completed, or their priority lowered. Additionally, while the
|
|
11
|
-
# job is queued no additional instances will be enqueued, even if the next cron interval has been reached.
|
|
12
|
-
#
|
|
13
|
-
# Note:
|
|
14
|
-
# - After failure the job is scheduled to run again in the future.
|
|
15
|
-
# - The job will not be retried if:
|
|
16
|
-
# - The job has expired.
|
|
17
|
-
# - The job fails validations.
|
|
18
|
-
# - The number of retry counts has been exceeded.
|
|
19
|
-
# - To see the number of times a job has failed so far:
|
|
20
|
-
# job.failure_count
|
|
21
|
-
#
|
|
22
7
|
# Example:
|
|
23
8
|
#
|
|
24
9
|
# class MyJob < RocketJob::Job
|
|
25
10
|
# include RocketJob::Plugins::Retry
|
|
26
11
|
#
|
|
27
|
-
# # Set the
|
|
12
|
+
# # Set the maximum number of times a job should be retried before giving up.
|
|
28
13
|
# self.retry_limit = 3
|
|
29
14
|
#
|
|
30
15
|
# def perform
|
|
@@ -35,10 +20,10 @@ module RocketJob
|
|
|
35
20
|
# # Queue the job for processing using the default cron_schedule specified above
|
|
36
21
|
# MyJob.create!
|
|
37
22
|
#
|
|
38
|
-
# #
|
|
23
|
+
# # Override the default retry_limit for a specific job instance.
|
|
39
24
|
# MyCronJob.create!(retry_limit: 10)
|
|
40
25
|
#
|
|
41
|
-
# # Disable retries for this job instance
|
|
26
|
+
# # Disable retries for this job instance.
|
|
42
27
|
# MyCronJob.create!(retry_limit: 0)
|
|
43
28
|
#
|
|
44
29
|
module Retry
|
|
@@ -107,7 +107,6 @@ module RocketJob
|
|
|
107
107
|
IOStreams.public_send(iterator, file_name_or_io, encoding: encoding, **args) { |line| io << line }
|
|
108
108
|
end
|
|
109
109
|
|
|
110
|
-
create_indexes
|
|
111
110
|
Writer::Input.collect(self, on_first: on_first, &block)
|
|
112
111
|
end
|
|
113
112
|
|
|
@@ -141,7 +140,6 @@ module RocketJob
|
|
|
141
140
|
# criteria = User.where(state: 'FL')
|
|
142
141
|
# job.record_count = job.upload_mongo_query(criteria, :zip_code)
|
|
143
142
|
def upload_mongo_query(criteria, *column_names, &block)
|
|
144
|
-
create_indexes
|
|
145
143
|
options = criteria.options
|
|
146
144
|
|
|
147
145
|
# Without a block extract the fields from the supplied criteria
|
|
@@ -198,7 +196,6 @@ module RocketJob
|
|
|
198
196
|
# arel = User.where(country_code: 'US')
|
|
199
197
|
# job.record_count = job.upload_arel(arel, :user_name, :zip_code)
|
|
200
198
|
def upload_arel(arel, *column_names, &block)
|
|
201
|
-
create_indexes
|
|
202
199
|
unless block
|
|
203
200
|
column_names = column_names.collect(&:to_sym)
|
|
204
201
|
column_names << :id if column_names.size.zero?
|
|
@@ -21,7 +21,9 @@ module RocketJob
|
|
|
21
21
|
@slice_class = slice_class
|
|
22
22
|
@slice_size = slice_size
|
|
23
23
|
@collection_name = collection_name
|
|
24
|
-
|
|
24
|
+
|
|
25
|
+
# Using `Sliced::Slice` avoids having to add `_type` as an index when all slices are the same type anyway.
|
|
26
|
+
@all = Sliced::Slice.with_collection(collection_name)
|
|
25
27
|
end
|
|
26
28
|
|
|
27
29
|
def new(params = {})
|
|
@@ -14,6 +14,8 @@ module RocketJob
|
|
|
14
14
|
# Default: nil
|
|
15
15
|
def self.collect(input, **args, &block)
|
|
16
16
|
writer = new(input, **args)
|
|
17
|
+
# Create indexes before uploading
|
|
18
|
+
input.create_indexes if input.respond_to?(:create_indexes)
|
|
17
19
|
block.call(writer)
|
|
18
20
|
writer.record_count
|
|
19
21
|
rescue Exception => exc
|
|
@@ -41,7 +41,7 @@ module RocketJob
|
|
|
41
41
|
Thread.new do
|
|
42
42
|
shutdown!
|
|
43
43
|
message = 'Shutdown signal (SIGTERM) received. Will shutdown as soon as active jobs/slices have completed.'
|
|
44
|
-
logger.
|
|
44
|
+
logger.info(message)
|
|
45
45
|
end
|
|
46
46
|
end
|
|
47
47
|
|
|
@@ -49,7 +49,7 @@ module RocketJob
|
|
|
49
49
|
Thread.new do
|
|
50
50
|
shutdown!
|
|
51
51
|
message = 'Shutdown signal (INT) received. Will shutdown as soon as active jobs/slices have completed.'
|
|
52
|
-
logger.
|
|
52
|
+
logger.info(message)
|
|
53
53
|
end
|
|
54
54
|
end
|
|
55
55
|
rescue StandardError
|
data/lib/rocket_job/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rocketjob
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.1.
|
|
4
|
+
version: 4.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Reid Morrison
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2019-
|
|
11
|
+
date: 2019-07-01 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: aasm
|
|
@@ -193,7 +193,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
193
193
|
- !ruby/object:Gem::Version
|
|
194
194
|
version: '0'
|
|
195
195
|
requirements: []
|
|
196
|
-
rubygems_version: 3.0.
|
|
196
|
+
rubygems_version: 3.0.3
|
|
197
197
|
signing_key:
|
|
198
198
|
specification_version: 4
|
|
199
199
|
summary: Ruby's missing batch system.
|