queue_classic_plus 4.0.0.alpha19 → 4.0.0.alpha21

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4ded39f47849c6dacb9e4efe8bc535bf9fae56cf15cc366cdde177e12176ae37
4
- data.tar.gz: 228a9d4ed7b5a4541e1d93e9887c3f3ec9193e9464c9766817ffd1690530d864
3
+ metadata.gz: d61507724f9d6b55e0cb83626e9cebd28e41d30f950c6fb30d16d38b762ff411
4
+ data.tar.gz: 4661d1689861baf7658ee403bba56551a0a8830932c604a550b07e3f2c8e5e57
5
5
  SHA512:
6
- metadata.gz: 447ed6984427a1649f76ed733c2eafcf6324a5591265cd3f3ec9d29ca8f09552c2a93134b3a481ab06fd1d64b1f78db405fd4ade10e1b372eb62b6e8cbdfe364
7
- data.tar.gz: c4b1823ae678c44d3d0892ff2bb44dc6ec844339717e1a8e0ce62ff564aee690e3f5d19c9ab254c6538ce2e3e4466c1789bc5b50beba787e49a8af22d60f892f
6
+ metadata.gz: c5044392ec3912a4e5d967ca8c5418bedad08f75176c53ade15d88f256d8658ca33570530cb3158de659d0b3fe517f13e6a68dce012a7ad569a2d99b7ce6fd9f
7
+ data.tar.gz: 41200b7ae13c0405c340ba1882e1ae064895734572ee6421a3adf1b6f5b3bc53ec2b5e2afda603312b4e8c7c9af05ccbd0e862f2a09d683ead29e47214ea2829
@@ -1,3 +1,3 @@
1
1
  module QueueClassicPlus
2
- VERSION = '4.0.0.alpha19'.freeze
2
+ VERSION = '4.0.0.alpha21'.freeze
3
3
  end
@@ -24,17 +24,22 @@ module QueueClassicPlus
24
24
  force_retry = true
25
25
  end
26
26
 
27
+ @failed_job_class_memoized = false
27
28
  @failed_job = job
28
29
  @raw_args = job[:args]
29
- @failed_job_args = failed_job_class ? failed_job_class.deserialized(@raw_args) : @raw_args
30
-
31
- if force_retry && !(failed_job_class.respond_to?(:disable_retries) && failed_job_class.disable_retries)
32
- Metrics.increment("qc.force_retry", source: @q_name)
33
- retry_with_remaining(e)
34
- # The mailers doesn't have a retries_on?
35
- elsif failed_job_class.respond_to?(:retries_on?) && failed_job_class.retries_on?(e)
36
- Metrics.increment("qc.retry", source: @q_name)
37
- retry_with_remaining(e)
30
+
31
+ if queue_classic_plus_job?
32
+ @failed_job_args = failed_job_class.deserialized(@raw_args)
33
+
34
+ if force_retry && !failed_job_class.disable_retries
35
+ Metrics.increment("qc.force_retry", source: @q_name)
36
+ retry_with_remaining(e)
37
+ elsif failed_job_class.retries_on?(e)
38
+ Metrics.increment("qc.retry", source: @q_name)
39
+ retry_with_remaining(e)
40
+ else
41
+ enqueue_failed(e)
42
+ end
38
43
  else
39
44
  enqueue_failed(e)
40
45
  end
@@ -60,10 +65,20 @@ module QueueClassicPlus
60
65
  (@failed_job[:remaining_retries] || max_retries).to_i
61
66
  end
62
67
 
68
+ def queue_classic_plus_job?
69
+ failed_job_class && failed_job_class < Base
70
+ end
71
+
63
72
  def failed_job_class
64
- Object.const_get(@failed_job[:method].split('.')[0])
65
- rescue NameError
66
- nil
73
+ return @failed_job_class if @failed_job_class_memoized
74
+
75
+ @failed_job_class_memoized = true
76
+ @failed_job_class =
77
+ begin
78
+ Object.const_get(@failed_job[:method].split('.')[0])
79
+ rescue NameError
80
+ nil
81
+ end
67
82
  end
68
83
 
69
84
  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.alpha19
4
+ version: 4.0.0.alpha21
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-09-10 00:00:00.000000000 Z
13
+ date: 2023-11-07 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: queue_classic