Class: Degrade
- Inherits:
-
Object
- Object
- Degrade
- Defined in:
- lib/degrade.rb
Instance Method Summary collapse
- #failures ⇒ Object
-
#initialize(redis, options) ⇒ Degrade
constructor
A new instance of Degrade.
- #perform ⇒ Object
- #requests ⇒ Object
Constructor Details
#initialize(redis, options) ⇒ Degrade
Returns a new instance of Degrade.
2 3 4 5 6 7 8 9 10 |
# File 'lib/degrade.rb', line 2 def initialize(redis, ) @redis = redis @name = [:name] @minimum = [:minimum] || 100 @sample = [:sample] || 5000 @threshold = [:threshold] || 0.1 @errors = [:errors] || [StandardError] @failure_strategy = [:failure_strategy] end |
Instance Method Details
#failures ⇒ Object
26 27 28 |
# File 'lib/degrade.rb', line 26 def failures @redis.get(failures_key).to_f end |
#perform ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/degrade.rb', line 12 def perform begin mark_request yield rescue *@errors => e mark_failure raise e end end |
#requests ⇒ Object
22 23 24 |
# File 'lib/degrade.rb', line 22 def requests @redis.get(requests_key).to_f end |