Class: RailsAutoscaleAgent::Store
- Inherits:
-
Object
- Object
- RailsAutoscaleAgent::Store
- Includes:
- Singleton
- Defined in:
- lib/rails_autoscale_agent/store.rb
Instance Attribute Summary collapse
-
#measurements ⇒ Object
readonly
Returns the value of attribute measurements.
Instance Method Summary collapse
-
#initialize ⇒ Store
constructor
A new instance of Store.
- #pop_report ⇒ Object
- #push(value, time = Time.now, queue_name = nil, metric = nil) ⇒ Object
Constructor Details
#initialize ⇒ Store
Returns a new instance of Store.
14 15 16 17 |
# File 'lib/rails_autoscale_agent/store.rb', line 14 def initialize @measurements = [] @last_pop = Time.now end |
Instance Attribute Details
#measurements ⇒ Object (readonly)
Returns the value of attribute measurements.
12 13 14 |
# File 'lib/rails_autoscale_agent/store.rb', line 12 def measurements @measurements end |
Instance Method Details
#pop_report ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/rails_autoscale_agent/store.rb', line 27 def pop_report @last_pop = Time.now report = Report.new while measurement = @measurements.shift report.measurements << measurement end report end |
#push(value, time = Time.now, queue_name = nil, metric = nil) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/rails_autoscale_agent/store.rb', line 19 def push(value, time = Time.now, queue_name = nil, metric = nil) # If it's been two minutes since clearing out the store, stop collecting measurements. # There could be an issue with the reporter, and continuing to collect will consume linear memory. return if @last_pop && @last_pop < Time.now - 120 @measurements << Measurement.new(time, value, queue_name, metric) end |