From 0c6cfb370461e516662101ef68f089b5e9a8f18f Mon Sep 17 00:00:00 2001 From: Eric Fritz Date: Thu, 16 May 2019 16:09:56 -0500 Subject: [PATCH] Enable function to be created outside of StartHandler. --- lambda/entry.go | 4 +--- lambda/function.go | 4 ++++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lambda/entry.go b/lambda/entry.go index f55e61aa..581d9bcf 100644 --- a/lambda/entry.go +++ b/lambda/entry.go @@ -53,9 +53,7 @@ func StartHandler(handler Handler) { if err != nil { log.Fatal(err) } - function := new(Function) - function.handler = handler - err = rpc.Register(function) + err = rpc.Register(NewFunction(handler)) if err != nil { log.Fatal("failed to register handler function") } diff --git a/lambda/function.go b/lambda/function.go index 6a2e3373..50b6ac47 100644 --- a/lambda/function.go +++ b/lambda/function.go @@ -16,6 +16,10 @@ type Function struct { handler Handler } +func NewFunction(handler Handler) *Function { + return &Function{handler: handler} +} + func (fn *Function) Ping(req *messages.PingRequest, response *messages.PingResponse) error { *response = messages.PingResponse{} return nil