Class: Fluent::SQLInput::StateStore
- Inherits:
-
Object
- Object
- Fluent::SQLInput::StateStore
- Defined in:
- lib/fluent/plugin/in_sql.rb
Instance Method Summary collapse
-
#initialize(path) ⇒ StateStore
constructor
A new instance of StateStore.
- #last_records ⇒ Object
- #update! ⇒ Object
Constructor Details
#initialize(path) ⇒ StateStore
Returns a new instance of StateStore.
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 |
# File 'lib/fluent/plugin/in_sql.rb', line 243 def initialize(path) 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 |
Instance Method Details
#last_records ⇒ Object
260 261 262 |
# File 'lib/fluent/plugin/in_sql.rb', line 260 def last_records @data['last_records'] ||= {} end |
#update! ⇒ Object
264 265 266 267 268 |
# File 'lib/fluent/plugin/in_sql.rb', line 264 def update! File.open(@path, 'w') {|f| f.write YAML.dump(@data) } end |