diff --git a/examples/104-go1-16-pipeline.py b/examples/104-go1-16-pipeline.py index baeb94f2..4fa09bb7 100644 --- a/examples/104-go1-16-pipeline.py +++ b/examples/104-go1-16-pipeline.py @@ -15,7 +15,9 @@ def handler(msg): (kafka('input-topic') .handler('main', code="""package main -func Handler(m []byte) ([]byte, error) { +import "context" + +func Handler(ctx context.Context, m []byte) ([]byte, error) { return []byte("hi " + string(m)), nil }""", runtime='go1-16') .log() diff --git a/examples/104-go1-16-pipeline.yaml b/examples/104-go1-16-pipeline.yaml index ce50dc22..58bd874b 100644 --- a/examples/104-go1-16-pipeline.yaml +++ b/examples/104-go1-16-pipeline.yaml @@ -14,7 +14,9 @@ spec: code: |- package main - func Handler(m []byte) ([]byte, error) { + import "context" + + func Handler(ctx context.Context, m []byte) ([]byte, error) { return []byte("hi " + string(m)), nil } runtime: go1-16 diff --git a/runtimes/go1-16/handler.go b/runtimes/go1-16/handler.go index b574889e..abbbc083 100644 --- a/runtimes/go1-16/handler.go +++ b/runtimes/go1-16/handler.go @@ -1,5 +1,7 @@ package main -func Handler(m []byte) ([]byte, error) { +import "context" + +func Handler(background context.Context, m []byte) ([]byte, error) { return []byte("hi " + string(m)), nil } diff --git a/runtimes/go1-16/main.go b/runtimes/go1-16/main.go index 662077ec..d127d07e 100644 --- a/runtimes/go1-16/main.go +++ b/runtimes/go1-16/main.go @@ -1,6 +1,7 @@ package main import ( + "context" "io/ioutil" "net/http" ) @@ -15,7 +16,7 @@ func main() { if in, err := ioutil.ReadAll(r.Body); err != nil { return nil, err } else { - return Handler(in) + return Handler(context.Background(), in) } }() if err != nil {