Class: HatiConfig::Cache::BackoffConfig
- Inherits:
-
Object
- Object
- HatiConfig::Cache::BackoffConfig
- Includes:
- NumericConfigurable
- Defined in:
- lib/hati_config/cache.rb
Overview
BackoffConfig class handles backoff configuration and behavior.
Instance Attribute Summary collapse
-
#initial ⇒ Object
readonly
Returns the value of attribute initial.
-
#max ⇒ Object
readonly
Returns the value of attribute max.
-
#multiplier ⇒ Object
readonly
Returns the value of attribute multiplier.
Instance Method Summary collapse
-
#backoff_time(attempt) ⇒ Integer
Gets the backoff time for a given attempt.
-
#initialize ⇒ BackoffConfig
constructor
A new instance of BackoffConfig.
Methods included from NumericConfigurable
Constructor Details
#initialize ⇒ BackoffConfig
Returns a new instance of BackoffConfig.
183 184 185 186 187 |
# File 'lib/hati_config/cache.rb', line 183 def initialize @initial = 1 @multiplier = 2 @max = 300 end |
Instance Attribute Details
#initial ⇒ Object (readonly)
Returns the value of attribute initial.
179 180 181 |
# File 'lib/hati_config/cache.rb', line 179 def initial @initial end |
#max ⇒ Object (readonly)
Returns the value of attribute max.
179 180 181 |
# File 'lib/hati_config/cache.rb', line 179 def max @max end |
#multiplier ⇒ Object (readonly)
Returns the value of attribute multiplier.
179 180 181 |
# File 'lib/hati_config/cache.rb', line 179 def multiplier @multiplier end |
Instance Method Details
#backoff_time(attempt) ⇒ Integer
Gets the backoff time for a given attempt.
193 194 195 196 |
# File 'lib/hati_config/cache.rb', line 193 def backoff_time(attempt) time = initial * (multiplier**(attempt - 1)) [time, max].min end |