degrade 0.1.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ group :development do
2
+ gem "jeweler"
3
+ gem "rspec", "1.3.0"
4
+ gem "bourne", "1.0.0"
5
+ gem "redis", "=2.0.12"
6
+ end
@@ -0,0 +1,23 @@
1
+ GEM
2
+ specs:
3
+ bourne (1.0)
4
+ mocha (= 0.9.8)
5
+ git (1.2.5)
6
+ jeweler (1.5.2)
7
+ bundler (~> 1.0.0)
8
+ git (>= 1.2.5)
9
+ rake
10
+ mocha (0.9.8)
11
+ rake
12
+ rake (0.8.7)
13
+ redis (2.0.12)
14
+ rspec (1.3.0)
15
+
16
+ PLATFORMS
17
+ ruby
18
+
19
+ DEPENDENCIES
20
+ bourne (= 1.0.0)
21
+ jeweler
22
+ redis (= 2.0.12)
23
+ rspec (= 1.3.0)
@@ -63,7 +63,7 @@ We're doing this for one of our services and it's working pretty well.
63
63
 
64
64
  == Known issues / concerns
65
65
 
66
- Making a bunch of requests to services whose drivers are wrapped in this could cause problems if your services / site are extremely high throughput. This could be improved somewhat by adding some randomness to threshold checking and sample resetting so that those things aren't checked every request. The service we're currently using this with runs at about 25 req / s which is a _long_ way before any problems are likely.
66
+ Making a bunch of requests to services whose drivers are wrapped in this could cause problems if your services / site are extremely high throughput. This could be improved somewhat by adding some randomness to threshold checking and sample resetting so that those things aren't checked every request. The service we're currently using this with runs at about 250 req / s which is a _long_ way before any problems are likely.
67
67
 
68
68
  Also, obviously calls to redis add latency to your requests. Make sure you're okay with this.
69
69
 
data/Rakefile CHANGED
@@ -1,5 +1,8 @@
1
1
  require 'rubygems'
2
2
  require 'rake'
3
+ require 'bundler'
4
+
5
+ Bundler.setup
3
6
 
4
7
  begin
5
8
  require 'jeweler'
@@ -10,9 +13,6 @@ begin
10
13
  gem.email = "jamesgolick@gmail.com"
11
14
  gem.homepage = "http://github.com/jamesgolick/degrade"
12
15
  gem.authors = ["James Golick"]
13
- gem.add_development_dependency "rspec", "1.2.9"
14
- gem.add_development_dependency "bourne", "1.0.0"
15
- gem.add_development_dependency "redis", "0.1.0"
16
16
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
17
17
  end
18
18
  Jeweler::GemcutterTasks.new
@@ -32,8 +32,6 @@ Spec::Rake::SpecTask.new(:rcov) do |spec|
32
32
  spec.rcov = true
33
33
  end
34
34
 
35
- task :spec => :check_dependencies
36
-
37
35
  task :default => :spec
38
36
 
39
37
  require 'rake/rdoctask'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 1.0.0
@@ -0,0 +1,10 @@
1
+ class Degraderator
2
+ def initialize(degrade, object)
3
+ @degrade = degrade
4
+ @object = object
5
+ end
6
+
7
+ def method_missing(method, *args)
8
+ @degrade.perform { @object.send(method, *args) }
9
+ end
10
+ end
@@ -0,0 +1,26 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe Degraderator do
4
+ before do
5
+ @degrade = stub("Degrade")
6
+ # it seems that mocha doesn't let you pass a block that gets
7
+ # the arguments passed to it, and has the result returned. erg.
8
+ @degrade.stubs(:perform).yields.returns(:bar)
9
+
10
+ @object = stub("Something", :foo => :bar)
11
+ @degraderator = Degraderator.new(@degrade, @object)
12
+ @result = @degraderator.foo("boom")
13
+ end
14
+
15
+ it "calls perform" do
16
+ @degrade.should have_received(:perform)
17
+ end
18
+
19
+ it "uses method_missing to delegate method calls to the object" do
20
+ @object.should have_received(:foo).with("boom")
21
+ end
22
+
23
+ it "returns the result from the object" do
24
+ @result.should == :bar
25
+ end
26
+ end
@@ -1,6 +1,7 @@
1
1
  $LOAD_PATH.unshift(File.dirname(__FILE__))
2
2
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
3
  require 'degrade'
4
+ require 'degraderator'
4
5
  require 'spec'
5
6
  require 'spec/autorun'
6
7
  require 'bourne'
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: degrade
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
5
- prerelease: false
4
+ hash: 23
5
+ prerelease:
6
6
  segments:
7
- - 0
8
7
  - 1
