O'Reilly logo

Serverless Design Patterns and Best Practices by Brian Zambrano

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Batch layer

Whereas our speed layer is only interacting with DynamoDB, our batch layer will just be interacting with S3. There are two distinct types of functions in this layer—the functions that respond to S3 objects that arrive from Firehose, and functions that respond to S3 objects coming from Lambda functions. There isn't all that much difference, but it's important to point out the two different categories.

The following code block, taken from handler.py, shows the application code that comprises our batch layer:

def _get_bucket_and_key_from_event(event):     record = event['Records'][0]    s3 = record['s3']     bucket = s3['bucket']['name']     key = s3['object']['key']     return (bucket, key)def minute(event, context): """Process an S3 object uploaded ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required