class Fluent::AppdynamicsInput::StateStore
Class statestore
Public Class Methods
new(path,tag)
click to toggle source
# File lib/fluent/plugin/in_appdynamics.rb, line 40 def initialize(path,tag) require 'yaml' @path = path if File.exists?(@path) @data = YAML.load_file(@path) if @data == false || @data == [] # this happens if an users created an empty file accidentally @data = {} elsif !@data.is_a?(Hash) raise "state_file on #{@path.inspect} is invalid" end else @data = {} end end
Public Instance Methods
last_records(tag=nil)
click to toggle source
# File lib/fluent/plugin/in_appdynamics.rb, line 56 def last_records(tag=nil) return @data[tag] #@data['last_records'] ||= {} end
update_records(time, tag=nil)
click to toggle source
# File lib/fluent/plugin/in_appdynamics.rb, line 61 def update_records(time, tag=nil) @data[tag]=time pp @data File.open(@path, 'w') {|f| f.write YAML.dump(@data) } end