Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Error ¶
type Error struct { StatusCode int64 // contains filtered or unexported fields }
Error wraps an error message with a status code.
type Invoker ¶
type Invoker struct { MutateInput func(*lambda.InvokeInput) error MutateOutput func(*lambda.InvokeOutput) error // contains filtered or unexported fields }
Invoker is a wrapper around the aws lambda invoker implementation. It provides a convenient layer for middleware, as well as exposing a simpler method to invoke a lambda function with.
func New ¶
func New(li LambdaInvoker, arn string, opts ...Option) *Invoker
New initializes an Invoker with the options passed.
func (*Invoker) Invoke ¶
func (i *Invoker) Invoke(ctx context.Context, body json.RawMessage, opts ...awsreq.Option) (json.RawMessage, error)
Invoke _invokes_ the lambda function passing body as the InvokeInput.Payload and returning the InvokeOutput.Payload as the result. If InvokeOutput contains a FunctionError an Error is returned, wrapping the status code. By default lambda functions are invoked as a 'RequestResponse', but input mutators can be passed to change the InvocationType.
type LambdaInvoker ¶
type LambdaInvoker interface {
InvokeWithContext(context.Context, *lambda.InvokeInput, ...awsreq.Option) (*lambda.InvokeOutput, error)
}
LambdaInvoker abstracts the logic of invoking a lambda function behind an interface, this is to allow mocking the aws Lambda implementation.
type Option ¶
type Option func(*Invoker)
Option implementations can mutate the Invoker allowing configuration of how invokations of a lambda function should be performed.
func AsProcedure ¶
func AsProcedure(procedure string, unmarshalError func(json.RawMessage) error) Option
AsProcedure returns an option which can be passed when initializing an Invoker. If provided it will configure invocation to be performed as a call to the named procedure.