inst-jobs 0.15.19 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/db/migrate/20101216224513_create_delayed_jobs.rb +2 -0
- data/db/migrate/20110208031356_add_delayed_jobs_tag.rb +2 -0
- data/db/migrate/20110426161613_add_delayed_jobs_max_attempts.rb +2 -0
- data/db/migrate/20110516225834_add_delayed_jobs_strand.rb +2 -0
- data/db/migrate/20110531144916_cleanup_delayed_jobs_indexes.rb +2 -0
- data/db/migrate/20110610213249_optimize_delayed_jobs.rb +2 -0
- data/db/migrate/20110831210257_add_delayed_jobs_next_in_strand.rb +2 -0
- data/db/migrate/20120510004759_delayed_jobs_delete_trigger_lock_for_update.rb +2 -0
- data/db/migrate/20120531150712_drop_psql_jobs_pop_fn.rb +2 -0
- data/db/migrate/20120607164022_delayed_jobs_use_advisory_locks.rb +2 -0
- data/db/migrate/20120607181141_index_jobs_on_locked_by.rb +2 -0
- data/db/migrate/20120608191051_add_jobs_run_at_index.rb +2 -0
- data/db/migrate/20120927184213_change_delayed_jobs_handler_to_text.rb +2 -0
- data/db/migrate/20140505215131_add_failed_jobs_original_job_id.rb +2 -0
- data/db/migrate/20140505215510_copy_failed_jobs_original_id.rb +2 -0
- data/db/migrate/20140505223637_drop_failed_jobs_original_id.rb +2 -0
- data/db/migrate/20140512213941_add_source_to_jobs.rb +2 -0
- data/db/migrate/20150807133223_add_max_concurrent_to_jobs.rb +2 -0
- data/db/migrate/20151123210429_add_expires_at_to_jobs.rb +2 -0
- data/db/migrate/20151210162949_improve_max_concurrent.rb +2 -0
- data/db/migrate/20161206323555_add_back_default_string_limits_jobs.rb +2 -0
- data/db/migrate/20181217155351_speed_up_max_concurrent_triggers.rb +2 -0
- data/db/migrate/20190726154743_make_critical_columns_not_null.rb +2 -0
- data/db/migrate/20200330230722_add_id_to_get_delayed_jobs_index.rb +2 -0
- data/db/migrate/20200824222232_speed_up_max_concurrent_delete_trigger.rb +97 -0
- data/db/migrate/20200825011002_add_strand_order_override.rb +128 -0
- data/lib/delayed/backend/active_record.rb +19 -7
- data/lib/delayed/backend/base.rb +34 -20
- data/lib/delayed/backend/redis/functions.rb +2 -0
- data/lib/delayed/backend/redis/job.rb +2 -0
- data/lib/delayed/batch.rb +5 -3
- data/lib/delayed/cli.rb +2 -0
- data/lib/delayed/daemon.rb +2 -0
- data/lib/delayed/engine.rb +2 -0
- data/lib/delayed/job_tracking.rb +2 -0
- data/lib/delayed/lifecycle.rb +2 -0
- data/lib/delayed/log_tailer.rb +2 -0
- data/lib/delayed/logging.rb +2 -0
- data/lib/delayed/message_sending.rb +48 -111
- data/lib/delayed/performable_method.rb +15 -6
- data/lib/delayed/periodic.rb +6 -1
- data/lib/delayed/plugin.rb +2 -0
- data/lib/delayed/pool.rb +2 -0
- data/lib/delayed/server.rb +2 -0
- data/lib/delayed/server/helpers.rb +2 -0
- data/lib/delayed/settings.rb +7 -1
- data/lib/delayed/testing.rb +2 -0
- data/lib/delayed/version.rb +3 -1
- data/lib/delayed/work_queue/in_process.rb +2 -0
- data/lib/delayed/work_queue/parent_process.rb +2 -0
- data/lib/delayed/work_queue/parent_process/client.rb +2 -0
- data/lib/delayed/work_queue/parent_process/server.rb +3 -1
- data/lib/delayed/worker.rb +3 -1
- data/lib/delayed/worker/consul_health_check.rb +2 -0
- data/lib/delayed/worker/health_check.rb +2 -0
- data/lib/delayed/worker/null_health_check.rb +2 -0
- data/lib/delayed/worker/process_helper.rb +2 -0
- data/lib/delayed/yaml_extensions.rb +2 -0
- data/lib/delayed_job.rb +2 -0
- data/lib/inst-jobs.rb +2 -0
- data/spec/active_record_job_spec.rb +4 -2
- data/spec/delayed/cli_spec.rb +2 -0
- data/spec/delayed/daemon_spec.rb +2 -0
- data/spec/delayed/server_spec.rb +2 -0
- data/spec/delayed/settings_spec.rb +2 -0
- data/spec/delayed/work_queue/in_process_spec.rb +2 -0
- data/spec/delayed/work_queue/parent_process/client_spec.rb +2 -0
- data/spec/delayed/work_queue/parent_process/server_spec.rb +2 -0
- data/spec/delayed/work_queue/parent_process_spec.rb +2 -0
- data/spec/delayed/worker/consul_health_check_spec.rb +2 -0
- data/spec/delayed/worker/health_check_spec.rb +2 -0
- data/spec/delayed/worker_spec.rb +29 -0
- data/spec/gemfiles/51.gemfile.lock +7 -7
- data/spec/gemfiles/52.gemfile.lock +17 -15
- data/spec/gemfiles/60.gemfile.lock +91 -89
- data/spec/migrate/20140924140513_add_story_table.rb +2 -0
- data/spec/redis_job_spec.rb +10 -8
- data/spec/sample_jobs.rb +2 -0
- data/spec/shared/delayed_batch.rb +17 -15
- data/spec/shared/delayed_method.rb +49 -204
- data/spec/shared/performable_method.rb +11 -9
- data/spec/shared/shared_backend.rb +27 -25
- data/spec/shared/testing.rb +7 -5
- data/spec/shared/worker.rb +15 -13
- data/spec/shared_jobs_specs.rb +2 -0
- data/spec/spec_helper.rb +3 -1
- metadata +9 -7
data/lib/delayed/plugin.rb
CHANGED
data/lib/delayed/pool.rb
CHANGED
data/lib/delayed/server.rb
CHANGED
data/lib/delayed/settings.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'yaml'
|
2
4
|
require 'erb'
|
3
5
|
require 'active_support/core_ext/hash/indifferent_access'
|
@@ -23,7 +25,10 @@ module Delayed
|
|
23
25
|
:worker_health_check_config,
|
24
26
|
:worker_procname_prefix,
|
25
27
|
]
|
26
|
-
SETTINGS_WITH_ARGS = [
|
28
|
+
SETTINGS_WITH_ARGS = [
|
29
|
+
:job_detailed_log_format,
|
30
|
+
:num_strands
|
31
|
+
]
|
27
32
|
|
28
33
|
SETTINGS.each do |setting|
|
29
34
|
mattr_writer(setting)
|
@@ -65,6 +70,7 @@ module Delayed
|
|
65
70
|
|
66
71
|
self.num_strands = ->(strand_name){ nil }
|
67
72
|
self.default_job_options = ->{ Hash.new }
|
73
|
+
self.job_detailed_log_format = ->(job){ job.to_json(include_root: false, only: %w(tag strand priority attempts created_at max_attempts source)) }
|
68
74
|
|
69
75
|
# Send workers KILL after QUIT if they haven't exited within the
|
70
76
|
# slow_exit_timeout
|
data/lib/delayed/testing.rb
CHANGED
data/lib/delayed/version.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Delayed
|
2
4
|
module WorkQueue
|
3
5
|
class ParentProcess
|
@@ -5,7 +7,7 @@ class ParentProcess
|
|
5
7
|
attr_reader :clients, :listen_socket
|
6
8
|
|
7
9
|
include Delayed::Logging
|
8
|
-
SIGNALS = %i{INT TERM QUIT
|
10
|
+
SIGNALS = %i{INT TERM QUIT}
|
9
11
|
|
10
12
|
def initialize(listen_socket, parent_pid: nil, config: Settings.parent_process)
|
11
13
|
@listen_socket = listen_socket
|
data/lib/delayed/worker.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Delayed
|
2
4
|
|
3
5
|
class TimeoutError < RuntimeError; end
|
@@ -253,7 +255,7 @@ class Worker
|
|
253
255
|
def log_job(job, format = :short)
|
254
256
|
case format
|
255
257
|
when :long
|
256
|
-
"#{job.full_name} #{
|
258
|
+
"#{job.full_name} #{ Settings.job_detailed_log_format.call(job) }"
|
257
259
|
else
|
258
260
|
job.full_name
|
259
261
|
end
|
data/lib/delayed_job.rb
CHANGED
data/lib/inst-jobs.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require File.expand_path("../spec_helper", __FILE__)
|
2
4
|
|
3
5
|
describe 'Delayed::Backed::ActiveRecord::Job' do
|
@@ -17,7 +19,7 @@ describe 'Delayed::Backed::ActiveRecord::Job' do
|
|
17
19
|
|
18
20
|
it "should recover as well as possible from a failure failing a job" do
|
19
21
|
allow(Delayed::Job::Failed).to receive(:create).and_raise(RuntimeError)
|
20
|
-
job = "test".
|
22
|
+
job = "test".delay(ignore_transaction: true).reverse
|
21
23
|
job_id = job.id
|
22
24
|
proc { job.fail! }.should raise_error(RuntimeError)
|
23
25
|
proc { Delayed::Job.find(job_id) }.should raise_error(ActiveRecord::RecordNotFound)
|
@@ -43,7 +45,7 @@ describe 'Delayed::Backed::ActiveRecord::Job' do
|
|
43
45
|
it "should select the next job at random if enabled" do
|
44
46
|
begin
|
45
47
|
Delayed::Settings.select_random_from_batch = true
|
46
|
-
15.times { "test".
|
48
|
+
15.times { "test".delay.length }
|
47
49
|
founds = []
|
48
50
|
15.times do
|
49
51
|
job = Delayed::Job.get_and_lock_next_available('tester')
|
data/spec/delayed/cli_spec.rb
CHANGED
data/spec/delayed/daemon_spec.rb
CHANGED
data/spec/delayed/server_spec.rb
CHANGED
data/spec/delayed/worker_spec.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative "../spec_helper"
|
2
4
|
|
3
5
|
describe Delayed::Worker do
|
@@ -38,6 +40,33 @@ describe Delayed::Worker do
|
|
38
40
|
end
|
39
41
|
end
|
40
42
|
|
43
|
+
describe "#log_job" do
|
44
|
+
around(:each) do |block|
|
45
|
+
prev_logger = Delayed::Settings.job_detailed_log_format
|
46
|
+
block.call
|
47
|
+
Delayed::Settings.job_detailed_log_format = prev_logger
|
48
|
+
end
|
49
|
+
|
50
|
+
it "has a reasonable default format" do
|
51
|
+
payload = double(perform: nil)
|
52
|
+
job = Delayed::Job.new(payload_object: payload, priority: 25, strand: "test_jobs")
|
53
|
+
short_log_format = subject.log_job(job, :short)
|
54
|
+
expect(short_log_format).to eq("RSpec::Mocks::Double")
|
55
|
+
long_format = subject.log_job(job, :long)
|
56
|
+
expect(long_format).to eq("RSpec::Mocks::Double {\"priority\":25,\"attempts\":0,\"created_at\":null,\"tag\":\"RSpec::Mocks::Double#perform\",\"max_attempts\":null,\"strand\":\"test_jobs\",\"source\":null}")
|
57
|
+
end
|
58
|
+
|
59
|
+
it "logging format can be changed with settings" do
|
60
|
+
Delayed::Settings.job_detailed_log_format = ->(job){ "override format #{job.strand}"}
|
61
|
+
payload = double(perform: nil)
|
62
|
+
job = Delayed::Job.new(payload_object: payload, priority: 25, strand: "test_jobs")
|
63
|
+
short_log_format = subject.log_job(job, :short)
|
64
|
+
expect(short_log_format).to eq("RSpec::Mocks::Double")
|
65
|
+
long_format = subject.log_job(job, :long)
|
66
|
+
expect(long_format).to eq("RSpec::Mocks::Double override format test_jobs")
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
41
70
|
describe "#run" do
|
42
71
|
it "passes extra config options through to the WorkQueue" do
|
43
72
|
expect(subject.work_queue).to receive(:get_and_lock_next_available).
|
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ../..
|
3
3
|
specs:
|
4
|
-
inst-jobs (0.
|
4
|
+
inst-jobs (1.0.0)
|
5
5
|
activerecord (>= 4.2)
|
6
6
|
activesupport (>= 4.2)
|
7
7
|
after_transaction_commit (>= 1.0, < 3)
|
@@ -52,7 +52,7 @@ GEM
|
|
52
52
|
tzinfo (~> 1.1)
|
53
53
|
addressable (2.7.0)
|
54
54
|
public_suffix (>= 2.0.2, < 5.0)
|
55
|
-
after_transaction_commit (2.
|
55
|
+
after_transaction_commit (2.1.0)
|
56
56
|
activerecord (>= 5.0)
|
57
57
|
arel (8.0.0)
|
58
58
|
backports (3.11.3)
|
@@ -67,9 +67,9 @@ GEM
|
|
67
67
|
erubi (1.7.1)
|
68
68
|
et-orbi (1.2.4)
|
69
69
|
tzinfo
|
70
|
-
fugit (1.3.
|
70
|
+
fugit (1.3.9)
|
71
71
|
et-orbi (~> 1.1, >= 1.1.8)
|
72
|
-
raabro (~> 1.
|
72
|
+
raabro (~> 1.3)
|
73
73
|
globalid (0.4.1)
|
74
74
|
activesupport (>= 4.2.0)
|
75
75
|
httpclient (2.8.3)
|
@@ -97,7 +97,7 @@ GEM
|
|
97
97
|
coderay (~> 1.1.0)
|
98
98
|
method_source (~> 0.9.0)
|
99
99
|
public_suffix (4.0.3)
|
100
|
-
raabro (1.
|
100
|
+
raabro (1.4.0)
|
101
101
|
rack (2.0.5)
|
102
102
|
rack-protection (2.0.0.beta2)
|
103
103
|
rack
|
@@ -127,7 +127,7 @@ GEM
|
|
127
127
|
rake (>= 0.8.7)
|
128
128
|
thor (>= 0.18.1, < 2.0)
|
129
129
|
rake (12.3.1)
|
130
|
-
redis (4.
|
130
|
+
redis (4.2.2)
|
131
131
|
redis-scripting (1.0.1)
|
132
132
|
redis (>= 3.0)
|
133
133
|
rspec (3.8.0)
|
@@ -195,4 +195,4 @@ DEPENDENCIES
|
|
195
195
|
wwtd (~> 1.4.0)
|
196
196
|
|
197
197
|
BUNDLED WITH
|
198
|
-
1.17.
|
198
|
+
1.17.3
|
@@ -1,14 +1,14 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ../..
|
3
3
|
specs:
|
4
|
-
inst-jobs (0.
|
4
|
+
inst-jobs (1.0.0)
|
5
5
|
activerecord (>= 4.2)
|
6
6
|
activesupport (>= 4.2)
|
7
7
|
after_transaction_commit (>= 1.0, < 3)
|
8
|
+
fugit (~> 1.3)
|
8
9
|
railties (>= 4.2)
|
9
10
|
redis (> 3.0)
|
10
11
|
redis-scripting (~> 1.0.1)
|
11
|
-
rufus-scheduler (~> 3.4, < 3.5)
|
12
12
|
|
13
13
|
GEM
|
14
14
|
remote: https://rubygems.org/
|
@@ -54,9 +54,9 @@ GEM
|
|
54
54
|
i18n (>= 0.7, < 2)
|
55
55
|
minitest (~> 5.1)
|
56
56
|
tzinfo (~> 1.1)
|
57
|
-
addressable (2.
|
58
|
-
public_suffix (>= 2.0.2, <
|
59
|
-
after_transaction_commit (2.
|
57
|
+
addressable (2.7.0)
|
58
|
+
public_suffix (>= 2.0.2, < 5.0)
|
59
|
+
after_transaction_commit (2.1.0)
|
60
60
|
activerecord (>= 5.0)
|
61
61
|
arel (9.0.0)
|
62
62
|
backports (3.15.0)
|
@@ -69,14 +69,17 @@ GEM
|
|
69
69
|
database_cleaner (1.6.1)
|
70
70
|
diff-lcs (1.3)
|
71
71
|
erubi (1.8.0)
|
72
|
-
et-orbi (1.2.
|
72
|
+
et-orbi (1.2.4)
|
73
73
|
tzinfo
|
74
|
+
fugit (1.3.9)
|
75
|
+
et-orbi (~> 1.1, >= 1.1.8)
|
76
|
+
raabro (~> 1.3)
|
74
77
|
globalid (0.4.2)
|
75
78
|
activesupport (>= 4.2.0)
|
76
79
|
httpclient (2.8.3)
|
77
80
|
i18n (1.6.0)
|
78
81
|
concurrent-ruby (~> 1.0)
|
79
|
-
imperium (0.5.
|
82
|
+
imperium (0.5.2)
|
80
83
|
addressable (~> 2.5)
|
81
84
|
httpclient (~> 2.8)
|
82
85
|
loofah (2.2.3)
|
@@ -100,7 +103,8 @@ GEM
|
|
100
103
|
pry (0.12.2)
|
101
104
|
coderay (~> 1.1.0)
|
102
105
|
method_source (~> 0.9.0)
|
103
|
-
public_suffix (
|
106
|
+
public_suffix (4.0.6)
|
107
|
+
raabro (1.4.0)
|
104
108
|
rack (2.0.7)
|
105
109
|
rack-protection (2.0.0.beta2)
|
106
110
|
rack
|
@@ -131,7 +135,7 @@ GEM
|
|
131
135
|
rake (>= 0.8.7)
|
132
136
|
thor (>= 0.19.0, < 2.0)
|
133
137
|
rake (12.3.3)
|
134
|
-
redis (4.
|
138
|
+
redis (4.2.2)
|
135
139
|
redis-scripting (1.0.1)
|
136
140
|
redis (>= 3.0)
|
137
141
|
rspec (3.8.0)
|
@@ -147,8 +151,6 @@ GEM
|
|
147
151
|
diff-lcs (>= 1.2.0, < 2.0)
|
148
152
|
rspec-support (~> 3.8.0)
|
149
153
|
rspec-support (3.8.2)
|
150
|
-
rufus-scheduler (3.4.2)
|
151
|
-
et-orbi (~> 1.0)
|
152
154
|
sinatra (2.0.0.beta2)
|
153
155
|
mustermann (= 1.0.0.beta2)
|
154
156
|
rack (~> 2.0)
|
@@ -178,7 +180,7 @@ GEM
|
|
178
180
|
websocket-driver (0.7.1)
|
179
181
|
websocket-extensions (>= 0.1.0)
|
180
182
|
websocket-extensions (0.1.4)
|
181
|
-
wwtd (1.
|
183
|
+
wwtd (1.4.1)
|
182
184
|
|
183
185
|
PLATFORMS
|
184
186
|
ruby
|
@@ -187,7 +189,7 @@ DEPENDENCIES
|
|
187
189
|
bump
|
188
190
|
byebug
|
189
191
|
database_cleaner (= 1.6.1)
|
190
|
-
imperium (>= 0.2
|
192
|
+
imperium (>= 0.5.2)
|
191
193
|
inst-jobs!
|
192
194
|
pg (< 1.0)
|
193
195
|
pry
|
@@ -198,7 +200,7 @@ DEPENDENCIES
|
|
198
200
|
sinatra (= 2.0.0.beta2)
|
199
201
|
sinatra-contrib (= 2.0.0.beta2)
|
200
202
|
timecop (= 0.7.1)
|
201
|
-
wwtd (~> 1.
|
203
|
+
wwtd (~> 1.4.0)
|
202
204
|
|
203
205
|
BUNDLED WITH
|
204
|
-
1.
|
206
|
+
1.17.3
|