lkd-collection
Implement collections in a lkd stack (Lambda, Kinesis, DynamoDB).
How it works
The library implements two lambda functions: a producer and a consumer.
The producer is invoked by API Gateway, and its job is to publish collection-related events into a Kinesis Stream. The consumer is invoked by Kinesis, and its job is to build a materialized view of the collection into DynamoDB, taking as source the collection-related events created by the producer.
Application event format
The data
property can be any JSON document.
Collection events
Insert
API Gateway request body:
Resulting event sent to kinesis:
Resulting document inserted into dynamodb
Remove
API Gateway request body:
Resulting event sent to kinesis:
Resuling operation on dynamodb
Removal of document with document.id === elementId
.
Replace
API Gateway request body:
Resulting event sent to kinesis:
Resulting document inserted into dynamodb (replaces the existing one)
Example usage
/* Lambda function invoked by API Gateway */; var myCollection = name: "myCollectionName" kinesisStreamName: "myStream"; var handler = myCollectionproducer;
/* Lambda function invoked by Kinesis */; var myCollection = name: "myCollectionName" dynamodbTableName: "myTable"; var handler = myCollectionconsumer;