queue_classic_plus 4.0.0.alpha19 → 4.0.0.alpha20
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/queue_classic_plus/version.rb +1 -1
- data/lib/queue_classic_plus/worker.rb +26 -12
- data/spec/worker_spec.rb +42 -0
- 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: 4e0d46c9b50526efda508c6b06114bff55fe3fe3d34f519b2fb65d55f4b16848
|
4
|
+
data.tar.gz: fd2fa603af9a4e4f65f3021b8e84b1c25f6effa68aed4d5b81b980b04def5b09
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d19aa544d277fcf0f04954fa9f3dfeb476435e2a4342663c73faa3150d40175b7ab7079550fa469e8b488b41a97e55d46950990714ba4898710bb42e27493672
|
7
|
+
data.tar.gz: c3ed2d8b5cbfcf0e8d1ecfd9bc0432f9c2b371061d5b5473df96d7e299a1ccb4d283a66dc7316de8a6719312254d3eafd9e3ae735b5876b7000334fda040f52e
|
@@ -26,15 +26,19 @@ module QueueClassicPlus
|
|
26
26
|
|
27
27
|
@failed_job = job
|
28
28
|
@raw_args = job[:args]
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
29
|
+
|
30
|
+
if queue_classic_plus_job?
|
31
|
+
@failed_job_args = failed_job_class.deserialized(@raw_args)
|
32
|
+
|
33
|
+
if force_retry && !failed_job_class.disable_retries
|
34
|
+
Metrics.increment("qc.force_retry", source: @q_name)
|
35
|
+
retry_with_remaining(e)
|
36
|
+
elsif failed_job_class.retries_on?(e)
|
37
|
+
Metrics.increment("qc.retry", source: @q_name)
|
38
|
+
retry_with_remaining(e)
|
39
|
+
else
|
40
|
+
enqueue_failed(e)
|
41
|
+
end
|
38
42
|
else
|
39
43
|
enqueue_failed(e)
|
40
44
|
end
|
@@ -60,10 +64,20 @@ module QueueClassicPlus
|
|
60
64
|
(@failed_job[:remaining_retries] || max_retries).to_i
|
61
65
|
end
|
62
66
|
|
67
|
+
def queue_classic_plus_job?
|
68
|
+
failed_job_class && failed_job_class < Base
|
69
|
+
end
|
70
|
+
|
63
71
|
def failed_job_class
|
64
|
-
|
65
|
-
|
66
|
-
|
72
|
+
return @failed_job_class if @failed_job_class_memoized
|
73
|
+
|
74
|
+
@failed_job_class_memoized = true
|
75
|
+
@failed_job_class =
|
76
|
+
begin
|
77
|
+
Object.const_get(@failed_job[:method].split('.')[0])
|
78
|
+
rescue NameError
|
79
|
+
nil
|
80
|
+
end
|
67
81
|
end
|
68
82
|
|
69
83
|
def backoff
|
data/spec/worker_spec.rb
CHANGED
@@ -45,6 +45,48 @@ describe QueueClassicPlus::CustomWorker do
|
|
45
45
|
expect(job).to_not be_nil
|
46
46
|
expect(job['last_error']).to_not be_nil
|
47
47
|
end
|
48
|
+
|
49
|
+
context 'for a non-QueueClassicPlus job' do
|
50
|
+
let(:job_type) do
|
51
|
+
Class.new(ActiveJob::Base) do
|
52
|
+
def self.name
|
53
|
+
"NonQcJob"
|
54
|
+
end
|
55
|
+
|
56
|
+
self.queue_adapter = :queue_classic
|
57
|
+
|
58
|
+
queue_as :test
|
59
|
+
|
60
|
+
def perform(boom)
|
61
|
+
raise boom.to_s
|
62
|
+
end
|
63
|
+
end.tap { Object.const_set(:NonQcJob, _1) }
|
64
|
+
end
|
65
|
+
let(:queue) { QC::Queue.new("test") }
|
66
|
+
|
67
|
+
it 'properly enqueues for jobs in the failed queue' do
|
68
|
+
non_qc_job = job_type.new(:boom).enqueue
|
69
|
+
job_id = non_qc_job.provider_job_id
|
70
|
+
|
71
|
+
expect(failed_queue.count).to eq(0)
|
72
|
+
job = find_job(job_id)
|
73
|
+
expect(job).to_not be_nil
|
74
|
+
expect(find_job(job_id.succ)).to be_nil
|
75
|
+
args = JSON.load(job['args']).first
|
76
|
+
expect(args['arguments']).to eq(QueueClassicPlus::Base.serialized([:boom]))
|
77
|
+
|
78
|
+
worker.work
|
79
|
+
|
80
|
+
expect(failed_queue.count).to eq(1)
|
81
|
+
expect(find_job(job_id)).to be_nil
|
82
|
+
job = find_job(job_id.succ)
|
83
|
+
expect(job).to_not be_nil
|
84
|
+
failed_args = JSON.load(job['args']).first
|
85
|
+
expect(failed_args['arguments']).to eq(QueueClassicPlus::Base.serialized([:boom]))
|
86
|
+
expect(job['last_error']).to_not be_nil
|
87
|
+
expect(job['last_error']).to start_with("boom\n")
|
88
|
+
end
|
89
|
+
end
|
48
90
|
end
|
49
91
|
end
|
50
92
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: queue_classic_plus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.0.
|
4
|
+
version: 4.0.0.alpha20
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simon Mathieu
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2023-
|
13
|
+
date: 2023-11-06 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: queue_classic
|