backburner 0.4.6 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b2b489b60308b955b398ce8a9936c0bfca96588e
4
- data.tar.gz: 6a22f67c5502cd730139c4a857d4417552419c57
3
+ metadata.gz: 89f6987a5f81f904f8e2dd8d48bad8deea664a7e
4
+ data.tar.gz: d0a1cdf8c5cd0087f60d4c29da334f40ebc00a3f
5
5
  SHA512:
6
- metadata.gz: c751606af667cdeadbfd9d270d5aae80ccc42a9f9f968607f4a02d783207b3db4171ab9cc207e44b38a435024a68b6e6bfcb319973788940f819f6d05b49843a
7
- data.tar.gz: 5bacb2a1f9c613addac6a7ad3e4c45d9358fdd523092faf50f696fbbb3aede4d0676bddd875caa4fca84d36995bf9bfbd3aafe43fc33fda6e9458539dd6d3421
6
+ metadata.gz: 19fc5c5d7086baf5ca15cc8cf93d0a429cd858ac30fbdfe86719322bd8704edacfb008d3568eae6f5c6c1a029e7831a0ef6052345cb934d7fea45cca90e60103
7
+ data.tar.gz: 3da11501d42cecb97fae3428cdf9d3f9e7403f0eab8801e581ff90685a79646a12f4ee7d95811efd5b4339995f97ff96bca7d13fe8ca8372b99b52047d28a2b2
data/.DS_Store ADDED
Binary file
data/.travis.yml CHANGED
@@ -2,7 +2,7 @@
2
2
  rvm:
3
3
  - 1.9.3
4
4
  - 2.0.0
5
- - rbx-19mode
5
+ - rbx-2
6
6
  before_install:
7
7
  - curl -L https://github.com/kr/beanstalkd/archive/v1.9.tar.gz | tar xz -C /tmp
8
8
  - cd /tmp/beanstalkd-1.9/
@@ -11,11 +11,11 @@ before_install:
11
11
  - cd $TRAVIS_BUILD_DIR
12
12
  matrix:
13
13
  allow_failures:
14
- - rvm: rbx-19mode
14
+ - rvm: rbx-2
15
15
  script:
16
16
  - bundle install
17
17
  - bundle exec rake test
18
18
  gemfile: Gemfile
19
19
  notifications:
20
20
  recipients:
21
- - nesquena@gmail.com
21
+ - nesquena@gmail.com
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## Version 1.0.0 (April 26 2015)
4
+
5
+ * NEW Updating to Beaneater 1.0 (@alup)
6
+
3
7
  ## Version 0.4.6 (October 26 2014)
4
8
 
5
9
  * NEW Add job to on_error handler if the handler has a 4th argument (@Nitrodist)
data/README.md CHANGED
@@ -229,7 +229,7 @@ Backburner.work
229
229
  This will process jobs in all queues but you can also restrict processing to specific queues:
230
230
 
231
231
  ```ruby
232
- Backburner.work('newsletter-sender,push-notifier')
232
+ Backburner.work('newsletter-sender', 'push-notifier')
233
233
  ```
234
234
 
235
235
  The Backburner worker also exists as a rake task:
@@ -241,7 +241,7 @@ require 'backburner/tasks'
241
241
  so you can run:
242
242
 
243
243
  ```
244
- $ QUEUES=newsletter-sender,push-notifier rake backburner:work
244
+ $ QUEUE=newsletter-sender,push-notifier rake backburner:work
245
245
  ```
246
246
 
247
247
  You can also run the backburner binary for a convenient worker:
@@ -362,7 +362,7 @@ Backburner.work('newsletter-sender', :worker => Backburner::Workers::ThreadsOnFo
362
362
  or through associated rake tasks with:
363
363
 
364
364
  ```
365
- $ QUEUES=newsletter-sender,push-message THREADS=2 GARBAGE=1000 rake backburner:threads_on_fork:work
365
+ $ QUEUE=newsletter-sender,push-message THREADS=2 GARBAGE=1000 rake backburner:threads_on_fork:work
366
366
  ```
367
367
 
368
368
  For more information on the threads_on_fork worker, check out the
@@ -461,7 +461,7 @@ and then you can start the rake task with:
461
461
 
462
462
  ```bash
463
463
  $ rake backburner:work
464
- $ QUEUES=newsletter-sender,push-notifier rake backburner:work
464
+ $ QUEUE=newsletter-sender,push-notifier rake backburner:work
465
465
  ```
466
466
 
467
467
  The best way to deploy these rake tasks is using a monitoring library. We suggest [God](https://github.com/mojombo/god/)
data/backburner.gemspec CHANGED
@@ -16,8 +16,8 @@ Gem::Specification.new do |s|
16
16
  s.version = Backburner::VERSION
17
17
  s.license = 'MIT'
18
18
 
19
- s.add_runtime_dependency 'beaneater', '~> 0.3.1'
20
- s.add_runtime_dependency 'dante', '~> 0.1.5'
19
+ s.add_runtime_dependency 'beaneater', '~> 1.0'
20
+ s.add_runtime_dependency 'dante', '> 0.1.5'
21
21
 
22
22
  s.add_development_dependency 'rake'
23
23
  s.add_development_dependency 'minitest', '3.2.0'
data/examples/god.rb CHANGED
@@ -4,7 +4,7 @@ God.watch do |w|
4
4
  w.env = { 'PADRINO_ENV' => 'production', 'QUEUES' => 'newsletter-sender,push-message' }
5
5
  w.group = 'backburner-workers'
6
6
  w.interval = 30.seconds
7
- w.start = "bundle exec rake -f Rakefile backburner:start"
7
+ w.start = "bundle exec rake -f Rakefile backburner:work"
8
8
  w.log = "/var/log/god/backburner-worker-1.log"
9
9
 
10
10
  # restart if memory gets too high
@@ -43,4 +43,4 @@ God.watch do |w|
43
43
  c.running = false
44
44
  end
45
45
  end
46
- end
46
+ end
@@ -10,6 +10,7 @@ module Backburner
10
10
  # `url` can be a string i.e 'localhost:3001' or an array of addresses.
11
11
  def initialize(url)
12
12
  @url = url
13
+ @beanstalk = nil
13
14
  connect!
14
15
  end
15
16
 
@@ -24,7 +25,7 @@ module Backburner
24
25
 
25
26
  # Connects to a beanstalk queue
26
27
  def connect!
27
- @beanstalk ||= Beaneater::Pool.new(beanstalk_addresses)
28
+ @beanstalk ||= Beaneater.new(beanstalk_addresses)
28
29
  end
29
30
 
30
31
  # Returns the beanstalk queue addresses
@@ -33,8 +34,8 @@ module Backburner
33
34
  # beanstalk_addresses => ["localhost:11300"]
34
35
  #
35
36
  def beanstalk_addresses
36
- uris = self.url.is_a?(Array) ? self.url : self.url.split(/[\s,]+/)
37
- uris.map { |uri| beanstalk_host_and_port(uri) }
37
+ uri = self.url.is_a?(Array) ? self.url.first : self.url
38
+ beanstalk_host_and_port(uri)
38
39
  end
39
40
 
40
41
  # Returns a host and port based on the uri_string given
@@ -48,4 +49,4 @@ module Backburner
48
49
  "#{uri.host}:#{uri.port || 11300}"
49
50
  end
50
51
  end # Connection
51
- end # Backburner
52
+ end # Backburner
@@ -1,6 +1,12 @@
1
1
  module Backburner
2
2
  module Queue
3
3
  def self.included(base)
4
+ base.instance_variable_set(:@queue_name, nil)
5
+ base.instance_variable_set(:@queue_priority, nil)
6
+ base.instance_variable_set(:@queue_respond_timeout, nil)
7
+ base.instance_variable_set(:@queue_jobs_limit, nil)
8
+ base.instance_variable_set(:@queue_garbage_limit, nil)
9
+ base.instance_variable_set(:@queue_retry_limit, nil)
4
10
  base.extend ClassMethods
5
11
  Backburner::Worker.known_queue_classes << base
6
12
  end
@@ -1,3 +1,3 @@
1
1
  module Backburner
2
- VERSION = "0.4.6"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -53,7 +53,7 @@ module Backburner
53
53
 
54
54
  # Returns the worker connection.
55
55
  # @example
56
- # Backburner::Worker.connection # => <Beaneater::Pool>
56
+ # Backburner::Worker.connection # => <Beaneater::Connection>
57
57
  def self.connection
58
58
  @connection ||= Connection.new(Backburner.configuration.beanstalk_url)
59
59
  end
@@ -159,7 +159,7 @@ module Backburner
159
159
  def self.retryable_command(max_tries=8, &block)
160
160
  begin
161
161
  yield
162
- rescue Beaneater::NotConnected => e
162
+ rescue Beaneater::NotConnected
163
163
  retry_connection!(max_tries)
164
164
  yield
165
165
  end
@@ -9,7 +9,7 @@ module Backburner
9
9
  # @worker.prepare
10
10
  #
11
11
  def prepare
12
- self.tube_names.map! { |name| expand_tube_name(name) }
12
+ self.tube_names.map! { |name| expand_tube_name(name) }.uniq!
13
13
  log_info "Working #{tube_names.size} queues: [ #{tube_names.join(', ')} ]"
14
14
  self.connection.tubes.watch!(*self.tube_names)
15
15
  end
@@ -9,7 +9,7 @@ module Backburner
9
9
  # @worker.prepare
10
10
  #
11
11
  def prepare
12
- self.tube_names.map! { |name| expand_tube_name(name) }
12
+ self.tube_names.map! { |name| expand_tube_name(name) }.uniq!
13
13
  log_info "Working #{tube_names.size} queues: [ #{tube_names.join(', ')} ]"
14
14
  self.connection.tubes.watch!(*self.tube_names)
15
15
  end
@@ -1,7 +1,6 @@
1
1
  module Backburner
2
2
  module Workers
3
3
  class ThreadsOnFork < Worker
4
-
5
4
  class << self
6
5
  attr_accessor :shutdown
7
6
  attr_accessor :threads_number
@@ -18,7 +17,7 @@ module Backburner
18
17
  begin
19
18
  Process.kill(0, id)
20
19
  tmp_ids << id
21
- rescue Errno::ESRCH => e
20
+ rescue Errno::ESRCH
22
21
  end
23
22
  end
24
23
  @child_pids = tmp_ids if @child_pids != tmp_ids
@@ -69,6 +68,7 @@ module Backburner
69
68
  # Custom initializer just to set @tubes_data
70
69
  def initialize(*args)
71
70
  @tubes_data = {}
71
+ @connection = nil
72
72
  super
73
73
  self.process_tube_options
74
74
  end
@@ -122,7 +122,7 @@ module Backburner
122
122
  def prepare
123
123
  self.tube_names ||= Backburner.default_queues.any? ? Backburner.default_queues : all_existing_queues
124
124
  self.tube_names = Array(self.tube_names)
125
- tube_names.map! { |name| expand_tube_name(name) }
125
+ tube_names.map! { |name| expand_tube_name(name) }.uniq!
126
126
  tube_display_names = tube_names.map{|name| "#{name}:#{@tubes_data[name].values}"}
127
127
  log_info "Working #{tube_names.size} queues: [ #{tube_display_names.join(', ')} ]"
128
128
  end
@@ -253,7 +253,6 @@ module Backburner
253
253
  def connection
254
254
  @connection || super
255
255
  end
256
-
257
256
  end
258
257
  end
259
258
  end
@@ -11,23 +11,15 @@ describe "Backburner::Connection class" do
11
11
  end
12
12
 
13
13
  it "should setup beanstalk connection" do
14
- assert_kind_of Beaneater::Pool, @connection.beanstalk
14
+ assert_kind_of Beaneater, @connection.beanstalk
15
15
  end
16
16
  end # initialize single connection
17
17
 
18
- describe "for initialize with multiple urls" do
19
- it "should support single string with commas" do
20
- @connection = Backburner::Connection.new("beanstalk://localhost,beanstalk://localhost")
21
- connections = @connection.beanstalk.connections
22
- assert_equal 2, connections.size
23
- assert_equal ['localhost:11300','localhost:11300'], connections.map(&:address)
24
- end
25
-
26
- it "should support array of connections" do
27
- @connection = Backburner::Connection.new(['beanstalk://127.0.0.1:11300','beanstalk://localhost'])
28
- connections = @connection.beanstalk.connections
29
- assert_equal 2, @connection.beanstalk.connections.size
30
- assert_equal ['127.0.0.1:11300','localhost:11300'], connections.map(&:address)
18
+ describe "for initialize with url" do
19
+ it "should delegate the address url correctly" do
20
+ @connection = Backburner::Connection.new("beanstalk://localhost")
21
+ connection = @connection.beanstalk.connection
22
+ assert_equal 'localhost:11300', connection.address
31
23
  end
32
24
  end # initialize
33
25
 
@@ -45,7 +37,7 @@ describe "Backburner::Connection class" do
45
37
  end
46
38
 
47
39
  it "delegate methods to beanstalk connection" do
48
- assert_equal "localhost", @connection.connections.first.host
40
+ assert_equal "localhost", @connection.connection.host
49
41
  end
50
42
  end # delegator
51
43
  end # Connection
data/test/helpers_test.rb CHANGED
@@ -40,7 +40,7 @@ describe "Backburner::Helpers module" do
40
40
  describe "for exception_message method" do
41
41
  it "prints out message about failure" do
42
42
  output = exception_message(RuntimeError.new("test"))
43
- assert_match /Exception RuntimeError/, output
43
+ assert_match(/Exception RuntimeError/, output)
44
44
  end
45
45
  end # exception_message
46
46
 
@@ -161,4 +161,4 @@ describe "Backburner::Helpers module" do
161
161
  assert_equal 300, resolve_respond_timeout(nil)
162
162
  end
163
163
  end # resolve_respond_timeout
164
- end
164
+ end
data/test/hooks_test.rb CHANGED
@@ -12,22 +12,22 @@ describe "Backburner::Hooks module" do
12
12
  it "should support successful invocation" do
13
13
  out = silenced { @res = @hooks.invoke_hook_events(HookedObjectSuccess, :before_enqueue, 5, 6) }
14
14
  assert_equal [nil, nil], @res
15
- assert_match /!!before_enqueue_foo!! \[5\, 6\]/, out
16
- assert_match /!!before_enqueue_bar!! \[5\, 6\]/, out
15
+ assert_match(/!!before_enqueue_foo!! \[5\, 6\]/, out)
16
+ assert_match(/!!before_enqueue_bar!! \[5\, 6\]/, out)
17
17
  end
18
18
 
19
19
  it "should support fail case" do
20
20
  out = silenced { @res = @hooks.invoke_hook_events(HookedObjectBeforeEnqueueFail, :before_enqueue, 5, 6) }
21
21
  assert_equal false, @res
22
- assert_match /!!before_enqueue_foo!! \[5\, 6\]/, out
22
+ assert_match(/!!before_enqueue_foo!! \[5\, 6\]/, out)
23
23
  end
24
24
  end # before_enqueue
25
25
 
26
26
  describe "with after_enqueue" do
27
27
  it "should support successful invocation" do
28
28
  out = silenced { @hooks.invoke_hook_events(HookedObjectSuccess, :after_enqueue, 7, 8) }
29
- assert_match /!!after_enqueue_foo!! \[7\, 8\]/, out
30
- assert_match /!!after_enqueue_bar!! \[7\, 8\]/, out
29
+ assert_match(/!!after_enqueue_foo!! \[7\, 8\]/, out)
30
+ assert_match(/!!after_enqueue_bar!! \[7\, 8\]/, out)
31
31
  end
32
32
 
33
33
  it "should support fail case" do
@@ -40,20 +40,20 @@ describe "Backburner::Hooks module" do
40
40
  describe "with before_perform" do
41
41
  it "should support successful invocation" do
42
42
  out = silenced { @hooks.invoke_hook_events(HookedObjectSuccess, :before_perform, 1, 2) }
43
- assert_match /!!before_perform_foo!! \[1\, 2\]/, out
43
+ assert_match(/!!before_perform_foo!! \[1\, 2\]/, out)
44
44
  end
45
45
 
46
46
  it "should support fail case" do
47
47
  out = silenced { @res = @hooks.invoke_hook_events(HookedObjectBeforePerformFail, :before_perform, 5, 6) }
48
48
  assert_equal false, @res
49
- assert_match /!!before_perform_foo!! \[5\, 6\]/, out
49
+ assert_match(/!!before_perform_foo!! \[5\, 6\]/, out)
50
50
  end
51
51
  end # before_perform
52
52
 
53
53
  describe "with after_perform" do
54
54
  it "should support successful invocation" do
55
55
  out = silenced { @hooks.invoke_hook_events(HookedObjectSuccess, :after_perform, 3, 4) }
56
- assert_match /!!after_perform_foo!! \[3\, 4\]/, out
56
+ assert_match(/!!after_perform_foo!! \[3\, 4\]/, out)
57
57
  end
58
58
 
59
59
  it "should support fail case" do
@@ -66,7 +66,7 @@ describe "Backburner::Hooks module" do
66
66
  describe "with on_failure" do
67
67
  it "should support successful invocation" do
68
68
  out = silenced { @hooks.invoke_hook_events(HookedObjectSuccess, :on_failure, RuntimeError, 10) }
69
- assert_match /!!on_failure_foo!! RuntimeError \[10\]/, out
69
+ assert_match(/!!on_failure_foo!! RuntimeError \[10\]/, out)
70
70
  end
71
71
  end # on_failure
72
72
  end # invoke_hook_events
@@ -79,13 +79,13 @@ describe "Backburner::Hooks module" do
79
79
  puts "!!FIRED!!"
80
80
  }
81
81
  end
82
- assert_match /BEGIN.*?bar.*BEGIN.*cat.*FIRED.*END.*cat.*END.*bar/m, out
83
- assert_match /!!BEGIN around_perform_bar!! \[7\, 8\]/, out
84
- assert_match /!!BEGIN around_perform_cat!! \[7\, 8\]/, out
85
- assert_match /!!FIRED!!/, out
86
- assert_match /!!END around_perform_cat!! \[7\, 8\]/, out
87
- assert_match /!!END around_perform_bar!! \[7\, 8\]/, out
82
+ assert_match(/BEGIN.*?bar.*BEGIN.*cat.*FIRED.*END.*cat.*END.*bar/m, out)
83
+ assert_match(/!!BEGIN around_perform_bar!! \[7\, 8\]/, out)
84
+ assert_match(/!!BEGIN around_perform_cat!! \[7\, 8\]/, out)
85
+ assert_match(/!!FIRED!!/, out)
86
+ assert_match(/!!END around_perform_cat!! \[7\, 8\]/, out)
87
+ assert_match(/!!END around_perform_bar!! \[7\, 8\]/, out)
88
88
  end
89
89
  end # successful
90
90
  end # around_hook_events
91
- end # Hooks
91
+ end # Hooks
data/test/job_test.rb CHANGED
@@ -68,7 +68,7 @@ describe "Backburner::Job module" do
68
68
  it "should process task" do
69
69
  @job = Backburner::Job.new(@task)
70
70
  out = silenced(1) { @job.process }
71
- assert_match /Performed 56 in NestedDemo::TestJobC/, out
71
+ assert_match(/Performed 56 in NestedDemo::TestJobC/, out)
72
72
  end # process
73
73
  end # valid
74
74
 
@@ -111,4 +111,4 @@ describe "Backburner::Job module" do
111
111
  @job.bury
112
112
  end # bury
113
113
  end # simple delegation
114
- end
114
+ end
data/test/logger_test.rb CHANGED
@@ -17,7 +17,7 @@ describe "Backburner::Logger module" do
17
17
  it "can be configured to log to logger" do
18
18
  Backburner.configure { |config| config.logger = @logger }
19
19
  log_info("foo")
20
- assert_match /I,.*?foo/, @strio.string
20
+ assert_match(/I,.*?foo/, @strio.string)
21
21
  end
22
22
 
23
23
  after do
@@ -34,11 +34,11 @@ describe "Backburner::Logger module" do
34
34
  it "can be configured to log to logger" do
35
35
  Backburner.configure { |config| config.logger = @logger }
36
36
  log_error("bar")
37
- assert_match /E,.*?bar/, @strio.string
37
+ assert_match(/E,.*?bar/, @strio.string)
38
38
  end
39
39
 
40
40
  after do
41
41
  Backburner.configure { |config| config.logger = nil }
42
42
  end
43
43
  end # log_error
44
- end
44
+ end
data/test/test_helper.rb CHANGED
@@ -1,7 +1,11 @@
1
1
  require 'rubygems'
2
2
  require 'tempfile'
3
3
  require 'minitest/autorun'
4
- require 'mocha/setup'
4
+ begin
5
+ require 'mocha/setup'
6
+ rescue LoadError
7
+ require 'mocha'
8
+ end
5
9
  $:.unshift File.expand_path("../../lib")
6
10
  require 'backburner'
7
11
  require File.expand_path('../helpers/templogger', __FILE__)
data/test/worker_test.rb CHANGED
@@ -77,7 +77,7 @@ describe "Backburner::Worker module" do
77
77
  describe "for connection class method" do
78
78
  it "should return the beanstalk connection" do
79
79
  assert_equal "beanstalk://localhost", Backburner::Worker.connection.url
80
- assert_kind_of Beaneater::Pool, Backburner::Worker.connection.beanstalk
80
+ assert_kind_of Beaneater, Backburner::Worker.connection.beanstalk
81
81
  end
82
82
  end # connection
83
83
 
@@ -9,12 +9,18 @@ describe "Backburner::Workers::Forking module" do
9
9
  end
10
10
 
11
11
  describe "for prepare method" do
12
+ it "should make tube names array always unique to avoid duplication" do
13
+ worker = @worker_class.new(["foo", "demo.test.foo"])
14
+ worker.prepare
15
+ assert_equal ["demo.test.foo"], worker.tube_names
16
+ end
17
+
12
18
  it "should watch specified tubes" do
13
19
  worker = @worker_class.new(["foo", "bar"])
14
20
  out = capture_stdout { worker.prepare }
15
21
  assert_equal ["demo.test.foo", "demo.test.bar"], worker.tube_names
16
22
  assert_same_elements ["demo.test.foo", "demo.test.bar"], @worker_class.connection.tubes.watched.map(&:name)
17
- assert_match /demo\.test\.foo/, out
23
+ assert_match(/demo\.test\.foo/, out)
18
24
  end # multiple
19
25
 
20
26
  it "should watch single tube" do
@@ -22,7 +28,7 @@ describe "Backburner::Workers::Forking module" do
22
28
  out = capture_stdout { worker.prepare }
23
29
  assert_equal ["demo.test.foo"], worker.tube_names
24
30
  assert_same_elements ["demo.test.foo"], @worker_class.connection.tubes.watched.map(&:name)
25
- assert_match /demo\.test\.foo/, out
31
+ assert_match(/demo\.test\.foo/, out)
26
32
  end # single
27
33
 
28
34
  it "should respect default_queues settings" do
@@ -31,7 +37,7 @@ describe "Backburner::Workers::Forking module" do
31
37
  out = capture_stdout { worker.prepare }
32
38
  assert_equal ["demo.test.foo", "demo.test.bar"], worker.tube_names
33
39
  assert_same_elements ["demo.test.foo", "demo.test.bar"], @worker_class.connection.tubes.watched.map(&:name)
34
- assert_match /demo\.test\.foo/, out
40
+ assert_match(/demo\.test\.foo/, out)
35
41
  end
36
42
 
37
43
  it "should assign based on all tubes" do
@@ -40,7 +46,7 @@ describe "Backburner::Workers::Forking module" do
40
46
  out = capture_stdout { worker.prepare }
41
47
  assert_equal ["demo.test.bar"], worker.tube_names
42
48
  assert_same_elements ["demo.test.bar"], @worker_class.connection.tubes.watched.map(&:name)
43
- assert_match /demo\.test\.bar/, out
49
+ assert_match(/demo\.test\.bar/, out)
44
50
  end # all assign
45
51
 
46
52
  it "should properly retrieve all tubes" do
@@ -48,7 +54,7 @@ describe "Backburner::Workers::Forking module" do
48
54
  out = capture_stdout { worker.prepare }
49
55
  assert_contains worker.tube_names, "demo.test.backburner-jobs"
50
56
  assert_contains @worker_class.connection.tubes.watched.map(&:name), "demo.test.backburner-jobs"
51
- assert_match /demo\.test\.test-job/, out
57
+ assert_match(/demo\.test\.test-job/, out)
52
58
  end # all read
53
59
  end # prepare
54
60
 
@@ -174,6 +180,4 @@ describe "Backburner::Workers::Forking module" do
174
180
  end # retrying, succeeds
175
181
 
176
182
  end # practical tests
177
-
178
-
179
183
  end
@@ -9,12 +9,18 @@ describe "Backburner::Workers::Basic module" do
9
9
  end
10
10
 
11
11
  describe "for prepare method" do
12
+ it "should make tube names array always unique to avoid duplication" do
13
+ worker = @worker_class.new(["foo", "demo.test.foo"])
14
+ worker.prepare
15
+ assert_equal ["demo.test.foo"], worker.tube_names
16
+ end
17
+
12
18
  it "should watch specified tubes" do
13
19
  worker = @worker_class.new(["foo", "bar"])
14
20
  out = capture_stdout { worker.prepare }
15
21
  assert_equal ["demo.test.foo", "demo.test.bar"], worker.tube_names
16
22
  assert_same_elements ["demo.test.foo", "demo.test.bar"], @worker_class.connection.tubes.watched.map(&:name)
17
- assert_match /demo\.test\.foo/, out
23
+ assert_match(/demo\.test\.foo/, out)
18
24
  end # multiple
19
25
 
20
26
  it "should watch single tube" do
@@ -22,7 +28,7 @@ describe "Backburner::Workers::Basic module" do
22
28
  out = capture_stdout { worker.prepare }
23
29
  assert_equal ["demo.test.foo"], worker.tube_names
24
30
  assert_same_elements ["demo.test.foo"], @worker_class.connection.tubes.watched.map(&:name)
25
- assert_match /demo\.test\.foo/, out
31
+ assert_match(/demo\.test\.foo/, out)
26
32
  end # single
27
33
 
28
34
  it "should respect default_queues settings" do
@@ -31,7 +37,7 @@ describe "Backburner::Workers::Basic module" do
31
37
  out = capture_stdout { worker.prepare }
32
38
  assert_equal ["demo.test.foo", "demo.test.bar"], worker.tube_names
33
39
  assert_same_elements ["demo.test.foo", "demo.test.bar"], @worker_class.connection.tubes.watched.map(&:name)
34
- assert_match /demo\.test\.foo/, out
40
+ assert_match(/demo\.test\.foo/, out)
35
41
  end
36
42
 
37
43
  it "should assign based on all tubes" do
@@ -40,7 +46,7 @@ describe "Backburner::Workers::Basic module" do
40
46
  out = capture_stdout { worker.prepare }
41
47
  assert_equal ["demo.test.bar"], worker.tube_names
42
48
  assert_same_elements ["demo.test.bar"], @worker_class.connection.tubes.watched.map(&:name)
43
- assert_match /demo\.test\.bar/, out
49
+ assert_match(/demo\.test\.bar/, out)
44
50
  end # all assign
45
51
 
46
52
  it "should properly retrieve all tubes" do
@@ -48,7 +54,7 @@ describe "Backburner::Workers::Basic module" do
48
54
  out = capture_stdout { worker.prepare }
49
55
  assert_contains worker.tube_names, "demo.test.backburner-jobs"
50
56
  assert_contains @worker_class.connection.tubes.watched.map(&:name), "demo.test.backburner-jobs"
51
- assert_match /demo\.test\.test-job/, out
57
+ assert_match(/demo\.test\.test-job/, out)
52
58
  end # all read
53
59
  end # prepare
54
60
 
@@ -139,9 +145,9 @@ describe "Backburner::Workers::Basic module" do
139
145
  worker.work_one_job
140
146
  end
141
147
  end
142
- assert_match /attempt 1 of 2, retrying/, out.first
143
- assert_match /Finished TestRetryJob/m, out.last
144
- assert_match /attempt 2 of 2, burying/m, out.last
148
+ assert_match(/attempt 1 of 2, retrying/, out.first)
149
+ assert_match(/Finished TestRetryJob/m, out.last)
150
+ assert_match(/attempt 2 of 2, burying/m, out.last)
145
151
  assert_equal 2, $worker_test_count
146
152
  assert_equal false, $worker_success
147
153
  end # retry, bury
@@ -158,9 +164,9 @@ describe "Backburner::Workers::Basic module" do
158
164
  worker.work_one_job
159
165
  end
160
166
  end
161
- assert_match /attempt 1 of 3, retrying/, out.first
162
- assert_match /attempt 2 of 3, retrying/, out[1]
163
- assert_match /Completed TestRetryJob/m, out.last
167
+ assert_match(/attempt 1 of 3, retrying/, out.first)
168
+ assert_match(/attempt 2 of 3, retrying/, out[1])
169
+ assert_match(/Completed TestRetryJob/m, out.last)
164
170
  refute_match(/failed/, out.last)
165
171
  assert_equal 3, $worker_test_count
166
172
  assert_equal true, $worker_success
@@ -175,14 +181,14 @@ describe "Backburner::Workers::Basic module" do
175
181
  worker.prepare
176
182
  worker.work_one_job
177
183
  end
178
- assert_match /before_enqueue.*after_enqueue.*Working 1 queues/m, out
179
- assert_match /!!before_enqueue_bar!! \[nil, :foo, 5\]/, out
180
- assert_match /!!after_enqueue_bar!! \[nil, :foo, 5\]/, out
181
- assert_match /!!before_perform_foo!! \[nil, "foo", 5\]/, out
182
- assert_match /!!BEGIN around_perform_bar!! \[nil, "foo", 5\]/, out
183
- assert_match /!!BEGIN around_perform_cat!! \[nil, "foo", 5\]/, out
184
- assert_match /!!on_failure_foo!!.*HookFailError/, out
185
- assert_match /attempt 1 of 1, burying/, out
184
+ assert_match(/before_enqueue.*after_enqueue.*Working 1 queues/m, out)
185
+ assert_match(/!!before_enqueue_bar!! \[nil, :foo, 5\]/, out)
186
+ assert_match(/!!after_enqueue_bar!! \[nil, :foo, 5\]/, out)
187
+ assert_match(/!!before_perform_foo!! \[nil, "foo", 5\]/, out)
188
+ assert_match(/!!BEGIN around_perform_bar!! \[nil, "foo", 5\]/, out)
189
+ assert_match(/!!BEGIN around_perform_cat!! \[nil, "foo", 5\]/, out)
190
+ assert_match(/!!on_failure_foo!!.*HookFailError/, out)
191
+ assert_match(/attempt 1 of 1, burying/, out)
186
192
  end # event hooks, no retry
187
193
 
188
194
  it "should support event hooks with retry" do
@@ -197,26 +203,26 @@ describe "Backburner::Workers::Basic module" do
197
203
  worker.work_one_job
198
204
  end
199
205
  end
200
- assert_match /before_enqueue.*after_enqueue.*Working 1 queues/m, out
201
- assert_match /!!before_enqueue_bar!! \[nil, :foo, 5\]/, out
202
- assert_match /!!after_enqueue_bar!! \[nil, :foo, 5\]/, out
203
- assert_match /!!before_perform_foo!! \[nil, "foo", 5\]/, out
204
- assert_match /!!BEGIN around_perform_bar!! \[nil, "foo", 5\]/, out
205
- assert_match /!!BEGIN around_perform_cat!! \[nil, "foo", 5\]/, out
206
- assert_match /!!on_failure_foo!!.*HookFailError/, out
207
- assert_match /!!on_failure_foo!!.*retrying.*around_perform_bar.*around_perform_cat/m, out
208
- assert_match /attempt 1 of 2, retrying/, out
209
- assert_match /!!before_perform_foo!! \[nil, "foo", 5\]/, out
210
- assert_match /!!END around_perform_bar!! \[nil, "foo", 5\]/, out
211
- assert_match /!!END around_perform_cat!! \[nil, "foo", 5\]/, out
212
- assert_match /!!after_perform_foo!! \[nil, "foo", 5\]/, out
213
- assert_match /Finished HookedObjectSuccess/, out
206
+ assert_match(/before_enqueue.*after_enqueue.*Working 1 queues/m, out)
207
+ assert_match(/!!before_enqueue_bar!! \[nil, :foo, 5\]/, out)
208
+ assert_match(/!!after_enqueue_bar!! \[nil, :foo, 5\]/, out)
209
+ assert_match(/!!before_perform_foo!! \[nil, "foo", 5\]/, out)
210
+ assert_match(/!!BEGIN around_perform_bar!! \[nil, "foo", 5\]/, out)
211
+ assert_match(/!!BEGIN around_perform_cat!! \[nil, "foo", 5\]/, out)
212
+ assert_match(/!!on_failure_foo!!.*HookFailError/, out)
213
+ assert_match(/!!on_failure_foo!!.*retrying.*around_perform_bar.*around_perform_cat/m, out)
214
+ assert_match(/attempt 1 of 2, retrying/, out)
215
+ assert_match(/!!before_perform_foo!! \[nil, "foo", 5\]/, out)
216
+ assert_match(/!!END around_perform_bar!! \[nil, "foo", 5\]/, out)
217
+ assert_match(/!!END around_perform_cat!! \[nil, "foo", 5\]/, out)
218
+ assert_match(/!!after_perform_foo!! \[nil, "foo", 5\]/, out)
219
+ assert_match(/Finished HookedObjectSuccess/, out)
214
220
  end # event hooks, with retry
215
221
 
216
222
  it "should support event hooks with stopping enqueue" do
217
223
  $hooked_fail_count = 0
218
224
  clear_jobs!('foo.bar.events.retry2')
219
- out = silenced(2) do
225
+ silenced(2) do
220
226
  HookedObjectBeforeEnqueueFail.async(:queue => 'foo.bar.events.retry2').foo(5)
221
227
  end
222
228
  expanded_tube = [Backburner.configuration.tube_namespace, 'foo.bar.events.retry2'].join(".")
@@ -226,15 +232,15 @@ describe "Backburner::Workers::Basic module" do
226
232
  it "should support event hooks with stopping perform" do
227
233
  $hooked_fail_count = 0
228
234
  clear_jobs!('foo.bar.events.retry3')
229
- expanded_tube = [Backburner.configuration.tube_namespace, 'foo.bar.events.retry3'].join(".")
235
+ [Backburner.configuration.tube_namespace, 'foo.bar.events.retry3'].join(".")
230
236
  out = silenced(2) do
231
237
  HookedObjectBeforePerformFail.async(:queue => 'foo.bar.events.retry3').foo(10)
232
238
  worker = @worker_class.new('foo.bar.events.retry3')
233
239
  worker.prepare
234
240
  worker.work_one_job
235
241
  end
236
- assert_match /!!before_perform_foo!! \[nil, "foo", 10\]/, out
237
- assert_match /before_perform_foo.*Completed/m, out
242
+ assert_match(/!!before_perform_foo!! \[nil, "foo", 10\]/, out)
243
+ assert_match(/before_perform_foo.*Completed/m, out)
238
244
  refute_match(/Fail ran!!/, out)
239
245
  refute_match(/HookFailError/, out)
240
246
  end # stopping perform
@@ -243,4 +249,4 @@ describe "Backburner::Workers::Basic module" do
243
249
  Backburner.configure { |config| config.max_job_retries = 0; config.retry_delay = 5 }
244
250
  end
245
251
  end # work_one_job
246
- end # Worker
252
+ end # Worker
@@ -68,18 +68,24 @@ describe "Backburner::Workers::ThreadsOnFork module" do
68
68
  Backburner.configure { |config| config.logger = false }
69
69
  end
70
70
 
71
+ it "should make tube names array always unique to avoid duplication" do
72
+ worker = @worker_class.new(["foo", "demo.test.foo"])
73
+ worker.prepare
74
+ assert_equal ["demo.test.foo"], worker.tube_names
75
+ end
76
+
71
77
  it "should watch specified tubes" do
72
78
  worker = @worker_class.new(["foo", "bar"])
73
79
  out = capture_stdout { worker.prepare }
74
80
  assert_equal ["demo.test.foo", "demo.test.bar"], worker.tube_names
75
- assert_match /demo\.test\.foo/, out
81
+ assert_match(/demo\.test\.foo/, out)
76
82
  end # multiple
77
83
 
78
84
  it "should watch single tube" do
79
85
  worker = @worker_class.new("foo")
80
86
  out = capture_stdout { worker.prepare }
81
87
  assert_equal ["demo.test.foo"], worker.tube_names
82
- assert_match /demo\.test\.foo/, out
88
+ assert_match(/demo\.test\.foo/, out)
83
89
  end # single
84
90
 
85
91
  it "should respect default_queues settings" do
@@ -87,7 +93,7 @@ describe "Backburner::Workers::ThreadsOnFork module" do
87
93
  worker = @worker_class.new
88
94
  out = capture_stdout { worker.prepare }
89
95
  assert_equal ["demo.test.foo", "demo.test.bar"], worker.tube_names
90
- assert_match /demo\.test\.foo/, out
96
+ assert_match(/demo\.test\.foo/, out)
91
97
  end
92
98
 
93
99
  it "should assign based on all tubes" do
@@ -95,14 +101,14 @@ describe "Backburner::Workers::ThreadsOnFork module" do
95
101
  worker = @worker_class.new
96
102
  out = capture_stdout { worker.prepare }
97
103
  assert_equal ["demo.test.bar"], worker.tube_names
98
- assert_match /demo\.test\.bar/, out
104
+ assert_match(/demo\.test\.bar/, out)
99
105
  end # all assign
100
106
 
101
107
  it "should properly retrieve all tubes" do
102
108
  worker = @worker_class.new
103
109
  out = capture_stdout { worker.prepare }
104
110
  assert_contains worker.tube_names, "demo.test.test-job-fork"
105
- assert_match /demo\.test\.test-job-fork/, out
111
+ assert_match(/demo\.test\.test-job-fork/, out)
106
112
  end # all read
107
113
  end # prepare
108
114
 
@@ -136,7 +142,7 @@ describe "Backburner::Workers::ThreadsOnFork module" do
136
142
  def worker.create_thread(*args, &block); block.call(*args) end
137
143
 
138
144
  out = silenced(2) { worker.start(false) }
139
- refute_match /Catastrophic failure/, out
145
+ refute_match(/Catastrophic failure/, out)
140
146
  end
141
147
 
142
148
  it "fork_and_watch thread should log an error if exitstatus is != 99" do
@@ -153,7 +159,7 @@ describe "Backburner::Workers::ThreadsOnFork module" do
153
159
  end
154
160
  def worker.create_thread(*args, &block); block.call(*args) end
155
161
  out = silenced(2) { worker.start(false) }
156
- assert_match /Catastrophic failure: tube demo\.test\.foo exited with code 0\./, out
162
+ assert_match(/Catastrophic failure: tube demo\.test\.foo exited with code 0\./, out)
157
163
  end
158
164
 
159
165
  describe "fork_inner" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: backburner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.6
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Esquenazi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-26 00:00:00.000000000 Z
11
+ date: 2015-04-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: beaneater
@@ -16,26 +16,26 @@ dependencies:
16
16
  requirements:
17
17
  - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: 0.3.1
19
+ version: '1.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ~>
25
25
  - !ruby/object:Gem::Version
26
- version: 0.3.1
26
+ version: '1.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: dante
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - '>'
32
32
  - !ruby/object:Gem::Version
33
33
  version: 0.1.5
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - '>'
39
39
  - !ruby/object:Gem::Version
40
40
  version: 0.1.5
41
41
  - !ruby/object:Gem::Dependency
@@ -88,6 +88,7 @@ executables:
88
88
  extensions: []
89
89
  extra_rdoc_files: []
90
90
  files:
91
+ - .DS_Store
91
92
  - .gitignore
92
93
  - .travis.yml
93
94
  - CHANGELOG.md
@@ -190,4 +191,3 @@ test_files:
190
191
  - test/workers/forking_worker_test.rb
191
192
  - test/workers/simple_worker_test.rb
192
193
  - test/workers/threads_on_fork_worker_test.rb
193
- has_rdoc: