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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58a93e19106bcad0953826e4b33535464475fc60
|
4
|
+
data.tar.gz: 4792383889e4fa1aac9e450f44e27c2161e3eccd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d376ab39d539794646fb3d29348e68daafac482fe59251eb07cb745f03e820a3ebf37efe304a6630ce8fdcee1a66b46360ae3a72d3a67a75447f5c676cd31f3
|
7
|
+
data.tar.gz: 98a9976a3e97f37e5e123f78759a6bcbc4b57ff691db303dbffadb1b252003726d09e9dc5420b7eddbaee9ef20b4ace08377ab405e795e5816991dafd4136a26
|
@@ -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 =
|
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
|
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
|
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
|
-
@
|
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
|