Skip to content

Instantly share code, notes, and snippets.

@pdeschen
Created November 8, 2017 14:31
Show Gist options
  • Save pdeschen/0114c49539e29027746636d655deccd2 to your computer and use it in GitHub Desktop.
Save pdeschen/0114c49539e29027746636d655deccd2 to your computer and use it in GitHub Desktop.
medium/serverless/S3EventHandler.java
@Override
public Void handleRequest(S3Event event, Context context) {
List<S3EventNotificationRecord> records = event.getRecords();
...
String bucket = record.getS3().getBucket().getName();
String key = decodeKey(record.getS3().getObject().getKey());
...
// fetch recording off S3 bucket
S3Object object = getS3Object(bucket, key);
MosResult mos = computeMos(object);
// store custom metrics
mCloudWatchMosMetricProducer.put(mos, CLOUDWATCH_METRICS_NAMESPACE);
// send kinesis event
mKinesisMosRecordProducer.put(mos, KINESIS_STREAM_NAME);
return null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment