cloudwatch_events

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 30, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context struct {
	Context context.Context
	Event   events.CloudWatchEvent
}

func (*Context) Bind

func (c *Context) Bind(v interface{}) error

type HandlerFunc

type HandlerFunc func(c *Context) error

func (HandlerFunc) Middleware

func (hf HandlerFunc) Middleware(middleware ...Middleware) HandlerFunc

Apply middleware to the handler func.

Middleware is called in the order it is given to this function.

func (HandlerFunc) Start

func (hf HandlerFunc) Start()

func (HandlerFunc) ToLambdaHandler

func (hf HandlerFunc) ToLambdaHandler() func(ctx context.Context, event events.CloudWatchEvent) error

Get the AWS Lambda handler of the handler func.

Useful if you need to call AWS lambda.Start(...) directly, not required in most cases.

type Middleware

type Middleware func(h HandlerFunc) HandlerFunc

func CorrelationIDMiddleware

func CorrelationIDMiddleware() Middleware

Middleware to get or attach a correlation ID to the event, useful for tracing requests through distributed systems if it is passed along in further requests. You can also access the correlation ID directly in your handlers and middlewares by calling log.CorrelationIDFromContext(c.Context).

Uses the CloudWatch Event ID as the Correlation ID. If for some reason this is not present, a new correlation ID will be created.

If used with the LoggerMiddleware, Correlation IDs are logged in each message. To ensure logs have correlation ID field, this middleware should be called first.

func LoggerMiddleware

func LoggerMiddleware(w io.Writer, fields map[string]string) Middleware

Middleware to configure a logger in the context.Context.

The middleware logs on each event handled, and on errors. In addition to the default log messages, you can access the logger in your handlers/middleware by calling log.LoggerFromContext(c.Context). The logger we use is github.com/rs/zerolog

w io.Writer is the log output, for example os.Stdout field map[string]string is a list of key value fields to include in each log message

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL