Sha256: bf93c15b8d95b8707642bcec8eb97eeb8606ad6a487554d637237f22778fd17b

Contents?: true

Size: 573 Bytes

Versions: 2

Compression:

Stored size: 573 Bytes

Contents

# frozen_string_literal: true

require 'singleton'
require 'rails_autoscale_agent/time_rounder'
require 'rails_autoscale_agent/measurement'
require 'rails_autoscale_agent/report'

module RailsAutoscaleAgent
  class Store
    include Singleton

    def initialize
      @measurements = []
    end

    def push(value, time = Time.now)
      @measurements << Measurement.new(time, value)
    end

    def pop_report
      report = Report.new

      while measurement = @measurements.shift
        report.measurements << measurement
      end

      report
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rails_autoscale_agent-0.4.1 lib/rails_autoscale_agent/store.rb
rails_autoscale_agent-0.4.0 lib/rails_autoscale_agent/store.rb