To create a Kinesis Stream reactor that subscribes via an EventSourceMapping, use the NewKinesisReactor constructor as in:
import (
awsLambdaEvents "github.com/aws/aws-lambda-go/events"
spartaArchetype "github.com/mweagle/Sparta/v3/archetype"
)
// KinesisStream reactor function
func reactorFunc(ctx context.Context,
kinesisEvent awsLambdaEvents.KinesisEvent) (interface{}, error) {
logger, _ := ctx.Value(sparta.ContextKeyRequestLogger).(*zerolog.Logger)
logger.Info().
Interface("Event", kinesisEvent).
Msg("Kinesis Event")
return "Hello World 👋. Welcome to AWS Lambda! 🙌🎉🍾", nil
}
func main() {
// ...
handler := spartaArchetype.KinesisReactorFunc(reactorFunc)
lambdaFn, lambdaFnErr := spartaArchetype.NewKinesisReactor(handler,
"KINESIS_STREAM_ARN_OR_CLOUDFORMATION_REF_VALUE",
"TRIM_HORIZON",
10,
nil)
}