Kinesis

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/archetype"
)
// KinesisStream reactor function
func reactorFunc(ctx context.Context,
  kinesisEvent awsLambdaEvents.KinesisEvent) (interface{}, error) {
  logger, _ := ctx.Value(sparta.ContextKeyRequestLogger).(*logrus.Entry)

  logger.WithFields(logrus.Fields{
    "Event": kinesisEvent,
  }).Info("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)
}