9
8
  - 0
10
- version: 0.1.0
9
+ - 0
10
+ version: 1.0.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - James Golick
@@ -15,29 +15,41 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-07-17 00:00:00 -07:00
18
+ date: 2011-10-06 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
- name: rspec
22
+ version_requirements: &id001 !ruby/object:Gem::Requirement
23
+ none: false
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ hash: 3
28
+ segments:
29
+ - 0
30
+ version: "0"
31
+ name: jeweler
32
+ type: :development
23
33
  prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
34
+ requirement: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ version_requirements: &id002 !ruby/object:Gem::Requirement
25
37
  none: false
26
38
  requirements:
27
39
  - - "="
28
40
  - !ruby/object:Gem::Version
29
- hash: 13
41
+ hash: 27
30
42
  segments:
31
43
  - 1
32
- - 2
33
- - 9
34
- version: 1.2.9
44
+ - 3
45
+ - 0
46
+ version: 1.3.0
47
+ name: rspec
35
48
  type: :development
36
- version_requirements: *id001
37
- - !ruby/object:Gem::Dependency
38
- name: bourne
39
49
  prerelease: false
40
- requirement: &id002 !ruby/object:Gem::Requirement
50
+ requirement: *id002
51
+ - !ruby/object:Gem::Dependency
52
+ version_requirements: &id003 !ruby/object:Gem::Requirement
41
53
  none: false
42
54
  requirements:
43
55
  - - "="
@@ -48,24 +60,26 @@ dependencies:
48
60
  - 0
49
61
  - 0
50
62
  version: 1.0.0
63
+ name: bourne
51
64
  type: :development
52
- version_requirements: *id002
53
- - !ruby/object:Gem::Dependency
54
- name: redis
55
65
  prerelease: false
56
- requirement: &id003 !ruby/object:Gem::Requirement
66
+ requirement: *id003
67
+ - !ruby/object:Gem::Dependency
68
+ version_requirements: &id004 !ruby/object:Gem::Requirement
57
69
  none: false
58
70
  requirements:
59
71
  - - "="
60
72
  - !ruby/object:Gem::Version
61
- hash: 27
73
+ hash: 23
62
74
  segments:
75
+ - 2
63
76
  - 0
64
- - 1
65
- - 0
66
- version: 0.1.0
77
+ - 12
78
+ version: 2.0.12
79
+ name: redis
67
80
  type: :development
68
- version_requirements: *id003
81
+ prerelease: false
82
+ requirement: *id004
69
83
  description: Keep track of error rates using redis. Degrade functionality if they're too high.
70
84
  email: jamesgolick@gmail.com
71
85
  executables: []
@@ -77,13 +91,16 @@ extra_rdoc_files:
77
91
  - README.rdoc
78
92
  files:
79
93
  - .document
80
- - .gitignore
94
+ - Gemfile
95
+ - Gemfile.lock
81
96
  - LICENSE
82
97
  - README.rdoc
83
98
  - Rakefile
84
99
  - VERSION
85
100
  - lib/degrade.rb
101
+ - lib/degraderator.rb
86
102
  - spec/degrade_spec.rb
103
+ - spec/degraderator_spec.rb
87
104
  - spec/spec.opts
88
105
  - spec/spec_helper.rb
89
106
  has_rdoc: true
@@ -91,8 +108,8 @@ homepage: http://github.com/jamesgolick/degrade
91
108
  licenses: []
92
109
 
93
110
  post_install_message:
94
- rdoc_options:
95
- - --charset=UTF-8
111
+ rdoc_options: []
112
+
96
113
  require_paths:
97
114
  - lib
98
115
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -116,10 +133,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
116
133
  requirements: []
117
134
 
118
135
  rubyforge_project:
119
- rubygems_version: 1.3.7
136
+ rubygems_version: 1.3.9.3
120
137
  signing_key:
121
138
  specification_version: 3
122
139
  summary: Keep track of error rates using redis. Degrade functionality if they're too high.
123
140
  test_files:
124
141
  - spec/degrade_spec.rb
142
+ - spec/degraderator_spec.rb
125
143
  - spec/spec_helper.rb
data/.gitignore DELETED
@@ -1,21 +0,0 @@
1
- ## MAC OS
2
- .DS_Store
3
-
4
- ## TEXTMATE
5
- *.tmproj
6
- tmtags
7
-
8
- ## EMACS
9
- *~
10
- \#*
11
- .\#*
12
-
13
- ## VIM
14
- *.swp
15
-
16
- ## PROJECT::GENERAL
17
- coverage
18
- rdoc
19
- pkg
20
-
21
- ## PROJECT::SPECIFIC