queue_classic_plus 4.0.0.alpha16 → 4.0.0.alpha18
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/base.rb +3 -21
- data/lib/queue_classic_plus/version.rb +1 -1
- data/spec/base_spec.rb +3 -26
- 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: f4194444b2e3b6bc8d08ebfe7393e9efa53bc31fdb8c7e79c5b1a6aff31e8776
|
4
|
+
data.tar.gz: a12f2b01acea5e2fb4fc6e6b257c6aafc228ff38f73280a3deb974452f2e7220
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42399e627f40795df59f4235e6d616527506758af7a988c2e7e923ce3fbad2bac49b188563ad508d66e95f9935149eaafd1928d6eac6c97bfeb9f1a437fffabe
|
7
|
+
data.tar.gz: b08d05305a8772d2aacf0e5984b5d2254f3b1f83cb8e6d4d02b7f1bb3d929d70e3ddd02b1130f9845ebec3d9ef409d7a86d63f44ff04ea3fb998dd0cab2080a0
|
@@ -2,18 +2,10 @@ module QueueClassicPlus
|
|
2
2
|
class Base
|
3
3
|
extend QueueClassicPlus::InheritableAttribute
|
4
4
|
|
5
|
-
# Max value for bigint calculated from
|
6
|
-
# https://stackoverflow.com/questions/28960478/postgres-maximum-value-for-bigint
|
7
|
-
PG_BIGINT_MAX = 9223372036854775807.freeze
|
8
|
-
|
9
5
|
def self.queue
|
10
6
|
QC::Queue.new(@queue)
|
11
7
|
end
|
12
8
|
|
13
|
-
def self.queue_name_digest
|
14
|
-
@queue_name_digest ||= @queue.to_s.to_i(36) % PG_BIGINT_MAX
|
15
|
-
end
|
16
|
-
|
17
9
|
inheritable_attr :locked
|
18
10
|
inheritable_attr :skip_transaction
|
19
11
|
inheritable_attr :retries_on
|
@@ -83,19 +75,9 @@ module QueueClassicPlus
|
|
83
75
|
end
|
84
76
|
|
85
77
|
def self.enqueue(method, *args)
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
if can_enqueue?(method, *args)
|
90
|
-
queue.enqueue(method, *serialized(args))
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
if [PG::PQTRANS_ACTIVE, PG::PQTRANS_INTRANS].include?(conn.transaction_status)
|
95
|
-
check_and_enqueue.call
|
96
|
-
else
|
97
|
-
conn.transaction &check_and_enqueue
|
98
|
-
end
|
78
|
+
if can_enqueue?(method, *args)
|
79
|
+
queue.enqueue(method, *serialized(args))
|
80
|
+
end
|
99
81
|
end
|
100
82
|
|
101
83
|
def self.enqueue_perform(*args)
|
data/spec/base_spec.rb
CHANGED
@@ -12,15 +12,9 @@ describe QueueClassicPlus::Base do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
it "does not allow multiple enqueues" do
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
subject.do
|
19
|
-
expect(subject).to have_queue_size_of(1)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
threads.each(&:join)
|
15
|
+
subject.do
|
16
|
+
subject.do
|
17
|
+
expect(subject).to have_queue_size_of(1)
|
24
18
|
end
|
25
19
|
|
26
20
|
it "checks for an existing job using the same serializing as job enqueuing" do
|
@@ -44,23 +38,6 @@ describe QueueClassicPlus::Base do
|
|
44
38
|
end
|
45
39
|
end
|
46
40
|
|
47
|
-
context "when in a transaction" do
|
48
|
-
subject do
|
49
|
-
Class.new(QueueClassicPlus::Base) do
|
50
|
-
@queue = :test
|
51
|
-
lock!
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
it "does not create another transaction when enqueueing" do
|
56
|
-
conn = QC.default_conn_adapter.connection
|
57
|
-
expect(conn).to receive(:transaction).exactly(1).times.and_call_original
|
58
|
-
conn.transaction do
|
59
|
-
subject.do
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
41
|
context "with default settings" do
|
65
42
|
subject do
|
66
43
|
Class.new(QueueClassicPlus::Base) do
|
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.alpha18
|
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-09-06 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: queue_classic
|