heartcheck-resque 0.0.1

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f848101f29129c14dae99377b88eb1d1f3724aef
4
+ data.tar.gz: 7bbd327a7f40c41474e83f715b4baa2f7f41b72a
5
+ SHA512:
6
+ metadata.gz: 2b34d45593638cd19b3f03eca26701e9c31734386a6e7599e2529a2f74410b882e8fc2712dfc9916e0669747d5be3a6fd0f4f2b494471baa315523d5d0195a4d
7
+ data.tar.gz: eb06e4031524c4040edf227c659a8e214af6cfce922162ae58c0b0c6004c98a87fd719953d49c4a16745fb9892288c6a1f2f6994290b8ea55016a5d18c6904ef
data/.gitignore ADDED
@@ -0,0 +1,15 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
15
+ /vendor/bundle
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.1.0
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://geminabox.locaweb.com.br'
2
+
3
+ # Specify your gem's dependencies in heartcheck-resque.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Rafael Lima
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # Heartcheck::Resque
2
+
3
+ [![Build Status](https://travis-ci.org/locaweb/heartcheck-resque.svg)](https://travis-ci.org/locaweb/heartcheck-resque)
4
+
5
+ A plugin to check resque connection with heartcheck
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'heartcheck-resque'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install heartcheck-resque
22
+
23
+ ## Usage
24
+
25
+ You can add a check to resque when configure the heartcheck
26
+
27
+ ```ruby
28
+ Heartcheck.setup do |config|
29
+ config.add :resque do |c|
30
+ c.name = 'redis'
31
+ end
32
+ end
33
+ ```
34
+
35
+ ## Contributing
36
+
37
+ 1. Fork it ( https://github.com/locaweb/heartcheck-resque/fork )
38
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
39
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
40
+ 4. Push to the branch (`git push origin my-new-feature`)
41
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'heartcheck/resque/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "heartcheck-resque"
8
+ spec.version = Heartcheck::Resque::VERSION
9
+ spec.authors = ["Locaweb"]
10
+ spec.email = ["desenvolvedores@locaweb.com.br"]
11
+ spec.summary = 'A resque failures checker'
12
+ spec.description = 'Plugin to check resque failures'
13
+ spec.homepage = "http://developer.locaweb.com.br"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency 'rspec', '~> 3.1.0', '>= 3.1.0'
23
+ spec.add_development_dependency 'rubocop', '~> 0.27.0', '>= 0.27.1'
24
+ spec.add_development_dependency 'pry-nav', '~> 0.2.0', '>= 0.2.4'
25
+
26
+ spec.add_dependency 'heartcheck', '~> 1.0.0', '>= 1.0.0'
27
+ spec.add_dependency 'resque', '~> 1.0'
28
+ end
@@ -0,0 +1,28 @@
1
+ module Heartcheck
2
+ module Checks
3
+ class Resque < Base
4
+ def validate
5
+ services.each do |service|
6
+ begin
7
+ quantity = failures_counter
8
+ if quantity > service[:failures_limit].to_i
9
+ append_error("#{quantity} failures")
10
+ end
11
+ rescue => e
12
+ append_error(e.message)
13
+ end
14
+ end
15
+ end
16
+
17
+ private
18
+
19
+ def failures_counter
20
+ ::Resque::Failure.count
21
+ end
22
+
23
+ def custom_error(msg)
24
+ @errors << "Resque failed! #{msg}"
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,5 @@
1
+ module Heartcheck
2
+ module Resque
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ require 'resque'
2
+ require 'heartcheck'
3
+ require 'heartcheck/checks/resque'
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ describe Heartcheck::Checks::Resque do
4
+ let(:opts) { { failures_limit: 0 } }
5
+ subject { described_class.new.tap { |c| c.add_service(opts) } }
6
+
7
+ describe '#validate' do
8
+ context 'with errors' do
9
+ before { allow(Resque::Failure).to receive(:count).and_return(2) }
10
+
11
+ it 'sets @error' do
12
+ subject.validate
13
+ expect(subject.instance_variable_get(:@errors)).to eq(['Resque failed! 2 failures'])
14
+ end
15
+ end
16
+
17
+ context 'with success' do
18
+ before { expect(Resque::Failure).to receive(:count).and_return(0) }
19
+
20
+ it 'has no errors' do
21
+ subject.validate
22
+ expect(subject.instance_variable_get(:@errors)).to be_empty
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,12 @@
1
+ require 'heartcheck/resque'
2
+ require 'pry-nav'
3
+
4
+ RSpec.configure do |config|
5
+ config.mock_with :rspec do |c|
6
+ c.syntax = :expect
7
+ end
8
+
9
+ config.expect_with :rspec do |c|
10
+ c.syntax = :expect
11
+ end
12
+ end
metadata ADDED
@@ -0,0 +1,166 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: heartcheck-resque
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Locaweb
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-06-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 3.1.0
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: 3.1.0
37
+ type: :development
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - "~>"
42
+ - !ruby/object:Gem::Version
43
+ version: 3.1.0
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 3.1.0
47
+ - !ruby/object:Gem::Dependency
48
+ name: rubocop
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: 0.27.0
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: 0.27.1
57
+ type: :development
58
+ prerelease: false
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - "~>"
62
+ - !ruby/object:Gem::Version
63
+ version: 0.27.0
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: 0.27.1
67
+ - !ruby/object:Gem::Dependency
68
+ name: pry-nav
69
+ requirement: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - "~>"
72
+ - !ruby/object:Gem::Version
73
+ version: 0.2.0
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: 0.2.4
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - "~>"
82
+ - !ruby/object:Gem::Version
83
+ version: 0.2.0
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: 0.2.4
87
+ - !ruby/object:Gem::Dependency
88
+ name: heartcheck
89
+ requirement: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - "~>"
92
+ - !ruby/object:Gem::Version
93
+ version: 1.0.0
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: 1.0.0
97
+ type: :runtime
98
+ prerelease: false
99
+ version_requirements: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 1.0.0
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: 1.0.0
107
+ - !ruby/object:Gem::Dependency
108
+ name: resque
109
+ requirement: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - "~>"
112
+ - !ruby/object:Gem::Version
113
+ version: '1.0'
114
+ type: :runtime
115
+ prerelease: false
116
+ version_requirements: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - "~>"
119
+ - !ruby/object:Gem::Version
120
+ version: '1.0'
121
+ description: Plugin to check resque failures
122
+ email:
123
+ - desenvolvedores@locaweb.com.br
124
+ executables: []
125
+ extensions: []
126
+ extra_rdoc_files: []
127
+ files:
128
+ - ".gitignore"
129
+ - ".ruby-version"
130
+ - Gemfile
131
+ - LICENSE.txt
132
+ - README.md
133
+ - Rakefile
134
+ - heartcheck-resque.gemspec
135
+ - lib/heartcheck/checks/resque.rb
136
+ - lib/heartcheck/resque.rb
137
+ - lib/heartcheck/resque/version.rb
138
+ - spec/heartcheck/checks/resque_spec.rb
139
+ - spec/spec_helper.rb
140
+ homepage: http://developer.locaweb.com.br
141
+ licenses:
142
+ - MIT
143
+ metadata: {}
144
+ post_install_message:
145
+ rdoc_options: []
146
+ require_paths:
147
+ - lib
148
+ required_ruby_version: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ required_rubygems_version: !ruby/object:Gem::Requirement
154
+ requirements:
155
+ - - ">="
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
158
+ requirements: []
159
+ rubyforge_project:
160
+ rubygems_version: 2.2.0
161
+ signing_key:
162
+ specification_version: 4
163
+ summary: A resque failures checker
164
+ test_files:
165
+ - spec/heartcheck/checks/resque_spec.rb
166
+ - spec/spec_helper.rb