backburner 0.4.1 → 0.4.2

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.
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## Version 0.4.2 (July 3 2013)
4
+
5
+ * FIX #44 Properly retry to connect to beanstalkd when connection fails.
6
+
3
7
  ## Version 0.4.1 (June 28 2013)
4
8
 
5
9
  * FIX #43 Properly support CLI options and smart load the app environment.
data/README.md CHANGED
@@ -443,6 +443,10 @@ The best way to deploy these rake tasks is using a monitoring library. We sugges
443
443
  which watches processes and ensures their stability. A simple God recipe for Backburner can be found in
444
444
  [examples/god](https://github.com/nesquena/backburner/blob/master/examples/god.rb).
445
445
 
446
+ In Backburner, if the beanstalkd connection is temporarily severed, several retries to establish the connection will be attempted.
447
+ After several retries, if the connection is still not able to be made, a `Beaneater::NotConnected` exception will be raised.
448
+ You can manually catch this exception, and attempt another manual retry using `Backburner::Worker.retry_connection!`.
449
+
446
450
  ### Web Front-end
447
451
 
448
452
  Be sure to check out the Sinatra-powered project [beanstalkd_view](https://github.com/denniskuczynski/beanstalkd_view)
@@ -1,3 +1,3 @@
1
1
  module Backburner
2
- VERSION = "0.4.1"
2
+ VERSION = "0.4.2"
3
3
  end
@@ -34,6 +34,8 @@ module Backburner
34
34
  tube.put data.to_json, :pri => pri, :delay => delay, :ttr => ttr
35
35
  Backburner::Hooks.invoke_hook_events(job_class, :after_enqueue, *args)
36
36
  return true
37
+ rescue Beaneater::NotConnected => e
38
+ retry_connection!
37
39
  end
38
40
 
39
41
  # Starts processing jobs with the specified tube_names.
@@ -52,6 +54,24 @@ module Backburner
52
54
  @connection ||= Connection.new(Backburner.configuration.beanstalk_url)
53
55
  end
54
56
 
57
+ # Retries to make a connection to beanstalkd if that connection failed.
58
+ # @raise [Beaneater::NotConnected] If beanstalk fails to connect multiple times.
59
+ def self.retry_connection!(max_tries=5)
60
+ retry_count = 0
61
+ begin
62
+ @connection = nil
63
+ self.connection
64
+ rescue Beaneater::NotConnected => e
65
+ if retry_count < max_tries
66
+ retry_count += 1
67
+ sleep 0.5
68
+ retry
69
+ else # stop retrying
70
+ raise e
71
+ end
72
+ end
73
+ end # retry_connection!
74
+
55
75
  # List of tube names to be watched and processed
56
76
  attr_accessor :tube_names
57
77
 
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.4.1
4
+ version: 0.4.2
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-06-28 00:00:00.000000000 Z
12
+ date: 2013-07-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: beaneater
@@ -169,7 +169,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
169
169
  version: '0'
170
170
  segments:
171
171
  - 0
172
- hash: -3041917192474660022
172
+ hash: -4352332376795710100
173
173
  required_rubygems_version: !ruby/object:Gem::Requirement
174
174
  none: false
175
175
  requirements:
@@ -178,7 +178,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
178
178
  version: '0'
179
179
  segments:
180
180
  - 0
181
- hash: -3041917192474660022
181
+ hash: -4352332376795710100
182
182
  requirements: []
183
183
  rubyforge_project:
184
184
  rubygems_version: 1.8.25