Add entrypoint
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
package {{.File.Package}}_transportgrpc
|
||||
package {{.File.Package}}_grpctransport
|
||||
|
||||
{{$file := .File}}
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
context "golang.org/x/net/context"
|
||||
pb "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/{{.File.Package}}"
|
||||
grpctransport "github.com/go-kit/kit/transport/grpc"
|
||||
endpoint "github.com/moul/protoc-gen-gotemplate/examples/go-kit/{{.File.Package}}/gen/endpoints"
|
||||
endpoint "github.com/moul/protoc-gen-gotemplate/examples/go-kit/services/{{.File.Package}}/gen/endpoints"
|
||||
)
|
||||
|
||||
// avoid import errors
|
||||
@@ -25,7 +25,7 @@ func MakeGRPCServer(ctx context.Context, endpoints endpoint.Endpoints) pb.{{.Fil
|
||||
endpoints.{{.Name}}Endpoint,
|
||||
decode{{.Name}}Request,
|
||||
encode{{.Name}}Response,
|
||||
options,
|
||||
options...,
|
||||
),
|
||||
{{end}}
|
||||
{{end}}
|
||||
@@ -40,12 +40,12 @@ type grpcServer struct {
|
||||
}
|
||||
|
||||
{{range .Service.Method}}
|
||||
func (s *grpcServer) {{.Name}}(ctx context.Context, req *pb.{{.Name}}Request) (*pb.{{.Name}}Reply, error) {
|
||||
func (s *grpcServer) {{.Name}}(ctx context.Context, req *pb.{{.Name}}Request) (*pb.{{.Name}}Response, error) {
|
||||
_, rep, err := s.{{.Name | lower}}.ServeGRPC(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rep.(*pb.{{.Name}}Reply), nil
|
||||
return rep.(*pb.{{.Name}}Response), nil
|
||||
}
|
||||
|
||||
func decode{{.Name}}Request(ctx context.Context, grpcReq interface{}) (interface{}, error) {
|
||||
@@ -53,7 +53,7 @@ func decode{{.Name}}Request(ctx context.Context, grpcReq interface{}) (interface
|
||||
}
|
||||
|
||||
func encode{{.Name}}Response(ctx context.Context, response interface{}) (interface{}, error) {
|
||||
resp := response.(*pb.{{.Name}}Reply)
|
||||
resp := response.(*pb.{{.Name}}Response)
|
||||
return resp, nil
|
||||
}
|
||||
{{end}}
|
||||
|
Reference in New Issue
Block a user