inst-jobs 2.3.3 → 2.4.11
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 +9 -7
- data/db/migrate/20110531144916_cleanup_delayed_jobs_indexes.rb +8 -13
- data/db/migrate/20110610213249_optimize_delayed_jobs.rb +8 -8
- data/db/migrate/20110831210257_add_delayed_jobs_next_in_strand.rb +25 -25
- data/db/migrate/20120510004759_delayed_jobs_delete_trigger_lock_for_update.rb +4 -8
- data/db/migrate/20120531150712_drop_psql_jobs_pop_fn.rb +1 -3
- data/db/migrate/20120607164022_delayed_jobs_use_advisory_locks.rb +11 -15
- data/db/migrate/20120607181141_index_jobs_on_locked_by.rb +1 -1
- data/db/migrate/20120608191051_add_jobs_run_at_index.rb +2 -2
- data/db/migrate/20120927184213_change_delayed_jobs_handler_to_text.rb +1 -1
- data/db/migrate/20140505215510_copy_failed_jobs_original_id.rb +2 -3
- data/db/migrate/20150807133223_add_max_concurrent_to_jobs.rb +9 -13
- data/db/migrate/20151210162949_improve_max_concurrent.rb +4 -8
- data/db/migrate/20161206323555_add_back_default_string_limits_jobs.rb +3 -2
- data/db/migrate/20181217155351_speed_up_max_concurrent_triggers.rb +13 -17
- data/db/migrate/20200330230722_add_id_to_get_delayed_jobs_index.rb +8 -8
- data/db/migrate/20200824222232_speed_up_max_concurrent_delete_trigger.rb +72 -77
- data/db/migrate/20200825011002_add_strand_order_override.rb +93 -97
- data/db/migrate/20210809145804_add_n_strand_index.rb +3 -3
- data/db/migrate/20210812210128_add_singleton_column.rb +200 -0
- data/db/migrate/20210917232626_add_delete_conflicting_singletons_before_unlock_trigger.rb +27 -0
- data/db/migrate/20210928174754_fix_singleton_condition_in_before_insert.rb +56 -0
- data/exe/inst_jobs +3 -2
- data/lib/delayed/backend/active_record.rb +204 -150
- data/lib/delayed/backend/base.rb +106 -82
- data/lib/delayed/batch.rb +11 -9
- data/lib/delayed/cli.rb +98 -84
- data/lib/delayed/core_ext/kernel.rb +4 -2
- data/lib/delayed/daemon.rb +70 -74
- data/lib/delayed/job_tracking.rb +26 -25
- data/lib/delayed/lifecycle.rb +27 -24
- data/lib/delayed/log_tailer.rb +17 -17
- data/lib/delayed/logging.rb +13 -16
- data/lib/delayed/message_sending.rb +43 -52
- data/lib/delayed/performable_method.rb +6 -8
- data/lib/delayed/periodic.rb +72 -65
- data/lib/delayed/plugin.rb +2 -4
- data/lib/delayed/pool.rb +198 -193
- data/lib/delayed/server/helpers.rb +6 -6
- data/lib/delayed/server.rb +51 -54
- data/lib/delayed/settings.rb +93 -81
- data/lib/delayed/testing.rb +21 -22
- data/lib/delayed/version.rb +1 -1
- data/lib/delayed/work_queue/in_process.rb +21 -18
- data/lib/delayed/work_queue/parent_process/client.rb +54 -55
- data/lib/delayed/work_queue/parent_process/server.rb +219 -208
- data/lib/delayed/work_queue/parent_process.rb +52 -53
- data/lib/delayed/worker/consul_health_check.rb +21 -19
- data/lib/delayed/worker/health_check.rb +29 -22
- data/lib/delayed/worker/null_health_check.rb +3 -1
- data/lib/delayed/worker/process_helper.rb +8 -9
- data/lib/delayed/worker.rb +271 -265
- data/lib/delayed/yaml_extensions.rb +12 -10
- data/lib/delayed_job.rb +37 -38
- data/lib/inst-jobs.rb +1 -1
- data/spec/active_record_job_spec.rb +129 -136
- data/spec/delayed/cli_spec.rb +7 -7
- data/spec/delayed/daemon_spec.rb +10 -9
- data/spec/delayed/message_sending_spec.rb +16 -9
- data/spec/delayed/periodic_spec.rb +13 -12
- data/spec/delayed/server_spec.rb +38 -38
- data/spec/delayed/settings_spec.rb +26 -25
- data/spec/delayed/work_queue/in_process_spec.rb +7 -8
- data/spec/delayed/work_queue/parent_process/client_spec.rb +17 -12
- data/spec/delayed/work_queue/parent_process/server_spec.rb +70 -41
- data/spec/delayed/work_queue/parent_process_spec.rb +21 -23
- data/spec/delayed/worker/consul_health_check_spec.rb +22 -22
- data/spec/delayed/worker/health_check_spec.rb +60 -52
- data/spec/delayed/worker_spec.rb +28 -25
- data/spec/sample_jobs.rb +45 -15
- data/spec/shared/delayed_batch.rb +74 -67
- data/spec/shared/delayed_method.rb +143 -102
- data/spec/shared/performable_method.rb +39 -38
- data/spec/shared/shared_backend.rb +547 -441
- data/spec/shared/testing.rb +14 -14
- data/spec/shared/worker.rb +155 -147
- data/spec/shared_jobs_specs.rb +13 -13
- data/spec/spec_helper.rb +46 -41
- metadata +79 -55
- data/lib/delayed/backend/redis/bulk_update.lua +0 -50
- data/lib/delayed/backend/redis/destroy_job.lua +0 -2
- data/lib/delayed/backend/redis/enqueue.lua +0 -29
- data/lib/delayed/backend/redis/fail_job.lua +0 -5
- data/lib/delayed/backend/redis/find_available.lua +0 -3
- data/lib/delayed/backend/redis/functions.rb +0 -59
- data/lib/delayed/backend/redis/get_and_lock_next_available.lua +0 -17
- data/lib/delayed/backend/redis/includes/jobs_common.lua +0 -203
- data/lib/delayed/backend/redis/job.rb +0 -528
- data/lib/delayed/backend/redis/set_running.lua +0 -5
- data/lib/delayed/backend/redis/tickle_strand.lua +0 -2
- data/spec/gemfiles/52.gemfile +0 -7
- data/spec/gemfiles/60.gemfile +0 -7
- data/spec/gemfiles/60.gemfile.lock +0 -246
- data/spec/gemfiles/61.gemfile +0 -7
- data/spec/redis_job_spec.rb +0 -148
@@ -1,73 +1,74 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
shared_examples_for
|
4
|
-
|
5
|
-
|
6
|
-
story = Story.create :text => 'Once upon...'
|
3
|
+
shared_examples_for "Delayed::PerformableMethod" do
|
4
|
+
it "does not ignore ActiveRecord::RecordNotFound errors because they are not always permanent" do
|
5
|
+
story = Story.create text: "Once upon..."
|
7
6
|
p = Delayed::PerformableMethod.new(story, :tell)
|
8
7
|
story.destroy
|
9
|
-
|
8
|
+
expect { YAML.load(p.to_yaml) }.to raise_error(Delayed::Backend::RecordNotFound)
|
10
9
|
end
|
11
10
|
|
12
|
-
it "
|
13
|
-
story = Story.create :
|
11
|
+
it "stores the object using native YAML even if its an active record" do
|
12
|
+
story = Story.create text: "Once upon..."
|
14
13
|
p = Delayed::PerformableMethod.new(story, :tell)
|
15
|
-
p.class.
|
16
|
-
p.object.
|
17
|
-
p.method.
|
18
|
-
p.args.
|
19
|
-
p.perform.
|
14
|
+
expect(p.class).to eq(Delayed::PerformableMethod)
|
15
|
+
expect(p.object).to eq(story)
|
16
|
+
expect(p.method).to eq(:tell)
|
17
|
+
expect(p.args).to eq([])
|
18
|
+
expect(p.perform).to eq("Once upon...")
|
20
19
|
end
|
21
20
|
|
22
|
-
it "
|
23
|
-
Story.create!(:
|
21
|
+
it "allows class methods to be called on ActiveRecord models" do
|
22
|
+
Story.create!(text: "Once upon a...")
|
24
23
|
p = Delayed::PerformableMethod.new(Story, :count)
|
25
|
-
|
24
|
+
expect { expect(p.send(:perform)).to be 1 }.not_to raise_error
|
26
25
|
end
|
27
26
|
|
28
|
-
it "
|
27
|
+
it "allows class methods to be called" do
|
29
28
|
p = Delayed::PerformableMethod.new(StoryReader, :reverse, args: ["ohai"])
|
30
|
-
|
29
|
+
expect { expect(p.send(:perform)).to eq("iaho") }.not_to raise_error
|
31
30
|
end
|
32
31
|
|
33
|
-
it "
|
32
|
+
it "allows module methods to be called" do
|
34
33
|
p = Delayed::PerformableMethod.new(MyReverser, :reverse, args: ["ohai"])
|
35
|
-
|
34
|
+
expect { expect(p.send(:perform)).to eq("iaho") }.not_to raise_error
|
36
35
|
end
|
37
36
|
|
38
|
-
it "
|
39
|
-
story = Story.create :
|
37
|
+
it "stores arguments as native YAML if they are active record objects" do
|
38
|
+
story = Story.create text: "Once upon..."
|
40
39
|
reader = StoryReader.new
|
41
40
|
p = Delayed::PerformableMethod.new(reader, :read, args: [story])
|
42
|
-
p.class.
|
43
|
-
p.method.
|
44
|
-
p.args.
|
45
|
-
p.perform.
|
41
|
+
expect(p.class).to eq(Delayed::PerformableMethod)
|
42
|
+
expect(p.method).to eq(:read)
|
43
|
+
expect(p.args).to eq([story])
|
44
|
+
expect(p.perform).to eq("Epilog: Once upon...")
|
46
45
|
end
|
47
46
|
|
48
|
-
it "
|
49
|
-
story = Story.create :
|
47
|
+
it "deeplies de-AR-ize arguments in full name" do
|
48
|
+
story = Story.create text: "Once upon..."
|
50
49
|
reader = StoryReader.new
|
51
|
-
p = Delayed::PerformableMethod.new(reader, :read, args: [[
|
52
|
-
p.full_name.
|
50
|
+
p = Delayed::PerformableMethod.new(reader, :read, args: [["arg1", story, { [:key, 1] => story }]])
|
51
|
+
expect(p.full_name).to eq(
|
52
|
+
"StoryReader#read([\"arg1\", Story.find(#{story.id}), {[:key, 1] => Story.find(#{story.id})}])"
|
53
|
+
)
|
53
54
|
end
|
54
55
|
|
55
|
-
it "
|
56
|
-
story = Story.create :
|
56
|
+
it "calls the on_failure callback" do
|
57
|
+
story = Story.create text: "wat"
|
57
58
|
p = Delayed::PerformableMethod.new(story, :tell, on_failure: :text=)
|
58
|
-
p.send(:on_failure,
|
59
|
-
story.text.
|
59
|
+
p.send(:on_failure, "fail")
|
60
|
+
expect(story.text).to eq("fail")
|
60
61
|
end
|
61
62
|
|
62
|
-
it "
|
63
|
-
story = Story.create :
|
63
|
+
it "calls the on_permanent_failure callback" do
|
64
|
+
story = Story.create text: "wat"
|
64
65
|
p = Delayed::PerformableMethod.new(story, :tell, on_permanent_failure: :text=)
|
65
|
-
p.send(:on_permanent_failure,
|
66
|
-
story.text.
|
66
|
+
p.send(:on_permanent_failure, "fail_frd")
|
67
|
+
expect(story.text).to eq("fail_frd")
|
67
68
|
end
|
68
69
|
|
69
70
|
it "can still generate a name with no kwargs" do
|
70
|
-
story = Story.create :
|
71
|
+
story = Story.create text: "wat"
|
71
72
|
p = Delayed::PerformableMethod.new(story, :tell, kwargs: nil)
|
72
73
|
expect(p.full_name).to eq("Story.find(#{story.id}).tell()")
|
73
74
|
end
|