Skip to content

bored-engineer/lambda-partialbatch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lambda-partialbatch Go Reference

Support for AWS Lambda's Partial Batch Response for DynamoDB, Kinesis and SQS in Golang

Example

package main

import (
	"context"
	"log"

	"github.com/aws/aws-lambda-go/events"
	"github.com/aws/aws-lambda-go/lambda"
	partialbatch "github.com/bored-engineer/lambda-partialbatch"
)

func handler(ctx context.Context, msg events.SQSMessage) error {
	// TODO: Some processing that could fail
	return nil
}

func main() {
	// Process batches of SQS messages
	lambda.Start(partialbatch.SQS(
		handler,
		// Recover from any panics, treating as a failed record
		partialbatch.WithRecovery(true),
		// For FIFO queues, halt after the first failure
		partialbatch.WithHalt(true),
		// Log any errors for debugging/alerting
		partialbatch.WithErrorCallback(func(_ context.Context, itemIdentifier string, err error) {
			log.Printf("failed to process SQS message %q: %s", itemIdentifier, err)
		}),
	))
}

About

Support for AWS Lambda's Partial Batch Response in Golang

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages