Documentation ¶
Index ¶
Constants ¶
const ( // MaxDeadlineCushion is the timeout limit for deadline cushion. // Deadline cushion should not exceed lambda timeout // https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-limits.html // But setting the cushion at this limit effectively signals timeout // to post hooks by default MaxDeadlineCushion = 15 * time.Minute // DefaultTimeout is the default timeout limit // https://docs.aws.amazon.com/lambda/latest/dg/configuration-console.html DefaultTimeout = 3 * time.Second )
Variables ¶
This section is empty.
Functions ¶
func AddPostHook ¶
func AddPostHook(hook PostHook)
AddPostHook adds a post hook to be notified after execution
func AddPreHook ¶
func AddPreHook(hook PreHook)
AddPreHook adds a pre hook to be notified before execution
func Start ¶
func Start(handler interface{})
Start wraps the handler and starts the AWS lambda handler TODO: do we need this here?
func Wrap ¶
Wrap wraps the handler so the agent can intercept and record events Processes the handler according to the lambda rules below: Rules:
- handler must be a function
- handler may take between 0 and two arguments.
- if there are two arguments, the first argument must satisfy the "context.Context" interface.
- handler may return between 0 and two arguments.
- if there are two return values, the second argument must be an error.
- if there is one return value it must be an error.
Valid function signatures:
func () func () error func (TIn) error func () (TOut, error) func (TIn) (TOut, error) func (context.Context) error func (context.Context, TIn) error func (context.Context) (TOut, error) func (context.Context, TIn) (TOut, error)
Where "TIn" and "TOut" are types compatible with the "encoding/json" standard library. See https://golang.org/pkg/encoding/json/#Unmarshal for how deserialization behaves
Types ¶
type Option ¶ added in v0.1.0
type Option func() error
Option is an option to override defaults
func WithDeadlineCushion ¶ added in v0.1.0
WithDeadlineCushion overrides the default deadline cushion with given cushion
func WithPostHooks ¶ added in v0.1.0
WithPostHooks adds a list of post hooks in the order they are provided
func WithPreHooks ¶ added in v0.1.0
WithPreHooks adds a list of pre hooks in the order they are provided
func WithStarterFunc ¶ added in v0.1.0
WithStarterFunc overrides the default starter function with given function
type PostHook ¶
type PostHook interface { // AfterExecution executes once handler has executed AfterExecution( ctx context.Context, payload []byte, newPayload []byte, returnValue interface{}, errorValue interface{}, ) }
PostHook is a hook that's invoked after the handler has executed
type PreHook ¶
type PreHook interface { // BeforeExecution executes before the handler is executed // You may modify the context and/or payload at this point and the modified // context and payload will be passed on to the handler BeforeExecution( ctx context.Context, payload []byte, ) (context.Context, []byte) }
PreHook is a hook that's invoked before the handler is executed