Class: IbmAppconfigurationRubySdk::Metering::MeteringRecord

Inherits:
Object
  • Object
show all
Defined in:
lib/ibm_appconfiguration_ruby_sdk/metering.rb

Overview

Inner class for storing metering records Tracks count and latest evaluation time with thread-safe operations

Instance Method Summary collapse

Constructor Details

#initialize(time) ⇒ MeteringRecord

Initialize a new metering record

Parameters:

  • time (String)

    Initial evaluation time in ISO 8601 format



65
66
67
68
69
# File 'lib/ibm_appconfiguration_ruby_sdk/metering.rb', line 65

def initialize(time)
  @count = 1
  @latest_time = time
  @mutex = Mutex.new
end

Instance Method Details

#get_countInteger

Get the current count (thread-safe)

Returns:

  • (Integer)

    The evaluation count



86
87
88
# File 'lib/ibm_appconfiguration_ruby_sdk/metering.rb', line 86

def get_count
  @mutex.synchronize { @count }
end

#get_latest_timeString

Get the latest evaluation time (thread-safe)

Returns:

  • (String)

    The latest evaluation time



94
95
96
# File 'lib/ibm_appconfiguration_ruby_sdk/metering.rb', line 94

def get_latest_time
  @mutex.synchronize { @latest_time }
end

#increment(new_time) ⇒ Object

Increment the count and update latest time if newer

Parameters:

  • new_time (String)

    New evaluation time in ISO 8601 format



75
76
77
78
79
80
# File 'lib/ibm_appconfiguration_ruby_sdk/metering.rb', line 75

def increment(new_time)
  @mutex.synchronize do
    @count += 1
    @latest_time = new_time if new_time > @latest_time
  end
end