fluent-plugin-cloudwatch-ingest 0.1.15 → 0.1.16

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: 85240eae52c76e8a134b9ce96e0f323e75031950
4
- data.tar.gz: f0bde80bbec5883fd8a07a426c0ba6ed7e778e54
3
+ metadata.gz: 58a93e19106bcad0953826e4b33535464475fc60
4
+ data.tar.gz: 4792383889e4fa1aac9e450f44e27c2161e3eccd
5
5
  SHA512:
6
- metadata.gz: 51d80f4bd9d04a6cc4caf75742aa0db06a3a5d60da158e34651e4e7dd8ebfae0d4284f1ea70e9968909aaa14b3139f3462339be2cc7f8c830acae452ba71a12f
7
- data.tar.gz: 519f05819fda63aef3a6bafb39ccc287716455071bbc074e10103bf239a10817c92aeef9c351893b2a4e65f330acf1c07e56ad097a6865187ea4b17d9322e9ce
6
+ metadata.gz: 9d376ab39d539794646fb3d29348e68daafac482fe59251eb07cb745f03e820a3ebf37efe304a6630ce8fdcee1a66b46360ae3a72d3a67a75447f5c676cd31f3
7
+ data.tar.gz: 98a9976a3e97f37e5e123f78759a6bcbc4b57ff691db303dbffadb1b252003726d09e9dc5420b7eddbaee9ef20b4ace08377ab405e795e5816991dafd4136a26
@@ -2,7 +2,7 @@ module Fluent
2
2
  module Plugin
3
3
  module Cloudwatch
4
4
  module Ingest
5
- VERSION = '0.1.15'.freeze
5
+ VERSION = '0.1.16'.freeze
6
6
  end
7
7
  end
8
8
  end
@@ -146,7 +146,8 @@ module Fluent::Plugin
146
146
  # See if we have some stored state for this group and stream.
147
147
  # If we have then use the stored forward_token to pick up
148
148
  # from that point. Otherwise start from the start.
149
- stream_token = (state[group][stream] if state[group][stream])
149
+ stream_token =
150
+ (state.store[group][stream] if state.store[group][stream])
150
151
 
151
152
  begin
152
153
  loop do
@@ -163,7 +164,7 @@ module Fluent::Plugin
163
164
 
164
165
  # Once all events for this stream have been processed,
165
166
  # store the forward token
166
- state[group][stream] = response.next_forward_token
167
+ state.store[group][stream] = response.next_forward_token
167
168
  rescue => boom
168
169
  log.error("Unable to retrieve events for stream
169
170
  #{stream} in group #{group}: #{boom}")
@@ -186,13 +187,14 @@ module Fluent::Plugin
186
187
  end
187
188
  end
188
189
 
189
- class CloudwatchIngestInput::State < Hash
190
+ class CloudwatchIngestInput::State
190
191
  class LockFailed < RuntimeError; end
191
- attr_accessor :statefile
192
+ attr_accessor :statefile, :store
192
193
 
193
194
  def initialize(filepath, log)
194
195
  @filepath = filepath
195
196
  @log = log
197
+ @store = {}
196
198
 
197
199
  if File.exist?(statefile)
198
200
  self.statefile = Pathname.new(@filepath).open('r+')
@@ -212,14 +214,17 @@ module Fluent::Plugin
212
214
  lockstatus = statefile.flock(File::LOCK_EX | File::LOCK_NB)
213
215
  raise CloudwatchIngestInput::State::LockFailed if lockstatus == false
214
216
 
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
+ @store.merge!(Psych.safe_load(statefile.read, [Fluent::Plugin::CloudwatchIngestInput::State])) # rubocop:disable all
218
+ @log.info("Loaded #{@store.keys.size} log groups from #{statefile}")
217
219
  end
218
220
 
219
221
  # http://stackoverflow.com/questions/12821534/ruby-yaml-parser-by-passing-constructor
222
+ def encode_with(coder)
223
+ coder['store'] = @store
224
+ end
225
+
220
226
  def init_with(coder)
221
- @filepath = @filepath ? @filepath : coder['filepath']
222
- @log = @log ? @log : coder['log']
227
+ @store = coder['store']
223
228
  end
224
229
 
225
230
  def save
@@ -234,8 +239,8 @@ module Fluent::Plugin
234
239
  end
235
240
 
236
241
  def prune(log_groups)
237
- groups_before = keys.size
238
- delete_if { |k, _v| true unless log_groups.key?(k) }
242
+ groups_before = @store.keys.size
243
+ @store.delete_if { |k, _v| true unless log_groups.key?(k) }
239
244
  @log.info("Pruned #{groups_before - keys.size} keys from state file")
240
245
 
241
246
  # TODO: also prune streams as these are most likely to be transient
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.15
4
+ version: 0.1.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Pointer