class RailsAutoscaleAgent::Store

Attributes

measurements[R]

Public Class Methods

new() click to toggle source
# File lib/rails_autoscale_agent/store.rb, line 14
def initialize
  @measurements = []
end

Public Instance Methods

pop_report() click to toggle source
# File lib/rails_autoscale_agent/store.rb, line 26
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) click to toggle source
# File lib/rails_autoscale_agent/store.rb, line 18
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