Class: Fluent::Plugin::SQLInput::StateStore
- Inherits:
-
Object
- Object
- Fluent::Plugin::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.
281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 |
# File 'lib/fluent/plugin/in_sql.rb', line 281 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
298 299 300 |
# File 'lib/fluent/plugin/in_sql.rb', line 298 def last_records @data['last_records'] ||= {} end |
#update! ⇒ Object
302 303 304 305 306 |
# File 'lib/fluent/plugin/in_sql.rb', line 302 def update! File.open(@path, 'w') {|f| f.write YAML.dump(@data) } end |