solid_queue 0.3.2 → 0.3.3
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50d118a41d39dff4da741a1e7fb105b47571dd719b883fb53843e7b57f7aff66
|
4
|
+
data.tar.gz: a1dc7ff9b71a07f41fab851ea0dd2f16170240e2a465098f98e75a96c33edb4b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f344e6ba1a395f014fc08437c1322eac9b3f5218874f4b824cacab042d20053ee9a5504601e37864e04ccc956fc1f08fe35979c9d4a7b19dc42cc53ae5502c56
|
7
|
+
data.tar.gz: 27e1d8c00e2c68330d52e938bb00ecadaf246678e16b12b0e1269f8a4e8e3328a972b5a007a04d2839baf2edb480e9f0cae3b6099cd6009a75b11e85858ee6e2
|
@@ -6,16 +6,14 @@ module SolidQueue
|
|
6
6
|
extend ActiveSupport::Concern
|
7
7
|
|
8
8
|
included do
|
9
|
-
include ConcurrencyControls, Schedulable
|
9
|
+
include ConcurrencyControls, Schedulable, Retryable
|
10
10
|
|
11
11
|
has_one :ready_execution
|
12
12
|
has_one :claimed_execution
|
13
|
-
has_one :failed_execution
|
14
13
|
|
15
14
|
after_create :prepare_for_execution
|
16
15
|
|
17
16
|
scope :finished, -> { where.not(finished_at: nil) }
|
18
|
-
scope :failed, -> { includes(:failed_execution).where.not(failed_execution: { id: nil }) }
|
19
17
|
end
|
20
18
|
|
21
19
|
class_methods do
|
@@ -97,18 +95,10 @@ module SolidQueue
|
|
97
95
|
end
|
98
96
|
end
|
99
97
|
|
100
|
-
def retry
|
101
|
-
failed_execution&.retry
|
102
|
-
end
|
103
|
-
|
104
98
|
def discard
|
105
99
|
execution&.discard
|
106
100
|
end
|
107
101
|
|
108
|
-
def failed_with(exception)
|
109
|
-
FailedExecution.create_or_find_by!(job_id: id, exception: exception)
|
110
|
-
end
|
111
|
-
|
112
102
|
private
|
113
103
|
def ready
|
114
104
|
ReadyExecution.create_or_find_by!(job_id: id)
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SolidQueue
|
4
|
+
class Job
|
5
|
+
module Retryable
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
included do
|
9
|
+
has_one :failed_execution
|
10
|
+
|
11
|
+
scope :failed, -> { includes(:failed_execution).where.not(failed_execution: { id: nil }) }
|
12
|
+
end
|
13
|
+
|
14
|
+
def retry
|
15
|
+
failed_execution&.retry
|
16
|
+
end
|
17
|
+
|
18
|
+
def failed_with(exception)
|
19
|
+
FailedExecution.create_or_find_by!(job_id: id, exception: exception)
|
20
|
+
end
|
21
|
+
|
22
|
+
def reset_execution_counters
|
23
|
+
arguments["executions"] = 0
|
24
|
+
arguments["exception_executions"] = {}
|
25
|
+
save!
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -24,20 +24,21 @@ module SolidQueue
|
|
24
24
|
return [] if limit <= 0
|
25
25
|
|
26
26
|
transaction do
|
27
|
-
|
28
|
-
lock_candidates(
|
27
|
+
candidates = select_candidates(queue_relation, limit)
|
28
|
+
lock_candidates(candidates, process_id)
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
32
|
def select_candidates(queue_relation, limit)
|
33
|
-
queue_relation.ordered.limit(limit).non_blocking_lock.
|
33
|
+
queue_relation.ordered.limit(limit).non_blocking_lock.select(:id, :job_id)
|
34
34
|
end
|
35
35
|
|
36
|
-
def lock_candidates(
|
37
|
-
return [] if
|
36
|
+
def lock_candidates(executions, process_id)
|
37
|
+
return [] if executions.none?
|
38
38
|
|
39
|
-
SolidQueue::ClaimedExecution.claiming(
|
40
|
-
|
39
|
+
SolidQueue::ClaimedExecution.claiming(executions.map(&:job_id), process_id) do |claimed|
|
40
|
+
ids_to_delete = executions.index_by(&:job_id).values_at(*claimed.map(&:job_id)).map(&:id)
|
41
|
+
where(id: ids_to_delete).delete_all
|
41
42
|
end
|
42
43
|
end
|
43
44
|
|
data/lib/solid_queue/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solid_queue
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rosa Gutierrez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-06-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -199,6 +199,7 @@ files:
|
|
199
199
|
- app/models/solid_queue/job/concurrency_controls.rb
|
200
200
|
- app/models/solid_queue/job/executable.rb
|
201
201
|
- app/models/solid_queue/job/recurrable.rb
|
202
|
+
- app/models/solid_queue/job/retryable.rb
|
202
203
|
- app/models/solid_queue/job/schedulable.rb
|
203
204
|
- app/models/solid_queue/pause.rb
|
204
205
|
- app/models/solid_queue/process.rb
|