Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StartHandlerFunc ¶
func StartHandlerFunc[TIn any, TOut any, H HandlerFunc[TIn, TOut]](handler H, options ...Option)
StartHandlerFunc is the same as StartWithOptions except that it takes a generic input so that the function signature can be validated at compile time.
Types ¶
type Function
deprecated
type Function struct {
// contains filtered or unexported fields
}
Function struct which wrap the Handler
Deprecated: The Function type is public for the go1.x runtime internal use of the net/rpc package
func NewFunction
deprecated
func NewFunction(handler *handlerOptions) *Function
NewFunction which creates a Function with a given Handler
Deprecated: The Function type is public for the go1.x runtime internal use of the net/rpc package
func (*Function) Invoke ¶
func (fn *Function) Invoke(req *messages.InvokeRequest, response *messages.InvokeResponse) error
Invoke method try to perform a command given an InvokeRequest and an InvokeResponse
func (*Function) Ping ¶
func (fn *Function) Ping(req *messages.PingRequest, response *messages.PingResponse) error
Ping method which given a PingRequest and a PingResponse parses the PingResponse
type HandlerFunc ¶
HandlerFunc represents a valid input with two arguments and two returns as described by Start
type Option ¶
type Option func(*handlerOptions)
func WithContext ¶
WithContext is a HandlerOption that sets the base context for all invocations of the handler.
Usage:
lambda.StartWithOptions(
func (ctx context.Context) (string, error) {
return ctx.Value("foo"), nil
},
lambda.WithContext(context.WithValue(context.Background(), "foo", "bar"))
)
func WithEnableSIGTERM ¶
func WithEnableSIGTERM(callbacks ...func()) Option
WithEnableSIGTERM enables SIGTERM behavior within the Lambda platform on container spindown. SIGKILL will occur ~500ms after SIGTERM. Optionally, an array of callback functions to run on SIGTERM may be provided.
Usage:
lambda.StartWithOptions(
func (event any) (any, error) {
return event, nil
},
lambda.WithEnableSIGTERM(func() {
log.Print("function container shutting down...")
})
)
func WithSetEscapeHTML ¶
WithSetEscapeHTML sets the SetEscapeHTML argument on the underlying json encoder
Usage:
lambda.StartWithOptions(
func () (string, error) {
return "<html><body>hello!></body></html>", nil
},
lambda.WithSetEscapeHTML(true),
)
func WithSetIndent ¶
WithSetIndent sets the SetIndent argument on the underling json encoder
Usage:
lambda.StartWithOptions(
func (event any) (any, error) {
return event, nil
},
lambda.WithSetIndent(">"," "),
)