backburner 0.3.2 → 0.3.3
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.
- data/CHANGELOG.md +5 -1
- data/README.md +2 -2
- data/lib/backburner/helpers.rb +3 -3
- data/lib/backburner/version.rb +1 -1
- data/lib/backburner/worker.rb +4 -4
- data/lib/backburner/workers/threads_on_fork.rb +2 -2
- data/test/helpers_test.rb +2 -2
- metadata +9 -4
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -89,7 +89,7 @@ Backburner is extremely simple to setup. Just configure basic settings for backb
|
|
89
89
|
```ruby
|
90
90
|
Backburner.configure do |config|
|
91
91
|
config.beanstalk_url = ["beanstalk://127.0.0.1", "..."]
|
92
|
-
config.tube_namespace = "some
|
92
|
+
config.tube_namespace = "some-app-production"
|
93
93
|
config.on_error = lambda { |e| puts e }
|
94
94
|
config.max_job_retries = 3 # default 0 retries
|
95
95
|
config.retry_delay = 2 # default 5 seconds
|
@@ -427,4 +427,4 @@ Thanks to these projects for inspiration and certain design and implementation d
|
|
427
427
|
* Home: <http://github.com/nesquena/backburner>
|
428
428
|
* Docs: <http://rdoc.info/github/nesquena/backburner/master/frames>
|
429
429
|
* Bugs: <http://github.com/nesquena/backburner/issues>
|
430
|
-
* Gems: <http://gemcutter.org/gems/backburner>
|
430
|
+
* Gems: <http://gemcutter.org/gems/backburner>
|
data/lib/backburner/helpers.rb
CHANGED
@@ -71,9 +71,9 @@ module Backburner
|
|
71
71
|
# Returns configuration options for backburner
|
72
72
|
#
|
73
73
|
# @example
|
74
|
-
#
|
74
|
+
# queue_config.max_job_retries => 3
|
75
75
|
#
|
76
|
-
def
|
76
|
+
def queue_config
|
77
77
|
Backburner.configuration
|
78
78
|
end
|
79
79
|
|
@@ -84,7 +84,7 @@ module Backburner
|
|
84
84
|
# expand_tube_name(FooJob) # => <prefix>.foo-job
|
85
85
|
#
|
86
86
|
def expand_tube_name(tube)
|
87
|
-
prefix =
|
87
|
+
prefix = queue_config.tube_namespace
|
88
88
|
queue_name = if tube.is_a?(String)
|
89
89
|
tube
|
90
90
|
elsif tube.respond_to?(:queue) # use queue name
|
data/lib/backburner/version.rb
CHANGED
data/lib/backburner/worker.rb
CHANGED
@@ -117,9 +117,9 @@ module Backburner
|
|
117
117
|
rescue => e # Error occurred processing job
|
118
118
|
self.log_error self.exception_message(e)
|
119
119
|
num_retries = job.stats.releases
|
120
|
-
retry_status = "failed: attempt #{num_retries+1} of #{
|
121
|
-
if num_retries <
|
122
|
-
delay =
|
120
|
+
retry_status = "failed: attempt #{num_retries+1} of #{queue_config.max_job_retries+1}"
|
121
|
+
if num_retries < queue_config.max_job_retries # retry again
|
122
|
+
delay = queue_config.retry_delay + num_retries ** 3
|
123
123
|
job.release(:delay => delay)
|
124
124
|
self.log_job_end(job.name, "#{retry_status}, retrying in #{delay}s") if job_started_at
|
125
125
|
else # retries failed, bury
|
@@ -135,7 +135,7 @@ module Backburner
|
|
135
135
|
# Filtered for tubes that match the known prefix
|
136
136
|
def all_existing_queues
|
137
137
|
known_queues = Backburner::Worker.known_queue_classes.map(&:queue)
|
138
|
-
existing_tubes = self.connection.tubes.all.map(&:name).select { |tube| tube =~ /^#{
|
138
|
+
existing_tubes = self.connection.tubes.all.map(&:name).select { |tube| tube =~ /^#{queue_config.tube_namespace}/ }
|
139
139
|
known_queues + existing_tubes
|
140
140
|
end
|
141
141
|
|
@@ -147,7 +147,7 @@ module Backburner
|
|
147
147
|
|
148
148
|
# Here we are already on the forked child
|
149
149
|
# We will watch just the selected tube and change the configuration of
|
150
|
-
#
|
150
|
+
# queue_config.max_job_retries if needed
|
151
151
|
#
|
152
152
|
# If we limit the number of threads to 1 it will just run in a loop without
|
153
153
|
# creating any extra thread.
|
@@ -155,7 +155,7 @@ module Backburner
|
|
155
155
|
watch_tube(name)
|
156
156
|
|
157
157
|
if @tubes_data[name]
|
158
|
-
|
158
|
+
queue_config.max_job_retries = @tubes_data[name][:retries] if @tubes_data[name][:retries]
|
159
159
|
else
|
160
160
|
@tubes_data[name] = {}
|
161
161
|
end
|
data/test/helpers_test.rb
CHANGED
@@ -44,11 +44,11 @@ describe "Backburner::Helpers module" do
|
|
44
44
|
end
|
45
45
|
end # exception_message
|
46
46
|
|
47
|
-
describe "for
|
47
|
+
describe "for queue_config" do
|
48
48
|
before { Backburner.expects(:configuration).returns(stub(:tube_namespace => "test.foo.job")) }
|
49
49
|
|
50
50
|
it "accesses correct value for namespace" do
|
51
|
-
assert_equal "test.foo.job",
|
51
|
+
assert_equal "test.foo.job", queue_config.tube_namespace
|
52
52
|
end
|
53
53
|
end # config
|
54
54
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: backburner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-04-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: beaneater
|
@@ -166,15 +166,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
166
166
|
- - ! '>='
|
167
167
|
- !ruby/object:Gem::Version
|
168
168
|
version: '0'
|
169
|
+
segments:
|
170
|
+
- 0
|
171
|
+
hash: 2245407813677174470
|
169
172
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
170
173
|
none: false
|
171
174
|
requirements:
|
172
175
|
- - ! '>='
|
173
176
|
- !ruby/object:Gem::Version
|
174
177
|
version: '0'
|
178
|
+
segments:
|
179
|
+
- 0
|
180
|
+
hash: 2245407813677174470
|
175
181
|
requirements: []
|
176
182
|
rubyforge_project:
|
177
|
-
rubygems_version: 1.8.
|
183
|
+
rubygems_version: 1.8.25
|
178
184
|
signing_key:
|
179
185
|
specification_version: 3
|
180
186
|
summary: Reliable beanstalk background job processing made easy for Ruby and Sinatra
|
@@ -198,4 +204,3 @@ test_files:
|
|
198
204
|
- test/workers/forking_worker_test.rb
|
199
205
|
- test/workers/simple_worker_test.rb
|
200
206
|
- test/workers/threads_on_fork_worker_test.rb
|
201
|
-
has_rdoc:
|