fluent-plugin-cloudwatch-ingest 0.1.13 → 0.1.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: da60017312c17b0017c447f0dd8b7da2c4803457
4
- data.tar.gz: 9cfaec4d46eef8edd93155f00f7372759b3d4992
3
+ metadata.gz: fd7841c1d572b29c7281cb013d50891e7f516220
4
+ data.tar.gz: 2f17af0ba832d06aa21adff0ac5ddd5f0a619d6b
5
5
  SHA512:
6
- metadata.gz: fe01a1b5df0135ddcaf47e24b0c4f0c9cddcc628f92c051fb59a0ed718d629496296c73a0b342762ecfb337635b28d237f91812522d2a139a256f3ca5a6cf7e4
7
- data.tar.gz: 65de4d5cee4a6aa6f1422ba5f9b89bac09e714757fe39951db77a160a7f0d786ba3587b99f39fe13c008570ec96905c4eec74b173b820b767cfb0ee26aa3306e
6
+ metadata.gz: 1075e7279388aaa254e9ad81f5be0bbe1c0461d07022b9b1d095d4dc7450e0e08ceeb8b5a46dd5c7aa02b3760efe733ac05860f9e80eb70969a1e8584ad4bb00
7
+ data.tar.gz: 5f01bd527a5942c662449ccc1f06ada526d7ffb72185c6d92bfb24c0a02da7b537eb381dd2425c0f622aedeff31507f26a792c578f2dbbad481acc224ecc905f
@@ -2,7 +2,7 @@ module Fluent
2
2
  module Plugin
3
3
  module Cloudwatch
4
4
  module Ingest
5
- VERSION = '0.1.13'.freeze
5
+ VERSION = '0.1.14'.freeze
6
6
  end
7
7
  end
8
8
  end
@@ -3,7 +3,7 @@ require 'fluent/plugin/parser'
3
3
  require 'fluent/config/error'
4
4
  require 'aws-sdk'
5
5
  require 'pathname'
6
- require 'yaml'
6
+ require 'psych'
7
7
 
8
8
  module Fluent::Plugin
9
9
  class CloudwatchIngestInput < Fluent::Plugin::Input
@@ -191,32 +191,42 @@ module Fluent::Plugin
191
191
  attr_accessor :statefile
192
192
 
193
193
  def initialize(filepath, log)
194
+ @filepath = filepath
195
+ @log = log
196
+
194
197
  if File.exist?(statefile)
195
- self.statefile = Pathname.new(filepath).open('r+')
198
+ self.statefile = Pathname.new(@filepath).open('r+')
196
199
  else
197
- log.warn("No state file #{statefile} Creating a new one.")
200
+ @log.warn("No state file #{statefile} Creating a new one.")
198
201
  begin
199
- self.statefile = Pathname.new(filepath).open('w+')
202
+ self.statefile = Pathname.new(@filepath).open('w+')
200
203
  save
201
204
  rescue => boom
202
- log.error("Unable to create new state file #{statefile}: #{boom}")
205
+ @log.error("Unable to create new state file #{statefile}: #{boom}")
203
206
  end
204
207
  end
205
208
 
206
209
  # Attempt to obtain an exclusive flock on the file and raise and
207
210
  # exception if we can't
208
- log.info("Obtaining exclusive lock on state file #{statefile}")
211
+ @log.info("Obtaining exclusive lock on state file #{statefile}")
209
212
  lockstatus = statefile.flock(File::LOCK_EX | File::LOCK_NB)
210
213
  raise CloudwatchIngestInput::State::LockFailed if lockstatus == false
211
214
 
212
- merge!(YAML.safe_load(statefile.read))
213
- log.info("Loaded state for #{keys.size} log groups from #{statefile}")
215
+ merge!(Psych.safe_load(statefile.read, [Fluent::Plugin::CloudwatchIngestInput::State])) # rubocop:disable all
216
+ @log.info("Loaded state for #{keys.size} log groups from #{statefile}")
217
+ end
218
+
219
+ # http://stackoverflow.com/questions/12821534/ruby-yaml-parser-by-passing-constructor
220
+ def init_with(coder)
221
+ @filepath = coder['filepath']
222
+ @log = coder['log']
214
223
  end
215
224
 
216
225
  def save
217
226
  statefile.rewind
218
- statefile.write(YAML.dump(self))
219
- log.info("Saved state to #{statefile}")
227
+ statefile.write(Psych.dump(self))
228
+ @log.info("Saved state to #{statefile}")
229
+ statefile.rewind
220
230
  end
221
231
 
222
232
  def close
@@ -226,7 +236,7 @@ module Fluent::Plugin
226
236
  def prune(log_groups)
227
237
  groups_before = keys.size
228
238
  delete_if { |k, _v| true unless log_groups.key?(k) }
229
- log.info("Pruned #{groups_before - keys.size} keys from state file")
239
+ @log.info("Pruned #{groups_before - keys.size} keys from state file")
230
240
 
231
241
  # TODO: also prune streams as these are most likely to be transient
232
242
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-cloudwatch-ingest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.13
4
+ version: 0.1.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Pointer