From 3454f5bee7f100b5bfd13effa670601496d8a5af Mon Sep 17 00:00:00 2001 From: Bartosz Burclaf Date: Mon, 17 Sep 2018 15:19:29 +0200 Subject: [PATCH 1/2] remove context from stringsvc1 --- examples/stringsvc1/main.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/stringsvc1/main.go b/examples/stringsvc1/main.go index 7649a385d..8cbca37d2 100644 --- a/examples/stringsvc1/main.go +++ b/examples/stringsvc1/main.go @@ -14,21 +14,21 @@ import ( // StringService provides operations on strings. type StringService interface { - Uppercase(context.Context, string) (string, error) - Count(context.Context, string) int + Uppercase(string) (string, error) + Count(string) int } // stringService is a concrete implementation of StringService type stringService struct{} -func (stringService) Uppercase(_ context.Context, s string) (string, error) { +func (stringService) Uppercase(s string) (string, error) { if s == "" { return "", ErrEmpty } return strings.ToUpper(s), nil } -func (stringService) Count(_ context.Context, s string) int { +func (stringService) Count(s string) int { return len(s) } @@ -55,9 +55,9 @@ type countResponse struct { // Endpoints are a primary abstraction in go-kit. An endpoint represents a single RPC (method in our service interface) func makeUppercaseEndpoint(svc StringService) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (interface{}, error) { + return func(_ context.Context, request interface{}) (interface{}, error) { req := request.(uppercaseRequest) - v, err := svc.Uppercase(ctx, req.S) + v, err := svc.Uppercase(req.S) if err != nil { return uppercaseResponse{v, err.Error()}, nil } @@ -66,9 +66,9 @@ func makeUppercaseEndpoint(svc StringService) endpoint.Endpoint { } func makeCountEndpoint(svc StringService) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (interface{}, error) { + return func(_ context.Context, request interface{}) (interface{}, error) { req := request.(countRequest) - v := svc.Count(ctx, req.S) + v := svc.Count(req.S) return countResponse{v}, nil } } From 9957d51ab7f5212044a06e47d0d2845dba21e1bb Mon Sep 17 00:00:00 2001 From: Bartosz Burclaf Date: Mon, 17 Sep 2018 15:20:43 +0200 Subject: [PATCH 2/2] remove context from stringsvc2 --- examples/stringsvc2/transport.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/stringsvc2/transport.go b/examples/stringsvc2/transport.go index 297b3ffeb..3e892a9c9 100644 --- a/examples/stringsvc2/transport.go +++ b/examples/stringsvc2/transport.go @@ -9,7 +9,7 @@ import ( ) func makeUppercaseEndpoint(svc StringService) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (interface{}, error) { + return func(_ context.Context, request interface{}) (interface{}, error) { req := request.(uppercaseRequest) v, err := svc.Uppercase(req.S) if err != nil { @@ -20,7 +20,7 @@ func makeUppercaseEndpoint(svc StringService) endpoint.Endpoint { } func makeCountEndpoint(svc StringService) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (interface{}, error) { + return func(_ context.Context, request interface{}) (interface{}, error) { req := request.(countRequest) v := svc.Count(req.S) return countResponse{v}, nil