code review comments

This commit is contained in:
Dheeraj Mummareddy 2018-03-13 12:03:23 -04:00
parent 05a9c030c0
commit 3f9a5a254e
6 changed files with 33 additions and 18 deletions

View File

@ -18,21 +18,33 @@ Following are optimization katas you should be aware of while building a serverl
applications applications
* The Lean function * The Lean function
* Concise logic * Concise logic - Use functions to transform, not transport (utilize some of the
* Efficient/single purpose code integration available from the provider to transport), and make sure you read only
* ephemeral environment what you need
* Efficient/single purpose code - avoid conditional/routing logic and break down
into individual functions, avoid "fat"/monolithic functions and control the
dependencies in the function deployment package to reduce the load time for your
function
* ephemeral environment - Utilize container start for expensive initializations
* Eventful Invocations * Eventful Invocations
* Succinct payloads * Succinct payloads - Scrutinize the event as much as possible, and watch for
* resilient routing payload constraints (async - 128K)
* concurrent execution * resilient routing - Understand retry policies and leverage dead letter queues
(SQS or SNS for replays) and remember retries count as invocations
* concurrent execution - lambda thinks of it's scale in terms of concurrency and
its not request based/duration based. Lambda will spin up the number of instances
based on the request.
* Coordinated calls * Coordinated calls
* Decoupled via APIs * Decoupled via APIs - best practice to setup your application is to have API's as
* scale-matched downstream contracts that ensures separation of concerns
* secured * scale-matched downstream - make sure when Lambda is calling downstream
components, you are matching scale configuration to it (by specifying max
concurrency based on downstream services)
* secured - Always ask a question, do I need a VPC?
* Serviceful operations * Serviceful operations
* Automated operations * Automated - use automated tools to manage and maintain the stack
* monitored applications * monitored applications - use monitoring services to get holistic view of your
* Innovation mindset serverless applications
## Intent ## Intent
@ -84,7 +96,8 @@ database service also provided by Amazon.
## AWS lambda function implementation ## AWS lambda function implementation
AWS lambda SDK provides pre-defined interface `com.amazonaws.services.lambda.runtime [https://aws.amazon.com/sdk-for-java/](AWS Lambda SDK) provides pre-defined interface
`com.amazonaws.services.lambda.runtime
.RequestHandler` to implement our lambda function. .RequestHandler` to implement our lambda function.
```java ```java
@ -123,9 +136,9 @@ dependencies of the function.
Based on the configuration in `serverless.yml` serverless framework creates following Based on the configuration in `serverless.yml` serverless framework creates following
resources resources
* cloud formation stack for S3 (ServerlessDeploymentBucket) * CloudFormation stack for S3 (ServerlessDeploymentBucket)
* IAM Role (IamRoleLambdaExecution) * IAM Role (IamRoleLambdaExecution)
* cloud watch (log groups) * CloudWatch (log groups)
* API Gateway (ApiGatewayRestApi) * API Gateway (ApiGatewayRestApi)
* Lambda function * Lambda function
* DynamoDB collection * DynamoDB collection

View File

@ -6,7 +6,7 @@ import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBDocument;
import java.io.Serializable; import java.io.Serializable;
/** /**
* Address Object * Address class
* Created by dheeraj.mummarareddy on 3/4/18. * Created by dheeraj.mummarareddy on 3/4/18.
*/ */
@DynamoDBDocument @DynamoDBDocument

View File

@ -9,7 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable; import java.io.Serializable;
/** /**
* Person Request * Person class
* Created by dheeraj.mummarareddy on 3/4/18. * Created by dheeraj.mummarareddy on 3/4/18.
*/ */
@DynamoDBTable(tableName = "persons") @DynamoDBTable(tableName = "persons")

View File

@ -19,6 +19,7 @@ import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
/** /**
* Unit tests for FindPersonApiHandler
* Created by dheeraj.mummar on 3/5/18. * Created by dheeraj.mummar on 3/5/18.
*/ */
@RunWith(MockitoJUnitRunner.class) @RunWith(MockitoJUnitRunner.class)

View File

@ -19,6 +19,7 @@ import org.mockito.runners.MockitoJUnitRunner;
import static org.mockito.Mockito.*; import static org.mockito.Mockito.*;
/** /**
* Unit tests for SavePersonApiHandler
* Created by dheeraj.mummar on 3/4/18. * Created by dheeraj.mummar on 3/4/18.
*/ */
@RunWith(MockitoJUnitRunner.class) @RunWith(MockitoJUnitRunner.class)

View File

@ -33,7 +33,7 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
/** /**
* LambdaInfoApiHandlerTest * Unit tests for LambdaInfoApiHandler
*/ */
@RunWith(MockitoJUnitRunner.class) @RunWith(MockitoJUnitRunner.class)
public class LambdaInfoApiHandlerTest { public class LambdaInfoApiHandlerTest {