backburner-allq 1.0.33 → 1.0.36

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: 2c76bc8dcbc755e47c9f56134e031f01c0541fc96ad2fb68a88085d01b44bb79
4
- data.tar.gz: e48bdeaa45c5197540cacfdc330f82bdfcf402ebec20fb449da3123a188bc598
3
+ metadata.gz: 6ac9dbeeb771c9821488a74064bc6bbe1e059cb9e4dc7faf4f25caf08054b4e6
4
+ data.tar.gz: 298634152be89db02b2b2898b57c9d2fbd9b27354c7b49068af6aadd5613dbe5
5
5
  SHA512:
6
- metadata.gz: 929788a91d4f3502530ab7b2a13bec4179694de107539d887258155c2df37dfa5a6ad4e91817ecd1931bafe122a27094f54d6bdf86949890a43216be72fe59c4
7
- data.tar.gz: 12f64be49c3ee12e93bc081688be13229ea8c5f21e67e7832e36836bd7b8de21fdf10d15410e821a0310e3ec8f54115489ae77ae1d48d25ccf6f93731c08011b
6
+ metadata.gz: 34ee7a51b82f0362485e2346939f70d2bcb3db8412b72ccc237ebf63564b9bd9e9e26613e75fc0c2bdf3f9965ca0b96707db1130f35edfd93e475b7825bf7b9b
7
+ data.tar.gz: 27df1992ff07455872730e2d7d65638b4b63ee1670d4cddfe940de8f17ee27df002db0fba0b0086ea0da6bafedfdbfaea11f6c4acbc7671b9d95a9999600a057
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.33.gem
3
+ gem push backburner-allq-1.0.36.gem
@@ -219,9 +219,6 @@ module Backburner
219
219
 
220
220
  begin
221
221
  Timeout.timeout(10) do
222
- if body && body.to_s.include?('["default"]')
223
- end
224
-
225
222
  if is_parent
226
223
  new_job = build_new_parent_job(body, options)
227
224
  result = @client.parent_job_post(new_job)
@@ -232,18 +229,18 @@ module Backburner
232
229
  raise 'PUT returned nil' if result.nil? || result.to_s == ''
233
230
  end
234
231
  rescue Timeout::Error
235
- puts('ALLQ_PUT_TIMEOUT')
232
+ puts('ALLQ PUT timeout, retrying...')
236
233
  sleep(5)
237
234
  retry_count += 1
238
235
  retry if retry_count < 4
239
- raise 'Failed to put on allq, we are investigating the problem, please try again'
236
+ raise "Failed to put on allq, we are investigating the problem, please try again -> #{body}"
240
237
  rescue StandardError => e
241
- puts('Failed to ALLQ PUT')
238
+ puts('Failed to ALLQ PUT, retrying...')
242
239
  puts(e)
243
240
  retry_count += 1
244
241
  sleep(5)
245
242
  retry if retry_count < 4
246
- raise 'Failed to put on allq, we are investigating the problem, please try again'
243
+ raise "Failed to put on allq, we are investigating the problem, please try again: #{body}"
247
244
  end
248
245
  result
249
246
  end
@@ -1,3 +1,3 @@
1
1
  module Backburner
2
- VERSION = "1.0.33"
2
+ VERSION = "1.0.36"
3
3
  end
@@ -23,7 +23,13 @@ module Backburner
23
23
  # @example
24
24
  # Backburner::Worker.enqueue NewsletterSender, [self.id, user.id], :ttr => 1000
25
25
  #
26
- def self.enqueue(job_class, args=[], opts={})
26
+ def self.enqueue(job_class, args = [], opts = {})
27
+ # Invoke Procs if they are sent
28
+ opts.each_key do |k|
29
+ opts[k] = opts[k].call job_class, args if opts[k].instance_of?(Proc)
30
+ end
31
+
32
+ opts[:shard_key] = opts[:shard_key].nil? ? 'X' : opts[:shard_key].to_s
27
33
  pri = resolve_priority(opts[:pri] || job_class)
28
34
  delay = [0, opts[:delay].to_i].max
29
35
  ttr = resolve_respond_timeout(opts[:ttr] || job_class)
@@ -76,7 +82,7 @@ module Backburner
76
82
  #
77
83
  # @example
78
84
  # Worker.new(['test.job'])
79
- def initialize(tube_names=nil)
85
+ def initialize(tube_names = nil)
80
86
  @connection = new_connection
81
87
  @tube_names = self.process_tube_names(tube_names)
82
88
  register_signal_handlers!
@@ -221,7 +221,7 @@ module Backburner
221
221
  end
222
222
 
223
223
  def on_reconnect(conn)
224
- watch_tube(@watching_tube, conn) if @watching_tube
224
+ watch_tube(@watched_tube_name, conn) if @watched_tube_name
225
225
  end
226
226
 
227
227
  # Exit with Kernel.exit! to avoid at_exit callbacks that should belongs to
data/lib/backburner.rb CHANGED
@@ -10,8 +10,8 @@ require 'backburner/logger'
10
10
  require 'backburner/connection'
11
11
  require 'backburner/hooks'
12
12
  require 'backburner/performable'
13
- require 'backburner/worker'
14
- require 'backburner/workers/simple'
13
+ require_relative 'backburner/worker'
14
+ require_relative 'backburner/workers/simple'
15
15
  require 'backburner/workers/forking'
16
16
  require 'backburner/workers/threads_on_fork'
17
17
  require 'backburner/workers/threading'
@@ -29,15 +29,15 @@ describe "Backburner::Performable module" do
29
29
 
30
30
  describe "for async instance method" do
31
31
  it "should invoke worker enqueue" do
32
- Backburner::Worker.expects(:enqueue).with(PerformableTestObj, [56, :foo, true, false], has_entries(:pri => 5000, :queue => "foo"))
33
- PerformableTestObj.new.async(:pri => 5000, :queue => "foo").foo(true, false)
32
+ Backburner::Worker.expects(:enqueue).with(PerformableTestObj, [56, :foo, true, false], has_entries(:pri => 5000, :queue => "foo", :shard_key => "abc"))
33
+ PerformableTestObj.new.async(:pri => 5000, :queue => "foo", :shard_key => "abc").foo(true, false)
34
34
  end
35
35
  end # async instance
36
36
 
37
37
  describe "for async class method" do
38
38
  it "should invoke worker enqueue" do
39
- Backburner::Worker.expects(:enqueue).with(PerformableTestObj, [nil, :bar, true, false], has_entries(:pri => 5000, :queue => "foo"))
40
- PerformableTestObj.async(:pri => 5000, :queue => "foo").bar(true, false)
39
+ Backburner::Worker.expects(:enqueue).with(PerformableTestObj, [nil, :bar, true, false], has_entries(:pri => 5000, :queue => "foo", :shard_key => "abc"))
40
+ PerformableTestObj.async(:pri => 5000, :queue => "foo", :shard_key => "abc").bar(true, false)
41
41
  end
42
42
  end # async class
43
43
 
@@ -53,16 +53,16 @@ describe "Backburner::Performable module" do
53
53
 
54
54
  describe "for handle_asynchronously class method" do
55
55
  it "should automagically asynchronously proxy calls to the method" do
56
- Backburner::Performable.handle_asynchronously(AutomagicTestObj, :qux, :pri => 5000, :queue => "qux")
56
+ Backburner::Performable.handle_asynchronously(AutomagicTestObj, :qux, :pri => 5000, :queue => "qux", :shard_key => "abc")
57
57
 
58
- Backburner::Worker.expects(:enqueue).with(AutomagicTestObj, [56, :qux_without_async, true, false], has_entries(:pri => 5000, :queue => "qux"))
58
+ Backburner::Worker.expects(:enqueue).with(AutomagicTestObj, [56, :qux_without_async, true, false], has_entries(:pri => 5000, :queue => "qux", :shard_key => "abc"))
59
59
  AutomagicTestObj.new.qux(true, false)
