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
@@ -1,15 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
shared_examples_for 'Delayed::PerformableMethod' do
|
2
4
|
|
3
5
|
it "should not ignore ActiveRecord::RecordNotFound errors because they are not always permanent" do
|
4
6
|
story = Story.create :text => 'Once upon...'
|
5
|
-
p = Delayed::PerformableMethod.new(story, :tell
|
7
|
+
p = Delayed::PerformableMethod.new(story, :tell)
|
6
8
|
story.destroy
|
7
9
|
lambda { YAML.load(p.to_yaml) }.should raise_error(Delayed::Backend::RecordNotFound)
|
8
10
|
end
|
9
11
|
|
10
12
|
it "should store the object using native YAML even if its an active record" do
|
11
13
|
story = Story.create :text => 'Once upon...'
|
12
|
-
p = Delayed::PerformableMethod.new(story, :tell
|
14
|
+
p = Delayed::PerformableMethod.new(story, :tell)
|
13
15
|
p.class.should == Delayed::PerformableMethod
|
14
16
|
p.object.should == story
|
15
17
|
p.method.should == :tell
|
@@ -19,24 +21,24 @@ shared_examples_for 'Delayed::PerformableMethod' do
|
|
19
21
|
|
20
22
|
it "should allow class methods to be called on ActiveRecord models" do
|
21
23
|
Story.create!(:text => 'Once upon a...')
|
22
|
-
p = Delayed::PerformableMethod.new(Story, :count
|
24
|
+
p = Delayed::PerformableMethod.new(Story, :count)
|
23
25
|
lambda { expect(p.send(:perform)).to eql 1 }.should_not raise_error
|
24
26
|
end
|
25
27
|
|
26
28
|
it "should allow class methods to be called" do
|
27
|
-
p = Delayed::PerformableMethod.new(StoryReader, :reverse, ["ohai"])
|
29
|
+
p = Delayed::PerformableMethod.new(StoryReader, :reverse, args: ["ohai"])
|
28
30
|
lambda { p.send(:perform).should == "iaho" }.should_not raise_error
|
29
31
|
end
|
30
32
|
|
31
33
|
it "should allow module methods to be called" do
|
32
|
-
p = Delayed::PerformableMethod.new(MyReverser, :reverse, ["ohai"])
|
34
|
+
p = Delayed::PerformableMethod.new(MyReverser, :reverse, args: ["ohai"])
|
33
35
|
lambda { p.send(:perform).should == "iaho" }.should_not raise_error
|
34
36
|
end
|
35
37
|
|
36
38
|
it "should store arguments as native YAML if they are active record objects" do
|
37
39
|
story = Story.create :text => 'Once upon...'
|
38
40
|
reader = StoryReader.new
|
39
|
-
p = Delayed::PerformableMethod.new(reader, :read, [story])
|
41
|
+
p = Delayed::PerformableMethod.new(reader, :read, args: [story])
|
40
42
|
p.class.should == Delayed::PerformableMethod
|
41
43
|
p.method.should == :read
|
42
44
|
p.args.should == [story]
|
@@ -46,20 +48,20 @@ shared_examples_for 'Delayed::PerformableMethod' do
|
|
46
48
|
it "should deeply de-AR-ize arguments in full name" do
|
47
49
|
story = Story.create :text => 'Once upon...'
|
48
50
|
reader = StoryReader.new
|
49
|
-
p = Delayed::PerformableMethod.new(reader, :read, [['arg1', story, { [:key, 1] => story }]])
|
51
|
+
p = Delayed::PerformableMethod.new(reader, :read, args: [['arg1', story, { [:key, 1] => story }]])
|
50
52
|
p.full_name.should == "StoryReader#read([\"arg1\", Story.find(#{story.id}), {[:key, 1] => Story.find(#{story.id})}])"
|
51
53
|
end
|
52
54
|
|
53
55
|
it "should call the on_failure callback" do
|
54
56
|
story = Story.create :text => 'wat'
|
55
|
-
p = Delayed::PerformableMethod.new(story, :tell,
|
57
|
+
p = Delayed::PerformableMethod.new(story, :tell, on_failure: :text=)
|
56
58
|
p.send(:on_failure, 'fail')
|
57
59
|
story.text.should == 'fail'
|
58
60
|
end
|
59
61
|
|
60
62
|
it "should call the on_permanent_failure callback" do
|
61
63
|
story = Story.create :text => 'wat'
|
62
|
-
p = Delayed::PerformableMethod.new(story, :tell,
|
64
|
+
p = Delayed::PerformableMethod.new(story, :tell, on_permanent_failure: :text=)
|
63
65
|
p.send(:on_permanent_failure, 'fail_frd')
|
64
66
|
story.text.should == 'fail_frd'
|
65
67
|
end
|
@@ -1,6 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
shared_examples_for 'a backend' do
|
2
4
|
def create_job(opts = {})
|
3
|
-
Delayed::Job.enqueue(SimpleJob.new, { :queue => nil }.merge(opts))
|
5
|
+
Delayed::Job.enqueue(SimpleJob.new, **{ :queue => nil }.merge(opts))
|
4
6
|
end
|
5
7
|
|
6
8
|
before do
|
@@ -139,12 +141,12 @@ shared_examples_for 'a backend' do
|
|
139
141
|
end
|
140
142
|
|
141
143
|
it "should be the method that will be called if its a performable method object" do
|
142
|
-
@job = Story.
|
144
|
+
@job = Story.delay(ignore_transaction: true).create
|
143
145
|
@job.name.should == "Story.create"
|
144
146
|
end
|
145
147
|
|
146
148
|
it "should be the instance method that will be called if its a performable method object" do
|
147
|
-
@job = Story.create(:text => "...").
|
149
|
+
@job = Story.create(:text => "...").delay(ignore_transaction: true).save
|
148
150
|
@job.name.should == 'Story#save'
|
149
151
|
end
|
150
152
|
end
|
@@ -371,8 +373,8 @@ shared_examples_for 'a backend' do
|
|
371
373
|
end
|
372
374
|
|
373
375
|
it "should update existing singleton job handler if requested" do
|
374
|
-
job1 = Delayed::Job.enqueue(SimpleJob.new,
|
375
|
-
job2 = Delayed::Job.enqueue(ErrorJob.new,
|
376
|
+
job1 = Delayed::Job.enqueue(SimpleJob.new, queue: nil, singleton: 'myjobs', on_conflict: :overwrite)
|
377
|
+
job2 = Delayed::Job.enqueue(ErrorJob.new, queue: nil, singleton: 'myjobs', on_conflict: :overwrite)
|
376
378
|
job2.should == job1
|
377
379
|
expect(job2.handler).to include("ErrorJob")
|
378
380
|
end
|
@@ -498,7 +500,7 @@ shared_examples_for 'a backend' do
|
|
498
500
|
end
|
499
501
|
|
500
502
|
it "should set in_delayed_job?" do
|
501
|
-
job = InDelayedJobTest.
|
503
|
+
job = InDelayedJobTest.delay(ignore_transaction: true).check_in_job
|
502
504
|
Delayed::Job.in_delayed_job?.should == false
|
503
505
|
job.invoke_job
|
504
506
|
Delayed::Job.in_delayed_job?.should == false
|
@@ -506,12 +508,12 @@ shared_examples_for 'a backend' do
|
|
506
508
|
|
507
509
|
it "should fail on job creation if an unsaved AR object is used" do
|
508
510
|
story = Story.new :text => "Once upon..."
|
509
|
-
lambda { story.
|
511
|
+
lambda { story.delay.text }.should raise_error(RuntimeError)
|
510
512
|
|
511
513
|
reader = StoryReader.new
|
512
|
-
lambda { reader.
|
514
|
+
lambda { reader.delay.read(story) }.should raise_error(RuntimeError)
|
513
515
|
|
514
|
-
lambda { [story, 1, story, false].
|
516
|
+
lambda { [story, 1, story, false].delay.first }.should raise_error(RuntimeError)
|
515
517
|
end
|
516
518
|
|
517
519
|
# the sort order of current_jobs and list_jobs depends on the back-end
|
@@ -576,11 +578,11 @@ shared_examples_for 'a backend' do
|
|
576
578
|
|
577
579
|
it "should return the jobs for a tag" do
|
578
580
|
tag_jobs = []
|
579
|
-
3.times { tag_jobs << "test".
|
580
|
-
2.times { "test".
|
581
|
-
tag_jobs << "test".
|
582
|
-
tag_jobs << "test".
|
583
|
-
"test".
|
581
|
+
3.times { tag_jobs << "test".delay(ignore_transaction: true).to_s }
|
582
|
+
2.times { "test".delay.to_i }
|
583
|
+
tag_jobs << "test".delay(ignore_transaction: true, run_at: 5.hours.from_now).to_s
|
584
|
+
tag_jobs << "test".delay(ignore_transaction: true, strand: "test1").to_s
|
585
|
+
"test".delay(strand: "test1").to_i
|
584
586
|
create_job
|
585
587
|
|
586
588
|
jobs = Delayed::Job.list_jobs(:tag, 3, 0, "String#to_s")
|
@@ -719,9 +721,9 @@ shared_examples_for 'a backend' do
|
|
719
721
|
@flavor = 'tag'
|
720
722
|
@query = 'String#to_i'
|
721
723
|
Timecop.freeze(5.minutes.ago) do
|
722
|
-
@affected_jobs << "test".
|
723
|
-
@affected_jobs << "test".
|
724
|
-
@affected_jobs << "test".
|
724
|
+
@affected_jobs << "test".delay(ignore_transaction: true).to_i
|
725
|
+
@affected_jobs << "test".delay(strand: 's1', ignore_transaction: true).to_i
|
726
|
+
@affected_jobs << "test".delay(run_at: 2.hours.from_now, ignore_transaction: true).to_i
|
725
727
|
@ignored_jobs << create_job
|
726
728
|
@ignored_jobs << create_job(:run_at => 1.hour.from_now)
|
727
729
|
end
|
@@ -729,9 +731,9 @@ shared_examples_for 'a backend' do
|
|
729
731
|
end
|
730
732
|
|
731
733
|
it "should hold and un-hold given job ids" do
|
732
|
-
j1 = "test".
|
734
|
+
j1 = "test".delay(ignore_transaction: true).to_i
|
733
735
|
j2 = create_job(:run_at => 2.hours.from_now)
|
734
|
-
j3 = "test".
|
736
|
+
j3 = "test".delay(strand: 's1', ignore_transaction: true).to_i
|
735
737
|
Delayed::Job.bulk_update('hold', :ids => [j1.id, j2.id]).should == 2
|
736
738
|
Delayed::Job.find(j1.id).on_hold?.should be true
|
737
739
|
Delayed::Job.find(j2.id).on_hold?.should be true
|
@@ -776,13 +778,13 @@ shared_examples_for 'a backend' do
|
|
776
778
|
describe "tag_counts" do
|
777
779
|
before do
|
778
780
|
@cur = []
|
779
|
-
3.times { @cur << "test".
|
780
|
-
5.times { @cur << "test".
|
781
|
-
2.times { @cur << "test".
|
782
|
-
|
781
|
+
3.times { @cur << "test".delay(ignore_transaction: true).to_s }
|
782
|
+
5.times { @cur << "test".delay(ignore_transaction: true).to_i}
|
783
|
+
2.times { @cur << "test".delay(ignore_transaction: true).upcase }
|
784
|
+
"test".delay(ignore_transaction: true).downcase.fail!
|
783
785
|
@future = []
|
784
|
-
5.times { @future << "test".
|
785
|
-
@cur << "test".
|
786
|
+
5.times { @future << "test".delay(run_at: 3.hours.from_now, ignore_transaction: true).downcase }
|
787
|
+
@cur << "test".delay(ignore_transaction: true).downcase
|
786
788
|
end
|
787
789
|
|
788
790
|
it "should return a sorted list of popular current tags" do
|
data/spec/shared/testing.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
shared_examples_for 'Delayed::Testing' do
|
2
4
|
class TestingWorker
|
3
5
|
cattr_accessor :runs
|
@@ -13,7 +15,7 @@ shared_examples_for 'Delayed::Testing' do
|
|
13
15
|
|
14
16
|
describe '.run_job' do
|
15
17
|
it 'should run a single queued job' do
|
16
|
-
job = TestingWorker.
|
18
|
+
job = TestingWorker.delay(ignore_transaction: true).run
|
17
19
|
Delayed::Testing.run_job(job)
|
18
20
|
expect(TestingWorker.runs).to eq 1
|
19
21
|
end
|
@@ -21,7 +23,7 @@ shared_examples_for 'Delayed::Testing' do
|
|
21
23
|
|
22
24
|
describe '.drain' do
|
23
25
|
it 'should run all queued jobs' do
|
24
|
-
3.times { TestingWorker.
|
26
|
+
3.times { TestingWorker.delay.run }
|
25
27
|
YAML.dump(TestingWorker)
|
26
28
|
Delayed::Testing.drain
|
27
29
|
expect(TestingWorker.runs).to eq 3
|
@@ -30,8 +32,8 @@ shared_examples_for 'Delayed::Testing' do
|
|
30
32
|
|
31
33
|
describe 'track_created' do
|
32
34
|
it 'should return the list of jobs created in the block' do
|
33
|
-
3.times { TestingWorker.
|
34
|
-
jobs = Delayed::Testing.track_created { 2.times { TestingWorker.
|
35
|
+
3.times { TestingWorker.delay.run }
|
36
|
+
jobs = Delayed::Testing.track_created { 2.times { TestingWorker.delay.run } }
|
35
37
|
expect(jobs.size).to eq 2
|
36
38
|
expect(jobs.first.tag).to eq "TestingWorker.run"
|
37
39
|
end
|
@@ -39,7 +41,7 @@ shared_examples_for 'Delayed::Testing' do
|
|
39
41
|
|
40
42
|
describe 'clear_all!' do
|
41
43
|
it 'should delete all queued jobs' do
|
42
|
-
3.times { TestingWorker.
|
44
|
+
3.times { TestingWorker.delay.run }
|
43
45
|
Delayed::Testing.clear_all!
|
44
46
|
Delayed::Testing.drain
|
45
47
|
expect(TestingWorker.runs).to eq 0
|
data/spec/shared/worker.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
shared_examples_for 'Delayed::Worker' do
|
2
4
|
def job_create(opts = {})
|
3
5
|
Delayed::Job.create({:payload_object => SimpleJob.new, :queue => Delayed::Settings.queue}.merge(opts))
|
@@ -19,7 +21,7 @@ shared_examples_for 'Delayed::Worker' do
|
|
19
21
|
|
20
22
|
describe "running a job" do
|
21
23
|
it "should not fail when running a job with a % in the name" do
|
22
|
-
@job = "Some % Name here".
|
24
|
+
@job = "Some % Name here".delay(ignore_transaction: true).starts_with?("Some % Name")
|
23
25
|
@worker.perform(@job)
|
24
26
|
end
|
25
27
|
end
|
@@ -36,14 +38,14 @@ shared_examples_for 'Delayed::Worker' do
|
|
36
38
|
end
|
37
39
|
|
38
40
|
it "should run each job in order" do
|
39
|
-
bar = "bar"
|
41
|
+
bar = +"bar"
|
40
42
|
expect(bar).to receive(:scan).with("b").ordered
|
41
43
|
expect(bar).to receive(:scan).with("a").ordered
|
42
44
|
expect(bar).to receive(:scan).with("r").ordered
|
43
45
|
batch = Delayed::Batch::PerformableBatch.new(:serial, [
|
44
|
-
{ :payload_object => Delayed::PerformableMethod.new(bar, :scan, ["b"]) },
|
45
|
-
{ :payload_object => Delayed::PerformableMethod.new(bar, :scan, ["a"]) },
|
46
|
-
{ :payload_object => Delayed::PerformableMethod.new(bar, :scan, ["r"]) },
|
46
|
+
{ :payload_object => Delayed::PerformableMethod.new(bar, :scan, args: ["b"]) },
|
47
|
+
{ :payload_object => Delayed::PerformableMethod.new(bar, :scan, args: ["a"]) },
|
48
|
+
{ :payload_object => Delayed::PerformableMethod.new(bar, :scan, args: ["r"]) },
|
47
49
|
])
|
48
50
|
|
49
51
|
batch_job = Delayed::Job.create :payload_object => batch
|
@@ -54,9 +56,9 @@ shared_examples_for 'Delayed::Worker' do
|
|
54
56
|
it "should succeed regardless of the success/failure of its component jobs" do
|
55
57
|
change_setting(Delayed::Settings, :max_attempts, 2) do
|
56
58
|
batch = Delayed::Batch::PerformableBatch.new(:serial, [
|
57
|
-
{ :payload_object => Delayed::PerformableMethod.new("foo", :reverse
|
58
|
-
{ :payload_object => Delayed::PerformableMethod.new(1, :/, [0]) },
|
59
|
-
{ :payload_object => Delayed::PerformableMethod.new("bar", :scan, ["r"]) },
|
59
|
+
{ :payload_object => Delayed::PerformableMethod.new("foo", :reverse) },
|
60
|
+
{ :payload_object => Delayed::PerformableMethod.new(1, :/, args: [0]) },
|
61
|
+
{ :payload_object => Delayed::PerformableMethod.new("bar", :scan, args: ["r"]) },
|
60
62
|
])
|
61
63
|
batch_job = Delayed::Job.create :payload_object => batch
|
62
64
|
|
@@ -73,7 +75,7 @@ shared_examples_for 'Delayed::Worker' do
|
|
73
75
|
|
74
76
|
it "should retry a failed individual job" do
|
75
77
|
batch = Delayed::Batch::PerformableBatch.new(:serial, [
|
76
|
-
{ :payload_object => Delayed::PerformableMethod.new(1, :/, [0]) },
|
78
|
+
{ :payload_object => Delayed::PerformableMethod.new(1, :/, args: [0]) },
|
77
79
|
])
|
78
80
|
batch_job = Delayed::Job.create :payload_object => batch
|
79
81
|
|
@@ -155,7 +157,7 @@ shared_examples_for 'Delayed::Worker' do
|
|
155
157
|
@worker.perform(@job)
|
156
158
|
@job = Delayed::Job.find(@job.id)
|
157
159
|
@job.last_error.should =~ /did not work/
|
158
|
-
@job.last_error.should =~ /sample_jobs.rb:
|
160
|
+
@job.last_error.should =~ /sample_jobs.rb:10:in `perform'/
|
159
161
|
@job.attempts.should == 1
|
160
162
|
@job.run_at.should > Delayed::Job.db_time_now - 10.minutes
|
161
163
|
@job.run_at.should < Delayed::Job.db_time_now + 10.minutes
|
@@ -348,17 +350,17 @@ shared_examples_for 'Delayed::Worker' do
|
|
348
350
|
end
|
349
351
|
end
|
350
352
|
|
351
|
-
describe "
|
353
|
+
describe "delay failure callbacks" do
|
352
354
|
it "should call the on_failure callback" do
|
353
355
|
ErrorJob.last_error = nil
|
354
|
-
ErrorJob.new.
|
356
|
+
ErrorJob.new.delay(max_attempts: 2, on_failure: :on_failure).perform
|
355
357
|
expect { @worker.run }.to change { ErrorJob.failure_runs }.by(1)
|
356
358
|
expect(ErrorJob.last_error.to_s).to eq 'did not work'
|
357
359
|
end
|
358
360
|
|
359
361
|
it "should call the on_permanent_failure callback" do
|
360
362
|
ErrorJob.last_error = nil
|
361
|
-
ErrorJob.new.
|
363
|
+
ErrorJob.new.delay(max_attempts: 1, on_permanent_failure: :on_failure).perform
|
362
364
|
expect { @worker.run }.to change { ErrorJob.failure_runs }.by(1)
|
363
365
|
expect(ErrorJob.last_error.to_s).to eq 'did not work'
|
364
366
|
end
|
data/spec/shared_jobs_specs.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'delayed_job'
|
2
4
|
require 'delayed/testing'
|
3
5
|
|
@@ -91,7 +93,7 @@ class Story < ActiveRecord::Base
|
|
91
93
|
def whatever_else(n, _); tell*n; end
|
92
94
|
|
93
95
|
handle_asynchronously :whatever
|
94
|
-
|
96
|
+
handle_asynchronously :whatever_else, queue: "testqueue"
|
95
97
|
end
|
96
98
|
|
97
99
|
class StoryReader
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inst-jobs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tobias Luetke
|
8
8
|
- Brian Palmer
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-
|
12
|
+
date: 2020-10-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -311,7 +311,7 @@ dependencies:
|
|
311
311
|
- - "~>"
|
312
312
|
- !ruby/object:Gem::Version
|
313
313
|
version: 1.4.0
|
314
|
-
description:
|
314
|
+
description:
|
315
315
|
email:
|
316
316
|
- brianp@instructure.com
|
317
317
|
executables:
|
@@ -343,6 +343,8 @@ files:
|
|
343
343
|
- db/migrate/20181217155351_speed_up_max_concurrent_triggers.rb
|
344
344
|
- db/migrate/20190726154743_make_critical_columns_not_null.rb
|
345
345
|
- db/migrate/20200330230722_add_id_to_get_delayed_jobs_index.rb
|
346
|
+
- db/migrate/20200824222232_speed_up_max_concurrent_delete_trigger.rb
|
347
|
+
- db/migrate/20200825011002_add_strand_order_override.rb
|
346
348
|
- exe/inst_jobs
|
347
349
|
- lib/delayed/backend/active_record.rb
|
348
350
|
- lib/delayed/backend/base.rb
|
@@ -427,7 +429,7 @@ files:
|
|
427
429
|
homepage: https://github.com/instructure/inst-jobs
|
428
430
|
licenses: []
|
429
431
|
metadata: {}
|
430
|
-
post_install_message:
|
432
|
+
post_install_message:
|
431
433
|
rdoc_options: []
|
432
434
|
require_paths:
|
433
435
|
- lib
|
@@ -442,8 +444,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
442
444
|
- !ruby/object:Gem::Version
|
443
445
|
version: '0'
|
444
446
|
requirements: []
|
445
|
-
rubygems_version: 3.
|
446
|
-
signing_key:
|
447
|
+
rubygems_version: 3.1.4
|
448
|
+
signing_key:
|
447
449
|
specification_version: 4
|
448
450
|
summary: Instructure-maintained fork of delayed_job
|
449
451
|
test_files:
|