Abstract AWS Lambda worker process
The github.com/go-nacelle/lambdabase
package provides an abstract AWS Lambda worker process.
This library supplies an abstract AWS Lambda RPC server process whose behavior can be be configured by implementing a Handler
interface. This interface wraps the handler defined by aws-lambda-go.
A Lambda server process is created by supplying a handler, described below, that controls its behavior.
|
|
A handler is a struct with an Init
and a Handle
method. The initialization method, like the process that runs it, that takes a context as a parameter adn returns an error value. The handle method of the base server takes a context object and the request payload as parameters and returns the response payload and an error value. The handle method of an event-specific server takes a context object, the request payload, and a logger populated with request and event identifiers as parameters and returns an error value. Return an error from either method signals a fatal error to the process that runs it.
The following example implements a handler that transforms a request value to upper-case.
|
|
This library comes with an example project that logs values received from a Kinesis stream.