Sha256: f213391f3daefdd7da6c071dea21818ef2042be1a1e8a0d7d8ea96cf0dd42952

Contents?: true

Size: 877 Bytes

Versions: 3

Compression:

Stored size: 877 Bytes

Contents

module RestFtpDaemon

  # Queue that stores all the Jobs waiting to be processed or fully processed
  class Counters
    attr_reader :stats

    if Settings.newrelic_enabled?
      include ::NewRelic::Agent::Instrumentation::ControllerInstrumentation
    end

    def initialize
      @stats = {}
      @mutex_stats = Mutex.new
    end

    def set group, name, value
      @mutex_stats.synchronize do
        @stats[group] ||= {}
        @stats[group][name] = value
      end
    end

    def get group, name
      @mutex_stats.synchronize do
        @stats[group][name] if @stats[group].is_a? Hash
      end
    end

    def add group, name, value
      @mutex_stats.synchronize do
        @stats[group] ||= {}
        @stats[group][name] ||= 0
        @stats[group][name] += value
      end
    end

    def increment group, name
      add group, name, 1
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rest-ftp-daemon-0.250.5 lib/rest-ftp-daemon/counters.rb
rest-ftp-daemon-0.250.4 lib/rest-ftp-daemon/counters.rb
rest-ftp-daemon-0.250.3 lib/rest-ftp-daemon/counters.rb