Class: RateThrottleClient::Base
- Inherits:
-
Object
- Object
- RateThrottleClient::Base
- Defined in:
- lib/rate_throttle_client/clients/base.rb
Overview
Standard interface for Client classes Don’t abuse this power
Direct Known Subclasses
ExponentialBackoff, ExponentialIncreaseGradualDecrease, ExponentialIncreaseProportionalDecrease, ExponentialIncreaseProportionalRemainingDecrease, Null
Instance Attribute Summary collapse
-
#log ⇒ Object
Returns the value of attribute log.
-
#min_sleep ⇒ Object
Returns the value of attribute min_sleep.
-
#multiplier ⇒ Object
Returns the value of attribute multiplier.
-
#sleep_for ⇒ Object
Returns the value of attribute sleep_for.
Instance Method Summary collapse
-
#initialize(log: nil, min_sleep: nil, starting_sleep_for: 0, multiplier: nil) ⇒ Base
constructor
A new instance of Base.
- #jitter(val) ⇒ Object
Constructor Details
#initialize(log: nil, min_sleep: nil, starting_sleep_for: 0, multiplier: nil) ⇒ Base
Returns a new instance of Base.
7 8 9 10 11 12 |
# File 'lib/rate_throttle_client/clients/base.rb', line 7 def initialize(log: nil, min_sleep: nil, starting_sleep_for: 0, multiplier: nil) @log = log || RateThrottleClient.log_block @min_sleep = min_sleep || RateThrottleClient.min_sleep @multiplier = multiplier || RateThrottleClient.multiplier @sleep_for = starting_sleep_for end |
Instance Attribute Details
#log ⇒ Object
Returns the value of attribute log.
5 6 7 |
# File 'lib/rate_throttle_client/clients/base.rb', line 5 def log @log end |
#min_sleep ⇒ Object
Returns the value of attribute min_sleep.
5 6 7 |
# File 'lib/rate_throttle_client/clients/base.rb', line 5 def min_sleep @min_sleep end |
#multiplier ⇒ Object
Returns the value of attribute multiplier.
5 6 7 |
# File 'lib/rate_throttle_client/clients/base.rb', line 5 def multiplier @multiplier end |
#sleep_for ⇒ Object
Returns the value of attribute sleep_for.
5 6 7 |
# File 'lib/rate_throttle_client/clients/base.rb', line 5 def sleep_for @sleep_for end |
Instance Method Details
#jitter(val) ⇒ Object
14 15 16 |
# File 'lib/rate_throttle_client/clients/base.rb', line 14 def jitter(val) val * rand(0.0..0.1) end |