modulepackage
0.0.0-20240919032739-eac131825870
Repository: https://github.com/nguyengg/golambda.git
Documentation: pkg.go.dev
# README
Go goodies for AWS Lambda
The main features of this module are the various wrappers around different AWS Lambda events, for example:
- Lambda Function URL, supporting both BUFFERED and RESPONSE_STREAM modes.
- API Gateway HTTP Integration with custom authoriser wrapper.
- DynamoDB Stream and other events.
Other utilities:
- Must provides
Must
,Must0
,Must2
, etc. to reduce typing outif a, err := someFunction(); err != nil
. - DynamoDB needs such as modeling version attribute, timestamps, utilities around making GetItem, PutItem, UpdateItem, and DeleteItem requests.
- Metrics measures arbitrary counters, timings, properties, and produce a JSON message describing about those metrics.
- Parse or log Smithy errors.
The module is very opinionated about how things are done because they work for me, but I'm always looking for feedback and suggestions.
Getting Started
The root module exposes a generic wrapper that attaches a metrics instance to the context:
# Download build.py to make it easier to build and update Lambda functions.
curl --proto '=https' -fo build.py https://raw.githubusercontent.com/nguyengg/golambda/main/build.py
package main
import (
"context"
"github.com/aws/aws-lambda-go/events"
"github.com/nguyengg/golambda"
"github.com/nguyengg/golambda/logsupport"
)
func main() {
golambda.StartHandlerFunc(func(ctx context.Context, request events.LambdaFunctionURLRequest) (events.LambdaFunctionURLResponse, error) {
// will set LambdaContext.AwsRequestID to log prefix and reset upon completion.
defer logsupport.SetUpGlobalLogger(ctx)()
return events.LambdaFunctionURLResponse{
StatusCode: 200,
Body: "hello, world!",
}, nil
})
}
# Packages
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Package yagl provides Yet-Another-Go-Logger interface, because there isn't enough of them in Go ecosystem already.
# Functions
StartHandlerFunc calls lambda.StartHandlerFunc passing the given handler after wrapping the context with a metrics instance that is used to populate basis statistics about the invocation.