queue_classic_plus 4.0.0.alpha13 → 4.0.0.alpha15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +14 -5
- data/lib/queue_classic_plus/base.rb +17 -3
- data/lib/queue_classic_plus/version.rb +1 -1
- data/spec/base_spec.rb +26 -3
- 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: 634ceaedff254e0c5382a484d574d6971101362a88b9d2185303d95298de06c8
|
4
|
+
data.tar.gz: '03509124366e931f02d928226da3b05ec3e625c5888eaba88f5669ee090566b6'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c8b6ff9e377c59b579c7309ee1f75e3fb583b00450ef09548f46d5d6e921c2553cf64037b259a1267b2781276f2e06ccceb3c8e5d6bc76373dc9e64e7a61522
|
7
|
+
data.tar.gz: d3852486ebdf22d4c59d142a8f00257f2fa7b0847d09704001644e56cb5ab91845ba154807bc2699491f379b62c98656da7b70735c9b3d3ba13638efaddfefb6
|
data/README.md
CHANGED
@@ -126,7 +126,7 @@ end
|
|
126
126
|
|
127
127
|
## Advanced configuration
|
128
128
|
|
129
|
-
If you want to log exceptions in your favorite exception tracker. You can configured it like
|
129
|
+
If you want to log exceptions in your favorite exception tracker. You can configured it like so:
|
130
130
|
|
131
131
|
```ruby
|
132
132
|
QueueClassicPlus.exception_handler = -> (exception, job) do
|
@@ -142,20 +142,26 @@ Push metrics to your metric provider (only Librato is supported for now).
|
|
142
142
|
QueueClassicPlus.update_metrics
|
143
143
|
```
|
144
144
|
|
145
|
-
Call this
|
145
|
+
Call this in a cron job or something similar.
|
146
146
|
|
147
|
-
If you are using
|
147
|
+
If you are using New Relic and want to push performance data to it, you can add this to an initializer:
|
148
148
|
|
149
149
|
```ruby
|
150
150
|
require "queue_classic_plus/new_relic"
|
151
151
|
```
|
152
152
|
|
153
|
-
To instrument
|
153
|
+
To instrument Datadog monitoring add this to your QC initializer:
|
154
154
|
|
155
155
|
```ruby
|
156
156
|
require "queue_classic_plus/datadog"
|
157
157
|
```
|
158
158
|
|
159
|
+
The Datadog service name defaults to `qc.job`. This can be changed in the initializer:
|
160
|
+
|
161
|
+
```ruby
|
162
|
+
QueueClassicDatadog.config.dd_service = "custom_service_name"
|
163
|
+
```
|
164
|
+
|
159
165
|
## Contributing
|
160
166
|
|
161
167
|
1. Fork it ( https://github.com/[my-github-username]/queue_classic_plus/fork )
|
@@ -172,4 +178,7 @@ createdb queue_classic_plus_test
|
|
172
178
|
|
173
179
|
## Releasing
|
174
180
|
|
175
|
-
Releasing is done in CircleCI via the `push_to_rubygems`, triggered by pushing a tagged commit.
|
181
|
+
Releasing is done in CircleCI via the `push_to_rubygems`, triggered by pushing a tagged commit.
|
182
|
+
You can create a new `tag` while [creating a new GitHub release](https://github.com/rainforestapp/queue_classic_plus/releases/new).
|
183
|
+
|
184
|
+
_** Note: The `tag` is what publishes a new version of the gem. The `release` is purely for documentation._
|
@@ -6,6 +6,10 @@ module QueueClassicPlus
|
|
6
6
|
QC::Queue.new(@queue)
|
7
7
|
end
|
8
8
|
|
9
|
+
def self.queue_name_digest
|
10
|
+
@queue_name_digest ||= @queue.to_s.to_i(36)
|
11
|
+
end
|
12
|
+
|
9
13
|
inheritable_attr :locked
|
10
14
|
inheritable_attr :skip_transaction
|
11
15
|
inheritable_attr :retries_on
|
@@ -75,9 +79,19 @@ module QueueClassicPlus
|
|
75
79
|
end
|
76
80
|
|
77
81
|
def self.enqueue(method, *args)
|
78
|
-
|
79
|
-
|
80
|
-
|
82
|
+
conn = QC.default_conn_adapter.connection
|
83
|
+
check_and_enqueue = proc do
|
84
|
+
conn.exec("SELECT pg_advisory_xact_lock(#{queue_name_digest})")
|
85
|
+
if can_enqueue?(method, *args)
|
86
|
+
queue.enqueue(method, *serialized(args))
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
if [PG::PQTRANS_ACTIVE, PG::PQTRANS_INTRANS].include?(conn.transaction_status)
|
91
|
+
check_and_enqueue.call
|
92
|
+
else
|
93
|
+
conn.transaction &check_and_enqueue
|
94
|
+
end
|
81
95
|
end
|
82
96
|
|
83
97
|
def self.enqueue_perform(*args)
|
data/spec/base_spec.rb
CHANGED
@@ -12,9 +12,15 @@ describe QueueClassicPlus::Base do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
it "does not allow multiple enqueues" do
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
threads = []
|
16
|
+
50.times do
|
17
|
+
threads << Thread.new do
|
18
|
+
subject.do
|
19
|
+
expect(subject).to have_queue_size_of(1)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
threads.each(&:join)
|
18
24
|
end
|
19
25
|
|
20
26
|
it "checks for an existing job using the same serializing as job enqueuing" do
|
@@ -38,6 +44,23 @@ describe QueueClassicPlus::Base do
|
|
38
44
|
end
|
39
45
|
end
|
40
46
|
|
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
|
+
|
41
64
|
context "with default settings" do
|
42
65
|
subject do
|
43
66
|
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.alpha15
|
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-08-
|
13
|
+
date: 2023-08-09 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: queue_classic
|