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.
313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 |
# File 'lib/fluent/plugin/in_sql.rb', line 313 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
330 331 332 |
# File 'lib/fluent/plugin/in_sql.rb', line 330 def last_records @data['last_records'] ||= {} end |
#update! ⇒ Object
334 335 336 337 338 |
# File 'lib/fluent/plugin/in_sql.rb', line 334 def update! File.open(@path, 'w') {|f| f.write YAML.dump(@data) } end |