Sha256: cef81bf81380fcbec4f7eafad6332fab06739fdab1a56b345cc8444819766eb9

Contents?: true

Size: 656 Bytes

Versions: 6

Compression:

Stored size: 656 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

    attr_reader :measurements

    def initialize
      @measurements = []
    end

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

    def pop_report
      report = Report.new

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

      report
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rails_autoscale_agent-0.9.1 lib/rails_autoscale_agent/store.rb
rails_autoscale_agent-0.9.0 lib/rails_autoscale_agent/store.rb
rails_autoscale_agent-0.9.0.beta.5 lib/rails_autoscale_agent/store.rb
rails_autoscale_agent-0.9.0.beta.4 lib/rails_autoscale_agent/store.rb
rails_autoscale_agent-0.9.0.beta.2 lib/rails_autoscale_agent/store.rb
rails_autoscale_agent-0.9.0.beta.1 lib/rails_autoscale_agent/store.rb