60
60
  end
61
61
 
62
62
  it "should work for class methods, too" do
63
- Backburner::Performable.handle_static_asynchronously(AutomagicTestObj, :garply, :pri => 5000, :queue => "garply")
63
+ Backburner::Performable.handle_static_asynchronously(AutomagicTestObj, :garply, :pri => 5000, :queue => "garply", :shard_key => "abc")
64
64
 
65
- Backburner::Worker.expects(:enqueue).with(AutomagicTestObj, [nil, :garply_without_async, true, false], has_entries(:pri => 5000, :queue => "garply"))
65
+ Backburner::Worker.expects(:enqueue).with(AutomagicTestObj, [nil, :garply_without_async, true, false], has_entries(:pri => 5000, :queue => "garply", :shard_key => "abc"))
66
66
  AutomagicTestObj.garply(true, false)
67
67
  end
68
68
 
@@ -74,14 +74,14 @@ describe "Backburner::Performable module" do
74
74
  end
75
75
 
76
76
  it "should be available for instance methods on any class that includes the Performable module" do
77
- AsyncInstanceMethodsTestObj.handle_asynchronously :foo, pri: 5000, queue: 'qux'
78
- Backburner::Worker.expects(:enqueue).with(AsyncInstanceMethodsTestObj, [56, :foo_without_async, true, false], has_entries(:pri => 5000, :queue => "qux"))
77
+ AsyncInstanceMethodsTestObj.handle_asynchronously :foo, pri: 5000, queue: 'qux', shard_key: "abc"
78
+ Backburner::Worker.expects(:enqueue).with(AsyncInstanceMethodsTestObj, [56, :foo_without_async, true, false], has_entries(:pri => 5000, :queue => "qux", :shard_key => "abc"))
79
79
  AsyncInstanceMethodsTestObj.new.foo(true, false)
80
80
  end
81
81
 
82
82
  it "should be available for class methods on any class that includes the Performable module" do
83
- AsyncStaticMethodsTestObj.handle_static_asynchronously :bar, pri: 5000, queue: 'garply'
84
- Backburner::Worker.expects(:enqueue).with(AsyncStaticMethodsTestObj, [nil, :bar_without_async, true, false], has_entries(:pri => 5000, :queue => "garply"))
83
+ AsyncStaticMethodsTestObj.handle_static_asynchronously :bar, pri: 5000, queue: 'garply', shard_key: "abc"
84
+ Backburner::Worker.expects(:enqueue).with(AsyncStaticMethodsTestObj, [nil, :bar_without_async, true, false], has_entries(:pri => 5000, :queue => "garply",:shard_key => "abc"))
85
85
  AsyncStaticMethodsTestObj.bar(true, false)
86
86
  end
87
87
  end
data/test/test_helper.rb CHANGED
@@ -12,7 +12,7 @@ require File.expand_path('../helpers/templogger', __FILE__)
12
12
 
13
13
  # Configure Backburner
14
14
  Backburner.configure do |config|
15
- config.beanstalk_url = "beanstalk://127.0.0.1"
15
+ config.allq_url = "allq://127.0.0.1:8091"
16
16
  config.tube_namespace = "demo.test"
17
17
  end
18
18
 
@@ -88,7 +88,7 @@ class MiniTest::Spec
88
88
  end
89
89
 
90
90
  def beanstalk_connection
91
- Backburner::Connection.new(Backburner.configuration.beanstalk_url)
91
+ Backburner::Connection.new(Backburner.configuration.allq_url)
92
92
  end
93
93
 
94
94
  # pop_one_job(tube_name)
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.33
4
+ version: 1.0.36
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-09-14 00:00:00.000000000 Z
11
+ date: 2022-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: allq_rest