inst-jobs 0.15.21 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. checksums.yaml +4 -4
  2. data/db/migrate/20101216224513_create_delayed_jobs.rb +2 -0
  3. data/db/migrate/20110208031356_add_delayed_jobs_tag.rb +2 -0
  4. data/db/migrate/20110426161613_add_delayed_jobs_max_attempts.rb +2 -0
  5. data/db/migrate/20110516225834_add_delayed_jobs_strand.rb +2 -0
  6. data/db/migrate/20110531144916_cleanup_delayed_jobs_indexes.rb +2 -0
  7. data/db/migrate/20110610213249_optimize_delayed_jobs.rb +2 -0
  8. data/db/migrate/20110831210257_add_delayed_jobs_next_in_strand.rb +2 -0
  9. data/db/migrate/20120510004759_delayed_jobs_delete_trigger_lock_for_update.rb +2 -0
  10. data/db/migrate/20120531150712_drop_psql_jobs_pop_fn.rb +2 -0
  11. data/db/migrate/20120607164022_delayed_jobs_use_advisory_locks.rb +2 -0
  12. data/db/migrate/20120607181141_index_jobs_on_locked_by.rb +2 -0
  13. data/db/migrate/20120608191051_add_jobs_run_at_index.rb +2 -0
  14. data/db/migrate/20120927184213_change_delayed_jobs_handler_to_text.rb +2 -0
  15. data/db/migrate/20140505215131_add_failed_jobs_original_job_id.rb +2 -0
  16. data/db/migrate/20140505215510_copy_failed_jobs_original_id.rb +2 -0
  17. data/db/migrate/20140505223637_drop_failed_jobs_original_id.rb +2 -0
  18. data/db/migrate/20140512213941_add_source_to_jobs.rb +2 -0
  19. data/db/migrate/20150807133223_add_max_concurrent_to_jobs.rb +2 -0
  20. data/db/migrate/20151123210429_add_expires_at_to_jobs.rb +2 -0
  21. data/db/migrate/20151210162949_improve_max_concurrent.rb +2 -0
  22. data/db/migrate/20161206323555_add_back_default_string_limits_jobs.rb +2 -0
  23. data/db/migrate/20181217155351_speed_up_max_concurrent_triggers.rb +2 -0
  24. data/db/migrate/20190726154743_make_critical_columns_not_null.rb +2 -0
  25. data/db/migrate/20200330230722_add_id_to_get_delayed_jobs_index.rb +2 -0
  26. data/db/migrate/20200824222232_speed_up_max_concurrent_delete_trigger.rb +97 -0
  27. data/db/migrate/20200825011002_add_strand_order_override.rb +128 -0
  28. data/lib/delayed/backend/active_record.rb +9 -5
  29. data/lib/delayed/backend/base.rb +34 -20
  30. data/lib/delayed/backend/redis/functions.rb +2 -0
  31. data/lib/delayed/backend/redis/job.rb +2 -0
  32. data/lib/delayed/batch.rb +5 -3
  33. data/lib/delayed/cli.rb +2 -0
  34. data/lib/delayed/core_ext/kernel.rb +9 -0
  35. data/lib/delayed/daemon.rb +2 -0
  36. data/lib/delayed/engine.rb +2 -0
  37. data/lib/delayed/job_tracking.rb +2 -0
  38. data/lib/delayed/lifecycle.rb +2 -0
  39. data/lib/delayed/log_tailer.rb +2 -0
  40. data/lib/delayed/logging.rb +2 -0
  41. data/lib/delayed/message_sending.rb +90 -106
  42. data/lib/delayed/performable_method.rb +34 -6
  43. data/lib/delayed/periodic.rb +6 -4
  44. data/lib/delayed/plugin.rb +2 -0
  45. data/lib/delayed/pool.rb +2 -0
  46. data/lib/delayed/server.rb +2 -0
  47. data/lib/delayed/server/helpers.rb +2 -0
  48. data/lib/delayed/settings.rb +7 -1
  49. data/lib/delayed/testing.rb +2 -0
  50. data/lib/delayed/version.rb +3 -1
  51. data/lib/delayed/work_queue/in_process.rb +2 -0
  52. data/lib/delayed/work_queue/parent_process.rb +2 -0
  53. data/lib/delayed/work_queue/parent_process/client.rb +2 -0
  54. data/lib/delayed/work_queue/parent_process/server.rb +2 -0
  55. data/lib/delayed/worker.rb +3 -1
  56. data/lib/delayed/worker/consul_health_check.rb +3 -1
  57. data/lib/delayed/worker/health_check.rb +2 -0
  58. data/lib/delayed/worker/null_health_check.rb +2 -0
  59. data/lib/delayed/worker/process_helper.rb +2 -0
  60. data/lib/delayed/yaml_extensions.rb +2 -0
  61. data/lib/delayed_job.rb +4 -0
  62. data/lib/inst-jobs.rb +2 -0
  63. data/spec/active_record_job_spec.rb +4 -6
  64. data/spec/delayed/cli_spec.rb +2 -0
  65. data/spec/delayed/daemon_spec.rb +2 -0
  66. data/spec/delayed/message_sending_spec.rb +101 -0
  67. data/spec/delayed/server_spec.rb +2 -4
  68. data/spec/delayed/settings_spec.rb +2 -0
  69. data/spec/delayed/work_queue/in_process_spec.rb +2 -4
  70. data/spec/delayed/work_queue/parent_process/client_spec.rb +2 -4
  71. data/spec/delayed/work_queue/parent_process/server_spec.rb +2 -1
  72. data/spec/delayed/work_queue/parent_process_spec.rb +2 -1
  73. data/spec/delayed/worker/consul_health_check_spec.rb +3 -1
  74. data/spec/delayed/worker/health_check_spec.rb +2 -0
  75. data/spec/delayed/worker_spec.rb +29 -0
  76. data/spec/gemfiles/42.gemfile.lock +192 -0
  77. data/spec/gemfiles/50.gemfile.lock +197 -0
  78. data/spec/gemfiles/51.gemfile.lock +198 -0
  79. data/spec/gemfiles/52.gemfile.lock +206 -0
  80. data/spec/gemfiles/60.gemfile.lock +224 -0
  81. data/spec/migrate/20140924140513_add_story_table.rb +2 -0
  82. data/spec/redis_job_spec.rb +10 -12
  83. data/spec/sample_jobs.rb +2 -0
  84. data/spec/shared/delayed_batch.rb +17 -15
  85. data/spec/shared/delayed_method.rb +49 -204
  86. data/spec/shared/performable_method.rb +11 -9
  87. data/spec/shared/shared_backend.rb +27 -25
  88. data/spec/shared/testing.rb +7 -5
  89. data/spec/shared/worker.rb +15 -13
  90. data/spec/shared_jobs_specs.rb +2 -0
  91. data/spec/spec_helper.rb +12 -1
  92. metadata +36 -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, [], :text=)
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, [], nil, :text=)
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.send_later_enqueue_args(:create, no_delay: true)
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 => "...").send_later_enqueue_args(:save, no_delay: true)
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, { :queue => nil, :singleton => 'myjobs', :on_conflict => :overwrite})
375
- job2 = Delayed::Job.enqueue(ErrorJob.new, { :queue => nil, :singleton => 'myjobs', :on_conflict => :overwrite})
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.send_later_enqueue_args(:check_in_job, no_delay: true)
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.send_later(:text) }.should raise_error(RuntimeError)
511
+ lambda { story.delay.text }.should raise_error(RuntimeError)
510
512
 
