-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Hackathon] Add ExampleMatcher (#11622)
* Add ExampleMatcher Add an example matcher that just counts events and outputs how many it saw. [skip changelog] * Remove excess whitespace * Add frozen_string_literal: true
- Loading branch information
Showing
2 changed files
with
89 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# frozen_string_literal: true | ||
|
||
module EventSummarizer | ||
class ExampleMatcher | ||
attr_reader :event_count | ||
|
||
def initialize | ||
@event_count = 0 | ||
end | ||
|
||
def handle_cloudwatch_event(_event) | ||
@event_count += 1 | ||
end | ||
|
||
def finish | ||
[ | ||
{ | ||
title: 'Processed some events', | ||
attributes: [ | ||
{ type: :event_count, description: "Processed #{event_count} event(s)" }, | ||
], | ||
}.tap do | ||
@event_count = 0 | ||
end, | ||
] | ||
end | ||
end | ||
end |