sidekiq_metered_exceptions 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -2
- data/Gemfile.lock +3 -0
- data/README.rdoc +2 -0
- data/VERSION +1 -1
- data/lib/metered_raven_error_handler.rb +16 -0
- data/lib/sidekiq_metered_exceptions.rb +1 -1
- data/sidekiq_metered_exceptions.gemspec +7 -4
- data/test/test_sidekiq_metered_exceptions.rb +3 -15
- metadata +17 -3
- data/lib/middleware.rb +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79b03042f7659b991d71c1fb5a5d5fe2f200fbd7
|
4
|
+
data.tar.gz: 0b71c4a04f953025c6bd7f271dd4d7e683323d21
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc885bc0c0ea35ccce8c3062f0d6628f8dbb965f366e44d92592ce11c67b7bd97dee60b65cdf2d0e799320c4a134f98bb15ecbeb3bc51432ef97bf70da65dedb
|
7
|
+
data.tar.gz: 4253bab7736d40e71d42fd1a2e1584e5a2f904f83eb2891b72d354ba5d1e7dcb0c625cbd1e2f4d187578c1efd9ab6ffad4368630aa3632d231cf7d4be9f7baa7
|
data/Gemfile
CHANGED
@@ -2,7 +2,7 @@ source "http://rubygems.org"
|
|
2
2
|
# Add dependencies required to use your gem here.
|
3
3
|
|
4
4
|
gem 'sidekiq'
|
5
|
-
|
5
|
+
gem 'sentry-raven'
|
6
6
|
|
7
7
|
# Add dependencies to develop your gem here.
|
8
8
|
# Include everything needed to run rake, tests, features, etc.
|
@@ -11,5 +11,4 @@ group :development do
|
|
11
11
|
gem "rdoc"
|
12
12
|
gem "bundler"
|
13
13
|
gem "jeweler"
|
14
|
-
|
15
14
|
end
|
data/Gemfile.lock
CHANGED
@@ -57,6 +57,8 @@ GEM
|
|
57
57
|
redis-namespace (1.3.0)
|
58
58
|
redis (~> 3.0.0)
|
59
59
|
semver2 (3.4.2)
|
60
|
+
sentry-raven (2.3.0)
|
61
|
+
faraday (>= 0.7.6, < 1.0)
|
60
62
|
sidekiq (2.12.4)
|
61
63
|
celluloid (>= 0.14.1)
|
62
64
|
connection_pool (>= 1.0.0)
|
@@ -74,6 +76,7 @@ DEPENDENCIES
|
|
74
76
|
jeweler
|
75
77
|
minitest
|
76
78
|
rdoc
|
79
|
+
sentry-raven
|
77
80
|
sidekiq
|
78
81
|
|
79
82
|
BUNDLED WITH
|
data/README.rdoc
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'sidekiq'
|
2
|
+
require 'raven/integrations/sidekiq'
|
3
|
+
|
4
|
+
module SidekiqMeteredExceptions
|
5
|
+
class MeteredRavenErrorHandler < ::Raven::Sidekiq
|
6
|
+
def call(ex, context)
|
7
|
+
retry_count = (context['retry_count'] || (context['job'] && context['job']['retry_count']))
|
8
|
+
|
9
|
+
if retry_count > 1
|
10
|
+
super(ex, context)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
|
@@ -1 +1 @@
|
|
1
|
-
require '
|
1
|
+
require 'metered_raven_error_handler'
|
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: sidekiq_metered_exceptions 0.
|
5
|
+
# stub: sidekiq_metered_exceptions 0.2.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "sidekiq_metered_exceptions".freeze
|
9
|
-
s.version = "0.
|
9
|
+
s.version = "0.2.0"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib".freeze]
|
13
13
|
s.authors = ["Nathan Woodhull".freeze]
|
14
|
-
s.date = "2017-01-
|
14
|
+
s.date = "2017-01-19"
|
15
15
|
s.description = "Some exceptions are transient, so notifying an admin is not useful.".freeze
|
16
16
|
s.email = "woodhull@gmail.com".freeze
|
17
17
|
s.extra_rdoc_files = [
|
@@ -28,7 +28,7 @@ Gem::Specification.new do |s|
|
|
28
28
|
"README.rdoc",
|
29
29
|
"Rakefile",
|
30
30
|
"VERSION",
|
31
|
-
"lib/
|
31
|
+
"lib/metered_raven_error_handler.rb",
|
32
32
|
"lib/sidekiq_metered_exceptions.rb",
|
33
33
|
"sidekiq_metered_exceptions.gemspec",
|
34
34
|
"test/helper.rb",
|
@@ -44,12 +44,14 @@ Gem::Specification.new do |s|
|
|
44
44
|
|
45
45
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
46
46
|
s.add_runtime_dependency(%q<sidekiq>.freeze, [">= 0"])
|
47
|
+
s.add_runtime_dependency(%q<sentry-raven>.freeze, [">= 0"])
|
47
48
|
s.add_development_dependency(%q<minitest>.freeze, [">= 0"])
|
48
49
|
s.add_development_dependency(%q<rdoc>.freeze, [">= 0"])
|
49
50
|
s.add_development_dependency(%q<bundler>.freeze, [">= 0"])
|
50
51
|
s.add_development_dependency(%q<jeweler>.freeze, [">= 0"])
|
51
52
|
else
|
52
53
|
s.add_dependency(%q<sidekiq>.freeze, [">= 0"])
|
54
|
+
s.add_dependency(%q<sentry-raven>.freeze, [">= 0"])
|
53
55
|
s.add_dependency(%q<minitest>.freeze, [">= 0"])
|
54
56
|
s.add_dependency(%q<rdoc>.freeze, [">= 0"])
|
55
57
|
s.add_dependency(%q<bundler>.freeze, [">= 0"])
|
@@ -57,6 +59,7 @@ Gem::Specification.new do |s|
|
|
57
59
|
end
|
58
60
|
else
|
59
61
|
s.add_dependency(%q<sidekiq>.freeze, [">= 0"])
|
62
|
+
s.add_dependency(%q<sentry-raven>.freeze, [">= 0"])
|
60
63
|
s.add_dependency(%q<minitest>.freeze, [">= 0"])
|
61
64
|
s.add_dependency(%q<rdoc>.freeze, [">= 0"])
|
62
65
|
s.add_dependency(%q<bundler>.freeze, [">= 0"])
|
@@ -3,24 +3,12 @@ require 'helper'
|
|
3
3
|
class TestSidekiqMeteredExceptions < Minitest::Test
|
4
4
|
describe 'middleware' do
|
5
5
|
before do
|
6
|
-
@
|
6
|
+
@exception = Exception.new
|
7
|
+
@middleware = SidekiqMeteredExceptions::MeteredRavenErrorHandler.new
|
7
8
|
end
|
8
9
|
|
9
|
-
|
10
|
-
assert_raises(Exception) { @middleware.call('worker', {}, 'queue') { raise Exception.new }}
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'should propagate the exception if the retry count is greater than zero' do
|
14
|
-
assert_raises(Exception) { @middleware.call('worker', {'retry_count' => 1}, 'queue') { raise Exception.new }}
|
15
|
-
end
|
10
|
+
# todo: figure out how to use minitest.
|
16
11
|
|
17
|
-
it 'should not propagate exception if the retry count is zero' do
|
18
|
-
@middleware.call('worker', {'retry_count' => 0}, 'queue') { raise Exception.new }
|
19
|
-
end
|
20
|
-
|
21
|
-
it "should not interfere with successful jobs" do
|
22
|
-
assert( @middleware.call('worker', {'retry_count' =>1}, 'queue') { return true })
|
23
|
-
end
|
24
12
|
|
25
13
|
end
|
26
14
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sidekiq_metered_exceptions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Woodhull
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sidekiq
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: sentry-raven
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: minitest
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -97,7 +111,7 @@ files:
|
|
97
111
|
- README.rdoc
|
98
112
|
- Rakefile
|
99
113
|
- VERSION
|
100
|
-
- lib/
|
114
|
+
- lib/metered_raven_error_handler.rb
|
101
115
|
- lib/sidekiq_metered_exceptions.rb
|
102
116
|
- sidekiq_metered_exceptions.gemspec
|
103
117
|
- test/helper.rb
|
data/lib/middleware.rb
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
module SidekiqMeteredExceptions
|
2
|
-
class Middleware
|
3
|
-
|
4
|
-
def call(worker, job, queue)
|
5
|
-
begin
|
6
|
-
yield
|
7
|
-
rescue StandardError => ex
|
8
|
-
# do not notify on the first occurrence of an exception
|
9
|
-
raise(ex) if job['retry_count'] == nil || job['retry_count'] > 0
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|