511
513
  reader = StoryReader.new
512
- lambda { reader.send_later(:read, story) }.should raise_error(RuntimeError)
514
+ lambda { reader.delay.read(story) }.should raise_error(RuntimeError)
513
515
 
514
- lambda { [story, 1, story, false].send_later(:first) }.should raise_error(RuntimeError)
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".send_later_enqueue_args(:to_s, :no_delay => true) }
580
- 2.times { "test".send_later(:to_i) }
581
- tag_jobs << "test".send_later_enqueue_args(:to_s, :run_at => 5.hours.from_now, :no_delay => true)
582
- tag_jobs << "test".send_later_enqueue_args(:to_s, :strand => "test1", :no_delay => true)
583
- "test".send_later_enqueue_args(:to_i, :strand => "test1")
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".send_later_enqueue_args(:to_i, :no_delay => true)
723
- @affected_jobs << "test".send_later_enqueue_args(:to_i, :strand => 's1', :no_delay => true)
724
- @affected_jobs << "test".send_later_enqueue_args(:to_i, :run_at => 2.hours.from_now, :no_delay => true)
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".send_later_enqueue_args(:to_i, :no_delay => true)
734
+ j1 = "test".delay(ignore_transaction: true).to_i
733
735
  j2 = create_job(:run_at => 2.hours.from_now)
734
- j3 = "test".send_later_enqueue_args(:to_i, :strand => 's1', :no_delay => true)
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".send_later_enqueue_args(:to_s, no_delay: true) }
780
- 5.times { @cur << "test".send_later_enqueue_args(:to_i, no_delay: true) }
781
- 2.times { @cur << "test".send_later_enqueue_args(:upcase, no_delay: true) }
782
- ("test".send_later_enqueue_args :downcase, no_delay: true).fail!
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".send_later_enqueue_args(:downcase, run_at: 3.hours.from_now, no_delay: true) }
785
- @cur << "test".send_later_enqueue_args(:downcase, no_delay: true)
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
@@ -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.send_later_enqueue_args(:run, no_delay: true)
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.send_later(:run) }
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.send_later(:run) }
34
- jobs = Delayed::Testing.track_created { 2.times { TestingWorker.send_later(:run) } }
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.send_later(:run) }
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
@@ -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".send_later_enqueue_args(:starts_with?, { no_delay: true }, "Some % Name")
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:8:in `perform'/
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 "send_later_enqueue_args failure callbacks" do
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.send_later_enqueue_args(:perform, :max_attempts => 2, :on_failure => :on_failure)
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.send_later_enqueue_args(:perform, :max_attempts => 1, :on_permanent_failure => :on_failure)
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
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require File.expand_path('../shared/delayed_batch', __FILE__)
2
4
  require File.expand_path('../shared/delayed_method', __FILE__)
3
5
  require File.expand_path('../shared/performable_method', __FILE__)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'delayed_job'
2
4
  require 'delayed/testing'
3
5
 
@@ -33,6 +35,15 @@ RSpec.configure do |config|
33
35
  end
34
36
  end
35
37
 
38
+ module NoYamlDump
39
+ def encode_with(coder)
40
+ end
41
+ end
42
+ # example groups are often the sender, and if we try to serialize them,
43
+ # the resultant object is then encoded in the sender, and then we serialize
44
+ # again, and it just keeps getting bigger and bigger and bigger...
45
+ RSpec::Core::ExampleGroup.include(NoYamlDump)
46
+
36
47
  ENV['TEST_ENV_NUMBER'] ||= '1'
37
48
  ENV['TEST_DB_HOST'] ||= 'localhost'
38
49
  ENV['TEST_DB_DATABASE'] ||= "inst-jobs-test-#{ENV['TEST_ENV_NUMBER']}"
@@ -91,7 +102,7 @@ class Story < ActiveRecord::Base
91
102
  def whatever_else(n, _); tell*n; end
92
103
 
93
104
  handle_asynchronously :whatever
94
- handle_asynchronously_with_queue :whatever_else, "testqueue"
105
+ handle_asynchronously :whatever_else, queue: "testqueue"
95
106
  end
96
107
 
97
108
  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.15.21
4
+ version: 1.0.2
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-05-06 00:00:00.000000000 Z
12
+ date: 2020-10-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -115,6 +115,20 @@ dependencies:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
117
  version: '1.3'
118
+ - !ruby/object:Gem::Dependency
119
+ name: debug_inspector
120
+ requirement: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 0.0.3
125
+ type: :runtime
126
+ prerelease: false
127
+ version_requirements: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: 0.0.3
118
132
  - !ruby/object:Gem::Dependency
119
133
  name: bump
120
134
  requirement: !ruby/object:Gem::Requirement
@@ -311,7 +325,7 @@ dependencies:
311
325
  - - "~>"
312
326
  - !ruby/object:Gem::Version
313
327
  version: 1.4.0
314
- description:
328
+ description:
315
329
  email:
316
330
  - brianp@instructure.com
317
331
  executables:
@@ -343,6 +357,8 @@ files:
343
357
  - db/migrate/20181217155351_speed_up_max_concurrent_triggers.rb
344
358
  - db/migrate/20190726154743_make_critical_columns_not_null.rb
345
359
  - db/migrate/20200330230722_add_id_to_get_delayed_jobs_index.rb
360
+ - db/migrate/20200824222232_speed_up_max_concurrent_delete_trigger.rb
361
+ - db/migrate/20200825011002_add_strand_order_override.rb
346
362
  - exe/inst_jobs
347
363
  - lib/delayed/backend/active_record.rb
348
364
  - lib/delayed/backend/base.rb
@@ -359,6 +375,7 @@ files:
359
375
  - lib/delayed/backend/redis/tickle_strand.lua
360
376
  - lib/delayed/batch.rb
361
377
  - lib/delayed/cli.rb
378
+ - lib/delayed/core_ext/kernel.rb
362
379
  - lib/delayed/daemon.rb
363
380
  - lib/delayed/engine.rb
364
381
  - lib/delayed/job_tracking.rb
@@ -394,6 +411,7 @@ files:
394
411
  - spec/active_record_job_spec.rb
395
412
  - spec/delayed/cli_spec.rb
396
413
  - spec/delayed/daemon_spec.rb
414
+ - spec/delayed/message_sending_spec.rb
397
415
  - spec/delayed/server_spec.rb
398
416
  - spec/delayed/settings_spec.rb
399
417
  - spec/delayed/work_queue/in_process_spec.rb
@@ -404,10 +422,15 @@ files:
404
422
  - spec/delayed/worker/health_check_spec.rb
405
423
  - spec/delayed/worker_spec.rb
406
424
  - spec/gemfiles/42.gemfile
425
+ - spec/gemfiles/42.gemfile.lock
407
426
  - spec/gemfiles/50.gemfile
427
+ - spec/gemfiles/50.gemfile.lock
408
428
  - spec/gemfiles/51.gemfile
429
+ - spec/gemfiles/51.gemfile.lock
409
430
  - spec/gemfiles/52.gemfile
431
+ - spec/gemfiles/52.gemfile.lock
410
432
  - spec/gemfiles/60.gemfile
433
+ - spec/gemfiles/60.gemfile.lock
411
434
  - spec/migrate/20140924140513_add_story_table.rb
412
435
  - spec/redis_job_spec.rb
413
436
  - spec/sample_jobs.rb
@@ -422,7 +445,7 @@ files:
422
445
  homepage: https://github.com/instructure/inst-jobs
423
446
  licenses: []
424
447
  metadata: {}
425
- post_install_message:
448
+ post_install_message:
426
449
  rdoc_options: []
427
450
  require_paths:
428
451
  - lib
@@ -437,18 +460,23 @@ required_rubygems_version: !ruby/object:Gem::Requirement
437
460
  - !ruby/object:Gem::Version
438
461
  version: '0'
439
462
  requirements: []
440
- rubygems_version: 3.0.3
441
- signing_key:
463
+ rubygems_version: 3.1.4
464
+ signing_key:
442
465
  specification_version: 4
443
466
  summary: Instructure-maintained fork of delayed_job
444
467
  test_files:
445
468
  - spec/sample_jobs.rb
446
469
  - spec/spec_helper.rb
447
470
  - spec/redis_job_spec.rb
471
+ - spec/gemfiles/51.gemfile.lock
472
+ - spec/gemfiles/60.gemfile.lock
473
+ - spec/gemfiles/42.gemfile.lock
474
+ - spec/gemfiles/50.gemfile.lock
448
475
  - spec/gemfiles/60.gemfile
449
476
  - spec/gemfiles/42.gemfile
450
477
  - spec/gemfiles/52.gemfile
451
478
  - spec/gemfiles/50.gemfile
479
+ - spec/gemfiles/52.gemfile.lock
452
480
  - spec/gemfiles/51.gemfile
453
481
  - spec/shared_jobs_specs.rb
454
482
  - spec/shared/performable_method.rb
@@ -462,6 +490,7 @@ test_files:
462
490
  - spec/delayed/cli_spec.rb
463
491
  - spec/delayed/daemon_spec.rb
464
492
  - spec/delayed/worker_spec.rb
493
+ - spec/delayed/message_sending_spec.rb
465
494
  - spec/delayed/settings_spec.rb
466
495
  - spec/delayed/work_queue/in_process_spec.rb
467
496
  - spec/delayed/work_queue/parent_process_spec.rb