backburner-allq 1.0.20 → 1.0.25
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -0
- data/deploy.sh +1 -1
- data/lib/backburner.rb +2 -2
- data/lib/backburner/allq_wrapper.rb +3 -2
- data/lib/backburner/job.rb +3 -2
- data/lib/backburner/version.rb +1 -1
- data/lib/backburner/worker.rb +1 -1
- data/lib/backburner/workers/threads_on_fork.rb +1 -6
- 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: 619799b2d9a3617ef54fc3e6512d7c0753848d48cb37ee1c7c6be97e3de919d5
|
4
|
+
data.tar.gz: 968f980395b0f8353aff01edd5babe6cfe0ff69a17c74bed59ba84077b86bedd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bfebc7d71a222d9ddd838852b1b131753178656750f520f3efd66cc5a248ecc460558e5960c443ac02a8ba5ee2541bac1e354a3704eabe6c52a56b490b498f12
|
7
|
+
data.tar.gz: 8fe4f7da71322bb541b953dc5616b95623334f8cb3835321d6b2a5b660463fa740f018795dd84a23db80feefad359453e3092755d70145607c91c021b2e344f3
|
data/Gemfile
CHANGED
data/deploy.sh
CHANGED
data/lib/backburner.rb
CHANGED
@@ -25,8 +25,8 @@ module Backburner
|
|
25
25
|
# @example
|
26
26
|
# Backburner.enqueue NewsletterSender, self.id, user.id
|
27
27
|
#
|
28
|
-
def enqueue(job_class, *args)
|
29
|
-
Backburner::Worker.enqueue(job_class, args, {})
|
28
|
+
def enqueue(job_class, *args, shard_key: nil)
|
29
|
+
Backburner::Worker.enqueue(job_class, args, { shard_key: shard_key.nil? ? "X" : shard_key.to_s })
|
30
30
|
end
|
31
31
|
|
32
32
|
# Begins working on jobs enqueued with optional tubes specified
|
@@ -81,6 +81,7 @@ module Backburner
|
|
81
81
|
end
|
82
82
|
|
83
83
|
class AllQWrapper
|
84
|
+
DEFAULT_TIMEOUT = 17800
|
84
85
|
def initialize(url = 'localhost:8090')
|
85
86
|
allq_conf = Allq::Configuration.new do |config|
|
86
87
|
config.host = url
|
@@ -182,7 +183,7 @@ module Backburner
|
|
182
183
|
def build_new_job(body, options)
|
183
184
|
adjusted_priority = map_priority(options[:pri] || 5)
|
184
185
|
|
185
|
-
ttl = options[:ttl] ||
|
186
|
+
ttl = options[:ttl] || options[:ttr] || DEFAULT_TIMEOUT
|
186
187
|
tube_name = options[:tube_name] || 'default'
|
187
188
|
delay = options[:delay] || 0
|
188
189
|
parent_id = options[:parent_id]
|
@@ -199,7 +200,7 @@ module Backburner
|
|
199
200
|
|
200
201
|
def build_new_parent_job(body, options)
|
201
202
|
adjusted_priority = map_priority(options[:pri] || 5)
|
202
|
-
ttl = options[:ttl] ||
|
203
|
+
ttl = options[:ttl] || options[:ttr] || DEFAULT_TIMEOUT
|
203
204
|
tube_name = options[:tube_name] || 'default'
|
204
205
|
delay = options[:delay] || 0
|
205
206
|
parent_id = options[:parent_id]
|
data/lib/backburner/job.rb
CHANGED
@@ -25,6 +25,7 @@ module Backburner
|
|
25
25
|
@body = task.body.is_a?(Hash) ? task.body : Backburner.configuration.job_parser_proc.call(task.body)
|
26
26
|
@name = body["class"] || body[:class]
|
27
27
|
@args = body["args"] || body[:args]
|
28
|
+
@ttr = body["ttr"] || body[:ttr]
|
28
29
|
rescue => ex # Job was not valid format
|
29
30
|
# self.bury
|
30
31
|
# raise JobFormatInvalid, "Job body could not be parsed: #{ex.inspect}"
|
@@ -42,13 +43,13 @@ module Backburner
|
|
42
43
|
# @example
|
43
44
|
# @task.process
|
44
45
|
#
|
45
|
-
def process
|
46
|
+
def process
|
46
47
|
# Invoke before hook and stop if false
|
47
48
|
res = @hooks.invoke_hook_events(job_name, :before_perform, *args)
|
48
49
|
return false unless res
|
49
50
|
# Execute the job
|
50
51
|
@hooks.around_hook_events(job_name, :around_perform, *args) do
|
51
|
-
job_class.perform(*args)
|
52
|
+
timeout_job_after(@ttr > 1 ? @ttr - 1 : @ttr) { job_class.perform(*args) }
|
52
53
|
end
|
53
54
|
task.delete
|
54
55
|
# Invoke after perform hook
|
data/lib/backburner/version.rb
CHANGED
data/lib/backburner/worker.rb
CHANGED
@@ -31,7 +31,7 @@ module Backburner
|
|
31
31
|
|
32
32
|
return nil unless res # stop if hook is false
|
33
33
|
|
34
|
-
data = { :class => job_class.name, :args => args }
|
34
|
+
data = { :class => job_class.name, :args => args, :ttr => ttr }
|
35
35
|
queue = opts[:queue] && (Proc === opts[:queue] ? opts[:queue].call(job_class) : opts[:queue])
|
36
36
|
|
37
37
|
begin
|
@@ -210,12 +210,7 @@ module Backburner
|
|
210
210
|
puts "Run while can"
|
211
211
|
while @garbage_after.nil? or @garbage_after > @runs
|
212
212
|
@runs += 1 # FIXME: Likely race condition
|
213
|
-
|
214
|
-
# Wait a second if we didn't find a job
|
215
|
-
unless ran_job
|
216
|
-
puts "sleeping"
|
217
|
-
sleep(rand() * 3)
|
218
|
-
end
|
213
|
+
work_one_job(conn, @watched_tube_name)
|
219
214
|
end
|
220
215
|
end
|
221
216
|
|
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.25
|
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-05-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: allq_rest
|