Class: ActiveRecord::Health::Configuration
- Inherits:
-
Object
- Object
- ActiveRecord::Health::Configuration
- Defined in:
- lib/activerecord/health/configuration.rb
Instance Attribute Summary collapse
-
#cache ⇒ Object
Returns the value of attribute cache.
-
#cache_ttl ⇒ Object
Returns the value of attribute cache_ttl.
-
#threshold ⇒ Object
Returns the value of attribute threshold.
-
#vcpu_count ⇒ Object
Returns the value of attribute vcpu_count.
Instance Method Summary collapse
- #for_model(model, &block) ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #max_healthy_sessions ⇒ Object
- #validate! ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
10 11 12 13 14 |
# File 'lib/activerecord/health/configuration.rb', line 10 def initialize @threshold = 0.75 @cache_ttl = 60 @model_configs = {} end |
Instance Attribute Details
#cache ⇒ Object
Returns the value of attribute cache.
8 9 10 |
# File 'lib/activerecord/health/configuration.rb', line 8 def cache @cache end |
#cache_ttl ⇒ Object
Returns the value of attribute cache_ttl.
8 9 10 |
# File 'lib/activerecord/health/configuration.rb', line 8 def cache_ttl @cache_ttl end |
#threshold ⇒ Object
Returns the value of attribute threshold.
8 9 10 |
# File 'lib/activerecord/health/configuration.rb', line 8 def threshold @threshold end |
#vcpu_count ⇒ Object
Returns the value of attribute vcpu_count.
8 9 10 |
# File 'lib/activerecord/health/configuration.rb', line 8 def vcpu_count @vcpu_count end |
Instance Method Details
#for_model(model, &block) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/activerecord/health/configuration.rb', line 21 def for_model(model, &block) if block_given? config = ModelConfiguration.new(self) block.call(config) @model_configs[model] = config else @model_configs[model] || self end end |
#max_healthy_sessions ⇒ Object
31 32 33 |
# File 'lib/activerecord/health/configuration.rb', line 31 def max_healthy_sessions (vcpu_count * threshold).floor end |
#validate! ⇒ Object
16 17 18 19 |
# File 'lib/activerecord/health/configuration.rb', line 16 def validate! raise ConfigurationError, "vcpu_count must be configured" if vcpu_count.nil? raise ConfigurationError, "cache must be configured" if cache.nil? end |