lib/fluent/plugin/in_sql.rb in fluent-plugin-sql-0.3.0 vs lib/fluent/plugin/in_sql.rb in fluent-plugin-sql-0.4.0

- old
+ new

@@ -148,11 +148,11 @@ end SKIP_TABLE_REGEXP = /\Aschema_migrations\Z/i def start - @state_store = StateStore.new(@state_file) + @state_store = @state_file.nil? ? MemoryStateStore.new : StateStore.new(@state_file) config = { :adapter => @adapter, :host => @host, :port => @port, @@ -233,10 +233,12 @@ end end class StateStore 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 @@ -255,9 +257,22 @@ def update! File.open(@path, 'w') {|f| f.write YAML.dump(@data) } + end + end + + class MemoryStateStore + def initialize + @data = {} + end + + def last_records + @data['last_records'] ||= {} + end + + def update! end end end end