From 877e93aa7c9c4be01d55450e73a1414557dfd123 Mon Sep 17 00:00:00 2001 From: Manfred Touron Date: Mon, 26 Dec 2016 16:20:46 +0100 Subject: [PATCH] Go-kit example: support services without unary calls --- .../{{.File.Package}}/gen/endpoints/endpoints.go.tmpl | 2 ++ .../{{.File.Package}}/gen/transports/grpc/grpc.go.tmpl | 3 ++- .../{{.File.Package}}/gen/transports/http/http.go.tmpl | 5 +++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/examples/go-kit/templates/{{.File.Package}}/gen/endpoints/endpoints.go.tmpl b/examples/go-kit/templates/{{.File.Package}}/gen/endpoints/endpoints.go.tmpl index d61d065..06d6207 100644 --- a/examples/go-kit/templates/{{.File.Package}}/gen/endpoints/endpoints.go.tmpl +++ b/examples/go-kit/templates/{{.File.Package}}/gen/endpoints/endpoints.go.tmpl @@ -10,7 +10,9 @@ import ( "github.com/go-kit/kit/endpoint" ) +var _ = endpoint.Chain var _ = fmt.Errorf +var _ = context.Background type StreamEndpoint func(server interface{}, req interface{}) (err error) diff --git a/examples/go-kit/templates/{{.File.Package}}/gen/transports/grpc/grpc.go.tmpl b/examples/go-kit/templates/{{.File.Package}}/gen/transports/grpc/grpc.go.tmpl index 4116453..2883cc0 100644 --- a/examples/go-kit/templates/{{.File.Package}}/gen/transports/grpc/grpc.go.tmpl +++ b/examples/go-kit/templates/{{.File.Package}}/gen/transports/grpc/grpc.go.tmpl @@ -16,7 +16,8 @@ import ( var _ = fmt.Errorf func MakeGRPCServer(ctx context.Context, endpoints endpoints.Endpoints) pb.{{.File.Package | title}}ServiceServer { - options := []grpctransport.ServerOption{} + var options []grpctransport.ServerOption + _ = options return &grpcServer{ {{range .Service.Method}} {{if or (.ClientStreaming) (.ServerStreaming)}} diff --git a/examples/go-kit/templates/{{.File.Package}}/gen/transports/http/http.go.tmpl b/examples/go-kit/templates/{{.File.Package}}/gen/transports/http/http.go.tmpl index fd541b1..0759a19 100644 --- a/examples/go-kit/templates/{{.File.Package}}/gen/transports/http/http.go.tmpl +++ b/examples/go-kit/templates/{{.File.Package}}/gen/transports/http/http.go.tmpl @@ -14,6 +14,11 @@ import ( endpoints "{{cat .GoPWD "/" .DestinationDir | nospace | clean}}/endpoints" ) +var _ = log.Printf +var _ = gokit_endpoint.Chain +var _ = httptransport.NewClient + + {{range .Service.Method}} {{if and (not .ServerStreaming) (not .ClientStreaming)}} func Make{{.Name}}Handler(ctx context.Context, svc pb.{{$file.Package | title}}ServiceServer, endpoint gokit_endpoint.Endpoint) *httptransport.Server {