Skip to content

Commit fb4cb6f

Browse files
efritzbmoffatt
authored andcommitted
Enable function to be created outside of StartHandler. (#192)
1 parent 387ac89 commit fb4cb6f

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

lambda/entry.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,7 @@ func StartHandler(handler Handler) {
5353
if err != nil {
5454
log.Fatal(err)
5555
}
56-
function := new(Function)
57-
function.handler = handler
58-
err = rpc.Register(function)
56+
err = rpc.Register(NewFunction(handler))
5957
if err != nil {
6058
log.Fatal("failed to register handler function")
6159
}

lambda/function.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ type Function struct {
1616
handler Handler
1717
}
1818

19+
func NewFunction(handler Handler) *Function {
20+
return &Function{handler: handler}
21+
}
22+
1923
func (fn *Function) Ping(req *messages.PingRequest, response *messages.PingResponse) error {
2024
*response = messages.PingResponse{}
2125
return nil

0 commit comments

Comments
 (0)