MCPcopy Index your code
hub / github.com/aws-samples/serverless-go-demo

github.com/aws-samples/serverless-go-demo @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
80 symbols 229 edges 20 files 13 documented · 16%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Serverless Go Demo

build codecov

Architecture diagram

This is a simple serverless application built in Golang. It consists of an API Gateway backed by four Lambda functions and a DynamoDB table for storage.

This single project will create five different binaries, one for each Lambda function. It uses an hexagonal architecture pattern to decouple the entry points, from the main domain logic, the storage component, and the event bus component.

🏗️ Deployment and testing

Requirements

Commands

You can use the following commands at the root of this repository to test, build, and deploy this project:

# Run unit tests
make tests-unit

# Compile and prepare Lambda functions
make build

# Deploy the functions on AWS
make deploy

# Run integration tests against the API in the cloud
make tests-integ

Load Test

Artillery is used to make 300 requests / second for 10 minutes to our API endpoints. You can run this with the following command:

make tests-load

CloudWatch Logs Insights

Using this CloudWatch Logs Insights query you can analyse the latency of the requests made to the Lambda functions.

The query separates cold starts from other requests and then gives you p50, p90 and p99 percentiles.

The times bellow were obtained while running the sample code with 128MB of RAM and arm64 architecture.

filter @type="REPORT"
| fields greatest(@initDuration, 0) + @duration as duration, ispresent(@initDuration) as coldStart
| stats count(*) as count, pct(duration, 50) as p50, pct(duration, 90) as p90, pct(duration, 99) as p99, max(duration) as max by coldStart

Load Test Results

👀 With other languages

You can find implementations of this project in other languages here:

Security

See CONTRIBUTING for more information.

License

This library is licensed under the MIT-0 License. See the LICENSE file.

Extension points exported contracts — how you extend this code

Bus (Interface)
(no doc) [5 implementers]
types/bus.go
Store (Interface)
(no doc) [4 implementers]
types/store.go

Core symbols most depended-on inside this repo

errResponse
called by 11
handlers/apigateway.go
AllProducts
called by 7
domain/products.go
NewProductsDomain
called by 6
domain/products.go
All
called by 4
types/store.go
NewDynamoDBStore
called by 4
store/dynamodb.go
GetProduct
called by 4
domain/products.go
NewAPIGatewayV2Handler
called by 4
handlers/apigateway.go
response
called by 4
handlers/apigateway.go

Shape

Method 33
Function 30
Struct 15
Interface 2

Languages

Go100%

Modules by API surface

types/mocks/mock_store.go12 symbols
handlers/apigateway.go8 symbols
integration-testing/integration_test.go7 symbols
store/memory.go6 symbols
store/dynamodb.go6 symbols
handlers/dynamodb.go6 symbols
domain/products_test.go6 symbols
domain/products.go6 symbols
types/store.go5 symbols
types/bus.go4 symbols
bus/event_bridge.go4 symbols
domain/products_stream.go3 symbols

For agents

$ claude mcp add serverless-go-demo \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact