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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ed4aae689c12e639f2f51a32aef5a59c80f0ab452f89fe2f29afb566474ba201
4
- data.tar.gz: 62e79b474949889a1b992b7fa25a034a1c87a62d1d6db0ba5f8a01582e464071
3
+ metadata.gz: 619799b2d9a3617ef54fc3e6512d7c0753848d48cb37ee1c7c6be97e3de919d5
4
+ data.tar.gz: 968f980395b0f8353aff01edd5babe6cfe0ff69a17c74bed59ba84077b86bedd
5
5
  SHA512:
6
- metadata.gz: 8f5e2bd1006d8d39e95f25b85b195ad7b8cefd5b77a16dd93ab095ef0ca080d90e04b63490e66d9247b47e9f97d2355e5b2fa9fe03b2c85dd413efa54d642a32
7
- data.tar.gz: 26a7b05894906fc6d79f0e98b6bed0f67d5ea8c62b09c3b6b89acb89fb13811dc568353ce7432d89081ed79ff97f4f2da5c91ee5e20ba2131cddf10a875da7c0
6
+ metadata.gz: bfebc7d71a222d9ddd838852b1b131753178656750f520f3efd66cc5a248ecc460558e5960c443ac02a8ba5ee2541bac1e354a3704eabe6c52a56b490b498f12
7
+ data.tar.gz: 8fe4f7da71322bb541b953dc5616b95623334f8cb3835321d6b2a5b660463fa740f018795dd84a23db80feefad359453e3092755d70145607c91c021b2e344f3
data/Gemfile CHANGED
@@ -2,3 +2,5 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in backburner.gemspec
4
4
  gemspec
5
+
6
+
data/deploy.sh CHANGED
@@ -1,3 +1,3 @@
1
1
  echo "Did you update the version?"
2
2
  gem build backburner-allq.gemspec
3
- gem push backburner-allq-1.0.20.gem
3
+ gem push backburner-allq-1.0.25.gem
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] || 600
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] || 600
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]
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Backburner
2
- VERSION = "1.0.20"
2
+ VERSION = "1.0.25"
3
3
  end
@@ -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
- ran_job = work_one_job(conn, @watched_tube_name)
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.20
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-02-13 00:00:00.000000000 Z
11
+ date: 2021-05-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: allq_rest