sidekiq-retries 0.2.0 → 0.3.0

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
  SHA1:
3
- metadata.gz: 87c2aac2892ffd9e2b44612ab5f37a1fa78388e9
4
- data.tar.gz: 6dc7a56dee7f165c425f2272656ec773530556d3
3
+ metadata.gz: 5f60b5afa37dea410255c1b748aa0274ed065f5b
4
+ data.tar.gz: e4658e58fa25eda6e6483907a2804cc789fc42f2
5
5
  SHA512:
6
- metadata.gz: c341f9fb8bca656566987dee920e37be30dba4b785402cf38088275c6c15a63cb09ee9ba476839ae5d6c3f07999947e9d066e5c3638cc84fe1a3128de82d1d07
7
- data.tar.gz: edab40f7f4331d138dc7f24b9ce1d637a740329bdea797483f0dc15ec8336eea29822cc89301a3f8027a8be1a851cac205944c13e7fed854793911b05b15d66c
6
+ metadata.gz: ead691bdce28f57974d1f10eacd84eaac9158ac4e6c0dc5dcb81ea62a8224ab4158166e7d10945247898ad46def81d5eb4c1d1aced48767b2ccc19f7ba8a427f
7
+ data.tar.gz: e818436af75490f09ed2215da50b27bba1a6ed351a9758ce44bdeb106db963dd0d4f8e75f30eed58639486bb401416f09d9e498ff86537570e0fd05eec901f9d
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ cache: bundler
3
+ rvm:
4
+ - 2.1.2
5
+ - jruby-19mode
6
+ services:
7
+ - redis-server
data/Gemfile CHANGED
@@ -7,4 +7,5 @@ group :development, :test do
7
7
  gem 'redcarpet', :platform => :ruby
8
8
  gem 'yard'
9
9
  gem 'pry'
10
+ gem 'sidekiq', git: 'https://github.com/mperham/sidekiq.git'
10
11
  end
