Class: HatiConfig::Cache::RefreshConfig
- Inherits:
-
Object
- Object
- HatiConfig::Cache::RefreshConfig
- Includes:
- NumericConfigurable
- Defined in:
- lib/hati_config/cache.rb
Overview
RefreshConfig class handles refresh configuration and behavior.
Instance Attribute Summary collapse
-
#backoff_config ⇒ Object
readonly
Returns the value of attribute backoff_config.
-
#interval ⇒ Object
readonly
Returns the value of attribute interval.
-
#jitter ⇒ Object
readonly
Returns the value of attribute jitter.
Instance Method Summary collapse
-
#backoff { ... } ⇒ Object
Configures backoff behavior.
-
#initialize ⇒ RefreshConfig
constructor
A new instance of RefreshConfig.
-
#next_refresh_time ⇒ Time
Gets the next refresh time.
Methods included from NumericConfigurable
Constructor Details
#initialize ⇒ RefreshConfig
Returns a new instance of RefreshConfig.
152 153 154 155 156 |
# File 'lib/hati_config/cache.rb', line 152 def initialize @interval = 60 @jitter = 0 @backoff_config = BackoffConfig.new end |
Instance Attribute Details
#backoff_config ⇒ Object (readonly)
Returns the value of attribute backoff_config.
148 149 150 |
# File 'lib/hati_config/cache.rb', line 148 def backoff_config @backoff_config end |
#interval ⇒ Object (readonly)
Returns the value of attribute interval.
148 149 150 |
# File 'lib/hati_config/cache.rb', line 148 def interval @interval end |
#jitter ⇒ Object (readonly)
Returns the value of attribute jitter.
148 149 150 |
# File 'lib/hati_config/cache.rb', line 148 def jitter @jitter end |
Instance Method Details
#backoff { ... } ⇒ Object
Configures backoff behavior.
161 162 163 164 |
# File 'lib/hati_config/cache.rb', line 161 def backoff(&block) @backoff_config.instance_eval(&block) if block_given? @backoff_config end |
#next_refresh_time ⇒ Time
Gets the next refresh time.
169 170 171 172 |
# File 'lib/hati_config/cache.rb', line 169 def next_refresh_time jitter_amount = jitter.positive? ? rand(0.0..jitter) : 0 Time.now + interval + jitter_amount end |