cloud_watch_logs_poller 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4641f0ec6db0d868154a40d3ac82a525c00d57ad3b51297a2078341397455a85
4
- data.tar.gz: 486c7f3b586fbca8b079231df5f8bf979c5112aab5d04110a1ad983adee87570
3
+ metadata.gz: ed9924117eb330ef1c01a77a0647c92b4af1d5a5b0aaa35172808f3492d9e834
4
+ data.tar.gz: c43befd252982a7ea7e47fefa369df6b0f7eb5baa1a75e563564c2fdb8c2cba7
5
5
  SHA512:
6
- metadata.gz: 35d9d853b1ee7192cca26901b1f4ae8a72a21652c3935b090f7a98dc757f5abcd7903a65bdf480c5654c5c7596db7520331289383a2a2c92a7bab0840193a989
7
- data.tar.gz: f146bb5eb28ce03faf8198ceed4df78db65ea57e8d716d0096dc19b09b3c325c1405482fa91c5eaad5a8d319dfb209acc18e6fff787b5d88b93ba67c0b8e7332
6
+ metadata.gz: 39b5ea7367cb0f7a73e8094a13b90dd6279458a40e1e59532e988f51af2f022b0b1f3c51196eb7740fa17f024139236ea62c006c85bbc858346fbcbb13236ac0
7
+ data.tar.gz: 49dc2306411267e01d0b551a5fd33ddac222b2cccb5661198446047ad14c0d15790aa3490ee4318194f4c4505663303c1e52b34ecea5ec46ef1a4869ca9a5248
@@ -25,6 +25,6 @@ Gem::Specification.new do |spec|
25
25
  spec.add_dependency "aws-sdk-cloudwatchlogs", "~> 1.0"
26
26
 
27
27
  spec.add_development_dependency "bundler", "~> 2.0"
28
- spec.add_development_dependency "rake", "~> 10.0"
28
+ spec.add_development_dependency "rake", ">= 12.3.3"
29
29
  spec.add_development_dependency "rspec", "~> 3.0"
30
30
  end
@@ -4,7 +4,8 @@ module CloudWatchLogsPoller
4
4
  @client = Aws::CloudWatchLogs::Client.new
5
5
  @interval = interval
6
6
  @debug = debug
7
- @event_ids_by_timestamp = {}
7
+ @event_ids = Set.new
8
+ @max_timestamp = 0
8
9
  end
9
10
 
10
11
  def execute(log_group_name:, log_stream_name_prefix: nil, filter_pattern: nil, start_time: Time.now, &block)
@@ -24,28 +25,26 @@ module CloudWatchLogsPoller
24
25
  result.events.each do |event|
25
26
  timestamp = event.timestamp&.to_i
26
27
  event_id = event.event_id
28
+ @max_timestamp = timestamp if timestamp > @max_timestamp
27
29
 
28
30
  debug_log("timestamp = #{timestamp}")
29
31
 
30
- @event_ids_by_timestamp[timestamp] ||= Set.new
31
- next if @event_ids_by_timestamp[timestamp].include?(event_id)
32
+ next if @event_ids.include?(event_id)
32
33
 
33
- @event_ids_by_timestamp[timestamp] << event_id
34
+ @event_ids << event_id
34
35
  block.call(Event.convert_from_filtered_log_event(event))
35
36
  end
36
37
 
37
38
  debug_log(params)
38
39
 
39
- @event_ids_by_timestamp = get_latest_events_and_timestamp
40
40
  break unless result.next_token
41
41
 
42
42
  params[:next_token] = result.next_token
43
43
  end
44
44
 
45
- newest_timestamp = @event_ids_by_timestamp.keys.max
46
- params[:start_time] = newest_timestamp unless newest_timestamp.nil?
45
+ params[:start_time] = @max_timestamp + 1 if @max_timestamp > 0
47
46
  params[:next_token] = nil
48
- @event_ids_by_timestamp = {}
47
+ @event_ids = Set.new
49
48
 
50
49
  sleep(@interval)
51
50
  end
@@ -55,13 +54,6 @@ module CloudWatchLogsPoller
55
54
 
56
55
  private
57
56
 
58
- def get_latest_events_and_timestamp
59
- newest_timestamp = @event_ids_by_timestamp.keys.max
60
- return {} if newest_timestamp.nil?
61
-
62
- {newest_timestamp => @event_ids_by_timestamp[newest_timestamp]}
63
- end
64
-
65
57
  def debug_log(message)
66
58
  return unless @debug
67
59
 
@@ -1,3 +1,3 @@
1
1
  module CloudWatchLogsPoller
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloud_watch_logs_poller
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takahiro Ooishi
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-23 00:00:00.000000000 Z
11
+ date: 2020-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-cloudwatchlogs
@@ -42,16 +42,16 @@ dependencies:
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '10.0'
47
+ version: 12.3.3
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '10.0'
54
+ version: 12.3.3
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -89,7 +89,7 @@ files:
89
89
  homepage: https://github.com/taka0125/cloud_watch_logs_poller
90
90
  licenses: []
91
91
  metadata: {}
92
- post_install_message:
92
+ post_install_message:
93
93
  rdoc_options: []
94
94
  require_paths:
95
95
  - lib
@@ -105,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
105
105
  version: '0'
106
106
  requirements: []
107
107
  rubygems_version: 3.1.2
108
- signing_key:
108
+ signing_key:
109
109
  specification_version: 4
110
110
  summary: Polling Cloud Watch Logs
111
111
  test_files: []