data/HISTORY.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.0
4
+ * stop cutting + pasting Sidekiq retry logic, which is now extracted into a method (https://github.com/mperham/sidekiq/pull/1928)
5
+ * require sidekiq 3.2.4
6
+
3
7
  ## 0.2.0
4
8
  * simplify retry/fail logic
5
9
  * fix retry: 0, which was going straight to the dead queue
data/README.md CHANGED
@@ -1,7 +1,17 @@
1
1
  # Sidekiq::Retries
2
2
 
3
- This subclasses the stock Sidekiq retries middleware to give you some additional options to conditionally retry jobs
4
- irrespective of whether retries are enabled for the job.
3
+ [![Build Status](https://travis-ci.org/govdelivery/sidekiq-retries.svg?branch=master)](https://travis-ci.org/govdelivery/sidekiq-retries)
4
+
5
+ This subclasses the stock Sidekiq retries middleware so that you can
6
+
7
+ * retry a job that has retries disabled (retry: 0 or retry: false)
8
+ * abort (don't retry) a job that will otherwise retry by default
9
+
10
+ but still have the job raise an exception so that you can observe that the job failed (by checking the logs,
11
+ using sidekiq-failures, etc.).
12
+
13
+ Don't use this as a replacement for making your jobs idempotent!
14
+
5
15
 
6
16
  ## Installation
7
17
 
@@ -9,6 +19,8 @@ Add this line to your application's Gemfile:
9
19
 
10
20
  gem 'sidekiq-retries'
11
21
 
22
+
23
+
12
24
  ## Usage
13
25
 
14
26
  class NoRetryJob
@@ -16,7 +28,7 @@ Add this line to your application's Gemfile:
16
28
  sidekiq_options retry: false # or retry: 0
17
29
 
18
30
  def perform
19
- # force a retry
31
+ # retry this job when it otherwise would not
20
32
  raise Sidekiq::Retries::Retry.new(RuntimeError.new('whatever happened'))
21
33
  end
22
34
  end
@@ -26,14 +38,10 @@ Add this line to your application's Gemfile:
26
38
  sidekiq_options retry: 25
27
39
 
28
40
  def perform
29
- # fail the job, don't retry it
41
+ # don't retry this particular job
30
42
  raise Sidekiq::Retries::Fail.new(RuntimeError.new('whatever happened'))
31
43
  end
32
44
  end
33
-
34
- ## Caveats
35
-
36
- * Jobs with retry: 0 don't ever appear to show up in the Sidekiq 3 Dead queue
37
45
 
38
46
  ## Contributing
39
47
 
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ require "rubygems"
2
+ require "bundler/setup"
1
3
  require "bundler/gem_tasks"
2
4
  require 'rspec/core/rake_task'
3
5
 
@@ -20,56 +20,10 @@ module Sidekiq
20
20
  # seriously, don't retry this
21
21
  raise e.cause
22
22
  rescue Exception => e
23
- attempt_retry(worker, msg, queue, e) if msg['retry']
24
- raise e
25
- end
26
-
27
- private
28
-
29
- # This is the default Sidekiq 3.2.2 retry logic
30
- def attempt_retry(worker, msg, queue, e)
31
23
  # ignore, will be pushed back onto queue during hard_shutdown
32
24
  raise Sidekiq::Shutdown if exception_caused_by_shutdown?(e)
33
-
34
25
  raise e unless msg['retry']
35
- max_retry_attempts = retry_attempts_from(msg['retry'], @max_retries)
36
-
37
- msg['queue'] = if msg['retry_queue']
38
- msg['retry_queue']
39
- else
40
- queue
41
- end
42
- msg['error_message'] = e.message[0..10_000]
43
- msg['error_class'] = e.class.name
44
- count = if msg['retry_count']
45
- msg['retried_at'] = Time.now.to_f
46
- msg['retry_count'] += 1
47
- else
48
- msg['failed_at'] = Time.now.to_f
49
- msg['retry_count'] = 0
50
- end
51
-
52
- if msg['backtrace'] == true
53
- msg['error_backtrace'] = e.backtrace
54
- elsif msg['backtrace'] == false
55
- # do nothing
56
- elsif msg['backtrace'].to_i != 0
57
- msg['error_backtrace'] = e.backtrace[0..msg['backtrace'].to_i]
58
- end
59
-
60
- if count < max_retry_attempts
61
- delay = delay_for(worker, count)
62
- logger.debug { "Failure! Retry #{count} in #{delay} seconds" }
63
- retry_at = Time.now.to_f + delay
64
- payload = Sidekiq.dump_json(msg)
65
- Sidekiq.redis do |conn|
66
- conn.zadd('retry', retry_at.to_s, payload)
67
- end
68
- else
69
- # Goodbye dear message, you (re)tried your best I'm sure.
70
- retries_exhausted(worker, msg)
71
- end
72
-
26
+ attempt_retry(worker, msg, queue, e)
73
27
  raise e
74
28
  end
75
29
 
@@ -1,5 +1,5 @@
1
1
  module Sidekiq
2
2
  module Retries
3
- VERSION = "0.2.0"
3
+ VERSION = "0.3.0"
4
4
  end
5
5
  end
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency 'sidekiq', '~>3.0'
21
+ spec.add_dependency 'sidekiq', '>= 3.2.4', '~>3.2'
22
22
  spec.add_development_dependency "bundler", "~> 1.3"
23
23
  spec.add_development_dependency 'rake'
24
24
  spec.add_development_dependency 'rspec'
metadata CHANGED
@@ -1,29 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-retries
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Benjamin Ortega
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-26 00:00:00.000000000 Z
11
+ date: 2014-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sidekiq
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 3.2.4
17
20
  - - "~>"
18
21
  - !ruby/object:Gem::Version
19
- version: '3.0'
22
+ version: '3.2'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 3.2.4
24
30
  - - "~>"
25
31
  - !ruby/object:Gem::Version
26
- version: '3.0'
32
+ version: '3.2'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: bundler
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -130,6 +136,7 @@ extensions: []
130
136
  extra_rdoc_files: []
131
137
  files:
132
138
  - ".gitignore"
139
+ - ".travis.yml"
133
140
  - Gemfile
134
141
  - HISTORY.md
135
142
  - LICENSE.txt