queue_classic_plus 4.0.0.alpha19 → 4.0.0.alpha20

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: 4e0d46c9b50526efda508c6b06114bff55fe3fe3d34f519b2fb65d55f4b16848
4
+ data.tar.gz: fd2fa603af9a4e4f65f3021b8e84b1c25f6effa68aed4d5b81b980b04def5b09
5
5
  SHA512:
6
- metadata.gz: 447ed6984427a1649f76ed733c2eafcf6324a5591265cd3f3ec9d29ca8f09552c2a93134b3a481ab06fd1d64b1f78db405fd4ade10e1b372eb62b6e8cbdfe364
7
- data.tar.gz: c4b1823ae678c44d3d0892ff2bb44dc6ec844339717e1a8e0ce62ff564aee690e3f5d19c9ab254c6538ce2e3e4466c1789bc5b50beba787e49a8af22d60f892f
6
+ metadata.gz: d19aa544d277fcf0f04954fa9f3dfeb476435e2a4342663c73faa3150d40175b7ab7079550fa469e8b488b41a97e55d46950990714ba4898710bb42e27493672
7
+ data.tar.gz: c3ed2d8b5cbfcf0e8d1ecfd9bc0432f9c2b371061d5b5473df96d7e299a1ccb4d283a66dc7316de8a6719312254d3eafd9e3ae735b5876b7000334fda040f52e
@@ -1,3 +1,3 @@
1
1
  module QueueClassicPlus
2
- VERSION = '4.0.0.alpha19'.freeze
2
+ VERSION = '4.0.0.alpha20'.freeze
3
3
  end
@@ -26,15 +26,19 @@ module QueueClassicPlus
26
26
 
27
27
  @failed_job = job
28
28
  @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)
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
- Object.const_get(@failed_job[:method].split('.')[0])
65
- rescue NameError
66
- nil
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.alpha19
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-09-10 00:00:00.000000000 Z
13
+ date: 2023-11-06 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: queue_classic