File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
integration-kinesis-to-lambda Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change
1
+ require 'aws-sdk'
2
+
3
+ def lambda_handler ( event :, context :)
4
+ event [ 'Records' ] . each do |record |
5
+ begin
6
+ puts "Processed Kinesis Event - EventID: #{ record [ 'eventID' ] } "
7
+ record_data = get_record_data_async ( record [ 'kinesis' ] )
8
+ puts "Record Data: #{ record_data } "
9
+ # TODO: Do interesting work based on the new data
10
+ rescue => err
11
+ $stderr. puts "An error occurred #{ err } "
12
+ raise err
13
+ end
14
+ end
15
+ puts "Successfully processed #{ event [ 'Records' ] . length } records."
16
+ end
17
+
18
+ def get_record_data_async ( payload )
19
+ data = Base64 . decode64 ( payload [ 'data' ] ) . force_encoding ( 'UTF-8' )
20
+ # Placeholder for actual async work
21
+ # You can use Ruby's asynchronous programming tools like async/await or fibers here.
22
+ return data
23
+ end
You can’t perform that action at this time.
0 commit comments