backburner-allq 1.0.12 → 1.0.18
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/deploy.sh +1 -1
- data/lib/backburner/allq_wrapper.rb +19 -8
- data/lib/backburner/version.rb +1 -1
- data/lib/backburner/worker.rb +35 -29
- data/lib/backburner/workers/threads_on_fork.rb +3 -1
- 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: a66b297949437303186f84d3ab4198416a72824de72142dd4727aa029365f119
|
4
|
+
data.tar.gz: b737ec4f3df6378167da3d5936c408ea6b1a92b05391c3c4ab9021160108492c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 02ec21561843632c02a39742c7eef8591f94a7320af93bc77d566bc6e5d390c089fdeef1b56b5df3865a3430ad3e7a350b51d9faebfdb2fcebd4944905c4150e
|
7
|
+
data.tar.gz: 51ffee578303fd24e70278788153cc6265a356ddab6882c8bd62c7447c8434f7949b7d4deb35affd8a14d7d4f295d1494d48d89dc27e0eec9bf4c06ee69093b0
|
data/deploy.sh
CHANGED
@@ -13,14 +13,16 @@ module Backburner
|
|
13
13
|
|
14
14
|
def watch
|
15
15
|
Thread.new do
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
16
|
+
loop do
|
17
|
+
ran = false
|
18
|
+
job = @allq_wrapper.get(@tube_name)
|
19
|
+
if job.body
|
20
|
+
perform(job)
|
21
|
+
ran = true
|
22
|
+
end
|
23
|
+
# Wait if nothing returned
|
24
|
+
sleep(rand() * 3) unless ran
|
21
25
|
end
|
22
|
-
# Wait if nothing returned
|
23
|
-
sleep(rand() * 3) unless ran
|
24
26
|
end
|
25
27
|
end
|
26
28
|
end
|
@@ -123,6 +125,10 @@ module Backburner
|
|
123
125
|
stats_hash.keys
|
124
126
|
end
|
125
127
|
|
128
|
+
def tubes
|
129
|
+
tube_names
|
130
|
+
end
|
131
|
+
|
126
132
|
def peek_buried(tube_name = 'default')
|
127
133
|
job = nil
|
128
134
|
job = @client.peek_get(tube_name, buried: true)
|
@@ -208,7 +214,7 @@ module Backburner
|
|
208
214
|
priority: adjusted_priority,
|
209
215
|
timeout: timeout,
|
210
216
|
run_on_timeout: run_on_timeout,
|
211
|
-
shard_key: options[:shard_key]
|
217
|
+
shard_key: options[:shard_key],
|
212
218
|
limit: limit)
|
213
219
|
new_parent_job
|
214
220
|
end
|
@@ -250,6 +256,11 @@ module Backburner
|
|
250
256
|
result
|
251
257
|
end
|
252
258
|
|
259
|
+
def stats(tube)
|
260
|
+
final_stats = stats
|
261
|
+
final_stats[tube]
|
262
|
+
end
|
263
|
+
|
253
264
|
def stats
|
254
265
|
raw_stats = @admin.stats_get
|
255
266
|
final_stats = {}
|
data/lib/backburner/version.rb
CHANGED
data/lib/backburner/worker.rb
CHANGED
@@ -134,35 +134,39 @@ module Backburner
|
|
134
134
|
return
|
135
135
|
end
|
136
136
|
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
137
|
+
if job
|
138
|
+
begin
|
139
|
+
self.log_job_begin(job.name, job.args)
|
140
|
+
job.process
|
141
|
+
self.log_job_end(job.name)
|
142
|
+
rescue Backburner::Job::JobFormatInvalid => e
|
143
|
+
self.log_error self.exception_message(e)
|
144
|
+
rescue => e # Error occurred processing job
|
145
|
+
self.log_error self.exception_message(e) unless e.is_a?(Backburner::Job::RetryJob)
|
146
|
+
|
147
|
+
unless job
|
148
|
+
self.log_error "Error occurred before we were able to assign a job. Giving up without retrying!"
|
149
|
+
return
|
150
|
+
end
|
151
|
+
|
152
|
+
# NB: There's a slight chance here that the connection to allq has
|
153
|
+
# gone down between the time we reserved / processed the job and here.
|
154
|
+
num_retries = job.releases
|
155
|
+
max_job_retries = resolve_max_job_retries(job.job_class)
|
156
|
+
retry_status = "failed: attempt #{num_retries+1} of #{max_job_retries+1}"
|
157
|
+
retry_delay = resolve_retry_delay(job.job_class)
|
158
|
+
delay = resolve_retry_delay_proc(job.job_class).call(retry_delay, num_retries) rescue retry_delay
|
159
|
+
if num_retries + 1 > max_job_retries
|
160
|
+
job.bury
|
161
|
+
else
|
162
|
+
job.release(delay)
|
163
|
+
end
|
164
|
+
self.log_job_end(job.name, "#{retry_status}, retrying in #{delay}s") if job_started_at
|
165
|
+
|
166
|
+
handle_error(e, job.name, job.args, job)
|
167
|
+
end
|
162
168
|
end
|
163
|
-
|
164
|
-
|
165
|
-
handle_error(e, job.name, job.args, job)
|
169
|
+
job
|
166
170
|
end
|
167
171
|
|
168
172
|
|
@@ -175,7 +179,9 @@ module Backburner
|
|
175
179
|
|
176
180
|
# Reserve a job from the watched queues
|
177
181
|
def reserve_job(conn, reserve_timeout = Backburner.configuration.reserve_timeout)
|
178
|
-
|
182
|
+
job = conn.get(@tube_names.sample)
|
183
|
+
return nil if job.body == nil?
|
184
|
+
Backburner::Job.new(job)
|
179
185
|
end
|
180
186
|
|
181
187
|
# Returns a list of all tubes known within the system
|
@@ -207,7 +207,9 @@ module Backburner
|
|
207
207
|
def run_while_can(conn = connection)
|
208
208
|
while @garbage_after.nil? or @garbage_after > @runs
|
209
209
|
@runs += 1 # FIXME: Likely race condition
|
210
|
-
work_one_job(conn)
|
210
|
+
ran_job = work_one_job(conn)
|
211
|
+
# Wait a second if we didn't find a job
|
212
|
+
sleep(rand() * 3) unless ran_job
|
211
213
|
end
|
212
214
|
end
|
213
215
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: backburner-allq
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Malcolm
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-02-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: allq_rest
|