resque-pertry 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -22,7 +22,7 @@ module Resque
22
22
  # Sets a number of seconds to wait before retrying
23
23
  def set_retry_delay(delay)
24
24
  self._retry_delays = nil
25
- self._retry_delay = Integer(delay)
25
+ self._retry_delay = delay == :clear ? nil : Integer(delay)
26
26
  end
27
27
 
28
28
  def retry_delay
@@ -31,8 +31,8 @@ module Resque
31
31
 
32
32
  # Sets a list of delays (list length will be the # of attempts)
33
33
  def set_retry_delays(*delays)
34
- self._retry_attempts = nil
35
- self._retry_delay = nil
34
+ set_retry_attempts :clear
35
+ set_retry_delay :clear
36
36
  self._retry_delays = Array(delays).map { |delay| Integer(delay) }
37
37
  end
38
38
 
@@ -43,7 +43,7 @@ module Resque
43
43
  # Sets the maximum number of times we will retry
44
44
  def set_retry_attempts(count)
45
45
  self._retry_delays = nil
46
- self._retry_attempts = Integer(count)
46
+ self._retry_attempts = count == :clear ? nil : Integer(count)
47
47
  end
48
48
 
49
49
  def retry_attempts
@@ -52,7 +52,7 @@ module Resque
52
52
 
53
53
  # Sets the maximum time-to-live of the job, after which no attempts will ever be made
54
54
  def set_retry_ttl(ttl)
55
- self._retry_ttl = Integer(ttl)
55
+ self._retry_ttl = ttl == :clear ? nil : Integer(ttl)
56
56
  end
57
57
 
58
58
  def retry_ttl
@@ -69,6 +69,16 @@ module Resque
69
69
  self._retry_exceptions
70
70
  end
71
71
 
72
+ # Quickly reset all retry properties
73
+ # Useful if you have a base job class
74
+ def reset_retry_properties
75
+ self._retry_delays = nil
76
+ self._retry_attempts = nil
77
+ self._retry_delays = nil
78
+ self._retry_ttl = nil
79
+ self._retry_exceptions = nil
80
+ end
81
+
72
82
  # Check if we will retry this job on failure
73
83
  # There has to be a constraint on the number of times we will retry a failing job
74
84
  # or have a ttl, otherwise we could be retrying job endlessly
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "resque-pertry"
3
3
  s.description = "Adds persistence to Resque jobs, and retry properties"
4
- s.version = "1.0.2"
4
+ s.version = "1.0.3"
5
5
  s.authors = [ "Anthony Powles" ]
6
6
  s.email = "rubygems+resque-pertry@idreamz.net"
7
7
  s.summary = "Allows job to be persistent, and be retried in case of failure"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resque-pertry
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.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-08-06 00:00:00.000000000 Z
12
+ date: 2013-08-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler