inst-jobs 3.0.13 → 3.1.0
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/delayed/backend/base.rb +8 -2
- data/lib/delayed/lifecycle.rb +1 -0
- data/lib/delayed/server.rb +1 -1
- data/lib/delayed/version.rb +1 -1
- data/lib/delayed/worker.rb +1 -1
- data/spec/shared/shared_backend.rb +16 -0
- data/spec/spec_helper.rb +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 37ca25ff97580c47a56d0d40a1ab2f78c62a2f47629d0c2e5ba6c8e5c4ace0bd
|
4
|
+
data.tar.gz: 16d4a060bfc0c23f84360d305e35adb5482d0d96f50b50c1a45a8a0b02739c90
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f981418c6f0493c84114777193674559f8a0a15006547600bc00cc44eaaff08232c7695f801a3b84c2919167c68c7fb7d91562aa1d4d47d9f98d28a1362b0e3
|
7
|
+
data.tar.gz: 4b31d64c30f9208c54b32796d6ad99f22f9beb3f405a8b4585398306d03b15063d3fde88fce2d063f4f76949da1e350bf4607b8bcf6709a4a20ff686f5c87b6d
|
data/lib/delayed/backend/base.rb
CHANGED
@@ -86,8 +86,12 @@ module Delayed
|
|
86
86
|
kwargs.merge!(n_strand_options(full_strand_name, num_strands))
|
87
87
|
end
|
88
88
|
|
89
|
+
job = nil
|
90
|
+
|
89
91
|
if singleton
|
90
|
-
|
92
|
+
Delayed::Worker.lifecycle.run_callbacks(:create, kwargs) do
|
93
|
+
job = create(**kwargs)
|
94
|
+
end
|
91
95
|
elsif batches && strand.nil? && run_at.nil?
|
92
96
|
batch_enqueue_args = kwargs.slice(*self.batch_enqueue_args)
|
93
97
|
batches[batch_enqueue_args] << kwargs
|
@@ -95,7 +99,9 @@ module Delayed
|
|
95
99
|
else
|
96
100
|
raise ArgumentError, "on_conflict can only be provided with singleton" if kwargs[:on_conflict]
|
97
101
|
|
98
|
-
|
102
|
+
Delayed::Worker.lifecycle.run_callbacks(:create, kwargs) do
|
103
|
+
job = create(**kwargs)
|
104
|
+
end
|
99
105
|
end
|
100
106
|
|
101
107
|
JobTracking.job_created(job)
|
data/lib/delayed/lifecycle.rb
CHANGED
data/lib/delayed/server.rb
CHANGED
@@ -16,7 +16,7 @@ module Delayed
|
|
16
16
|
# Rails will take care of establishing the DB connection for us if there is
|
17
17
|
# an application present
|
18
18
|
if using_active_record? && !ActiveRecord::Base.connected?
|
19
|
-
ActiveRecord::Base.establish_connection(ENV
|
19
|
+
ActiveRecord::Base.establish_connection(ENV.fetch("DATABASE_URL", nil))
|
20
20
|
end
|
21
21
|
|
22
22
|
@allow_update = args.length.positive? && args[0][:update]
|
data/lib/delayed/version.rb
CHANGED
data/lib/delayed/worker.rb
CHANGED
@@ -276,7 +276,7 @@ module Delayed
|
|
276
276
|
# set up the session context information, so that it gets logged with the job log lines
|
277
277
|
# also set up a unique tmpdir, which will get removed at the end of the job.
|
278
278
|
def configure_for_job(job)
|
279
|
-
previous_tmpdir = ENV
|
279
|
+
previous_tmpdir = ENV.fetch("TMPDIR", nil)
|
280
280
|
|
281
281
|
self.class.running_job(job) do
|
282
282
|
dir = Dir.mktmpdir("job-#{job.id}-#{name.gsub(/[^\w.]/, '.')}-")
|
@@ -35,6 +35,22 @@ shared_examples_for "a backend" do
|
|
35
35
|
expect(Delayed::Job.jobs_count(:current)).to eq(1)
|
36
36
|
end
|
37
37
|
|
38
|
+
it "triggers the lifecycle event around the create" do
|
39
|
+
called = false
|
40
|
+
called_args = nil
|
41
|
+
|
42
|
+
Delayed::Worker.lifecycle.after(:create) do |args|
|
43
|
+
called = true
|
44
|
+
called_args = args
|
45
|
+
end
|
46
|
+
|
47
|
+
job = SimpleJob.new
|
48
|
+
Delayed::Job.enqueue(job)
|
49
|
+
|
50
|
+
expect(called).to be_truthy
|
51
|
+
expect(called_args[:payload_object]).to eq job
|
52
|
+
end
|
53
|
+
|
38
54
|
it "is able to set priority when enqueuing items" do
|
39
55
|
@job = Delayed::Job.enqueue SimpleJob.new, priority: 5
|
40
56
|
expect(@job.priority).to eq(5)
|
data/spec/spec_helper.rb
CHANGED
@@ -47,14 +47,14 @@ RSpec::Core::ExampleGroup.include(NoYamlDump)
|
|
47
47
|
|
48
48
|
ENV["TEST_ENV_NUMBER"] ||= "1"
|
49
49
|
ENV["TEST_DB_HOST"] ||= "localhost"
|
50
|
-
ENV["TEST_DB_DATABASE"] ||= "inst-jobs-test-#{ENV
|
50
|
+
ENV["TEST_DB_DATABASE"] ||= "inst-jobs-test-#{ENV.fetch('TEST_ENV_NUMBER', nil)}"
|
51
51
|
|
52
52
|
connection_config = {
|
53
53
|
adapter: :postgresql,
|
54
54
|
host: ENV["TEST_DB_HOST"].presence,
|
55
55
|
encoding: "utf8",
|
56
|
-
username: ENV
|
57
|
-
database: ENV
|
56
|
+
username: ENV.fetch("TEST_DB_USERNAME", nil),
|
57
|
+
database: ENV.fetch("TEST_DB_DATABASE", nil),
|
58
58
|
min_messages: "notice",
|
59
59
|
# Ensure the pool is big enough the deadlock tests don't get starved for connections by rails instead
|
60
60
|
pool: 20
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inst-jobs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cody Cutrer
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2022-
|
13
|
+
date: 2022-05-09 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activerecord
|