From 2a6ba611ed077bdeddc246cffc9f0517d0fb9dc9 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Mon, 22 Mar 2021 00:10:15 +0300 Subject: [PATCH] regen with never protoc-gen-go Signed-off-by: Vasiliy Tolstov --- client/grpc/proto/test.pb.go | 5 -- client/http/proto/github.pb.go | 5 -- client/http/proto/github_micro_http.pb.go | 2 + codec/segmentio/generate.go | 4 +- codec/segmentio/proto/test.pb.go | 13 ++- codec/segmentio/proto/test.pb.micro.go | 92 --------------------- codec/segmentio/proto/test.proto | 1 + codec/segmentio/proto/test_grpc.pb.go | 90 -------------------- codec/segmentio/proto/test_micro.pb.go | 21 +++++ codec/segmentio/proto/test_micro_http.pb.go | 51 ++++++++++++ server/grpc/proto/test.pb.go | 5 -- server/http/proto/test.pb.go | 5 -- server/http/proto/test_micro_http.pb.go | 6 ++ 13 files changed, 90 insertions(+), 210 deletions(-) delete mode 100644 codec/segmentio/proto/test.pb.micro.go delete mode 100644 codec/segmentio/proto/test_grpc.pb.go create mode 100644 codec/segmentio/proto/test_micro.pb.go create mode 100644 codec/segmentio/proto/test_micro_http.pb.go diff --git a/client/grpc/proto/test.pb.go b/client/grpc/proto/test.pb.go index ce8db52..400b06f 100644 --- a/client/grpc/proto/test.pb.go +++ b/client/grpc/proto/test.pb.go @@ -7,7 +7,6 @@ package helloworld import ( - proto "github.com/golang/protobuf/proto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -21,10 +20,6 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -// This is a compile-time assertion that a sufficiently up-to-date version -// of the legacy proto package is being used. -const _ = proto.ProtoPackageIsVersion4 - type Request struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache diff --git a/client/http/proto/github.pb.go b/client/http/proto/github.pb.go index e055294..91c29e6 100644 --- a/client/http/proto/github.pb.go +++ b/client/http/proto/github.pb.go @@ -7,7 +7,6 @@ package pb import ( - proto "github.com/golang/protobuf/proto" _ "github.com/unistack-org/micro-proto/api" _ "github.com/unistack-org/micro-proto/openapiv2" protoreflect "google.golang.org/protobuf/reflect/protoreflect" @@ -23,10 +22,6 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -// This is a compile-time assertion that a sufficiently up-to-date version -// of the legacy proto package is being used. -const _ = proto.ProtoPackageIsVersion4 - type LookupUserReq struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache diff --git a/client/http/proto/github_micro_http.pb.go b/client/http/proto/github_micro_http.pb.go index 8dbe3d6..4fd6ba4 100644 --- a/client/http/proto/github_micro_http.pb.go +++ b/client/http/proto/github_micro_http.pb.go @@ -24,6 +24,8 @@ func (c *githubClient) LookupUser(ctx context.Context, req *LookupUserReq, opts errmap["default"] = &Error{} opts = append(opts, v3.ErrorMap(errmap), + ) + opts = append(opts, v3.Method("GET"), v3.Path("/users/{username}"), v3.Body(""), diff --git a/codec/segmentio/generate.go b/codec/segmentio/generate.go index 31c7626..e864960 100644 --- a/codec/segmentio/generate.go +++ b/codec/segmentio/generate.go @@ -1,3 +1,5 @@ package grpc -//go:generate protoc -I./internal/errors -I. --go-grpc_out=paths=source_relative:./internal/errors --go_out=paths=source_relative:./internal/errors --micro_out=paths=source_relative:./internal/errors internal/errors/errors.proto +//go:generate protoc -I./proto -I. -I/home/vtolstov/.cache/go-path/pkg/mod/github.com/unistack-org/micro-proto@v0.0.1 --go_out=paths=source_relative:./proto --micro_out=components=micro|http,debug=true,paths=source_relative:./proto proto/test.proto + +///go:generate protoc -I./proto -I. -I/home/vtolstov/devel/projects/unistack/micro/micro-proto --go_out=paths=source_relative:./proto --micro_out=components=micro|http,debug=true,paths=source_relative:./proto proto/test.proto diff --git a/codec/segmentio/proto/test.pb.go b/codec/segmentio/proto/test.pb.go index 77eafa7..14f85ec 100644 --- a/codec/segmentio/proto/test.pb.go +++ b/codec/segmentio/proto/test.pb.go @@ -4,10 +4,9 @@ // protoc v3.6.1 // source: test.proto -package helloworld +package pb import ( - proto "github.com/golang/protobuf/proto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -21,10 +20,6 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -// This is a compile-time assertion that a sufficiently up-to-date version -// of the legacy proto package is being used. -const _ = proto.ProtoPackageIsVersion4 - type Request struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -140,7 +135,11 @@ var file_test_proto_rawDesc = []byte{ 0x74, 0x12, 0x33, 0x0a, 0x04, 0x43, 0x61, 0x6c, 0x6c, 0x12, 0x13, 0x2e, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2e, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x3e, 0x5a, 0x3c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, + 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x75, 0x6e, 0x69, 0x73, 0x74, 0x61, 0x63, 0x6b, 0x2d, 0x6f, 0x72, + 0x67, 0x2f, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2d, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2f, 0x63, 0x6f, + 0x64, 0x65, 0x63, 0x2f, 0x73, 0x65, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x69, 0x6f, 0x2f, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/codec/segmentio/proto/test.pb.micro.go b/codec/segmentio/proto/test.pb.micro.go deleted file mode 100644 index 5fb8631..0000000 --- a/codec/segmentio/proto/test.pb.micro.go +++ /dev/null @@ -1,92 +0,0 @@ -// Code generated by protoc-gen-micro. DO NOT EDIT. -// source: test.proto - -package helloworld - -import ( - fmt "fmt" - proto "github.com/golang/protobuf/proto" - math "math" -) - -import ( - context "context" - api "github.com/unistack-org/micro/v3/api" - client "github.com/unistack-org/micro/v3/client" - server "github.com/unistack-org/micro/v3/server" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package - -// Reference imports to suppress errors if they are not otherwise used. -var _ api.Endpoint -var _ context.Context -var _ client.Option -var _ server.Option - -// Api Endpoints for Test service - -func NewTestEndpoints() []*api.Endpoint { - return []*api.Endpoint{} -} - -// Client API for Test service - -type TestService interface { - Call(ctx context.Context, req *Request, opts ...client.CallOption) (*Response, error) -} - -type testService struct { - c client.Client - name string -} - -func NewTestService(name string, c client.Client) TestService { - return &testService{ - c: c, - name: name, - } -} - -func (c *testService) Call(ctx context.Context, req *Request, opts ...client.CallOption) (*Response, error) { - rsp := &Response{} - err := c.c.Call(ctx, c.c.NewRequest(c.name, "Test.Call", req), rsp, opts...) - if err != nil { - return nil, err - } - return rsp, nil -} - -// Server API for Test service - -type TestHandler interface { - Call(context.Context, *Request, *Response) error -} - -func RegisterTestHandler(s server.Server, hdlr TestHandler, opts ...server.HandlerOption) error { - type test interface { - Call(ctx context.Context, req *Request, rsp *Response) error - } - type Test struct { - test - } - h := &testHandler{hdlr} - return s.Handle(s.NewHandler(&Test{h}, opts...)) -} - -type testHandler struct { - TestHandler -} - -func (h *testHandler) Call(ctx context.Context, req *Request, rsp *Response) error { - return h.TestHandler.Call(ctx, req, rsp) -} diff --git a/codec/segmentio/proto/test.proto b/codec/segmentio/proto/test.proto index 996dc51..d19c181 100644 --- a/codec/segmentio/proto/test.proto +++ b/codec/segmentio/proto/test.proto @@ -1,6 +1,7 @@ syntax = "proto3"; package helloworld; +option go_package = "github.com/unistack-org/micro-tests/codec/segmentio/proto;pb"; service Test { rpc Call(Request) returns (Response) {} diff --git a/codec/segmentio/proto/test_grpc.pb.go b/codec/segmentio/proto/test_grpc.pb.go deleted file mode 100644 index 95f6977..0000000 --- a/codec/segmentio/proto/test_grpc.pb.go +++ /dev/null @@ -1,90 +0,0 @@ -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. - -package helloworld - -import ( - context "context" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion6 - -// TestClient is the client API for Test service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -type TestClient interface { - Call(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error) -} - -type testClient struct { - cc grpc.ClientConnInterface -} - -func NewTestClient(cc grpc.ClientConnInterface) TestClient { - return &testClient{cc} -} - -func (c *testClient) Call(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error) { - out := new(Response) - err := c.cc.Invoke(ctx, "/helloworld.Test/Call", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// TestServer is the server API for Test service. -// All implementations must embed UnimplementedTestServer -// for forward compatibility -type TestServer interface { - Call(context.Context, *Request) (*Response, error) - mustEmbedUnimplementedTestServer() -} - -// UnimplementedTestServer must be embedded to have forward compatible implementations. -type UnimplementedTestServer struct { -} - -func (*UnimplementedTestServer) Call(context.Context, *Request) (*Response, error) { - return nil, status.Errorf(codes.Unimplemented, "method Call not implemented") -} -func (*UnimplementedTestServer) mustEmbedUnimplementedTestServer() {} - -func RegisterTestServer(s *grpc.Server, srv TestServer) { - s.RegisterService(&_Test_serviceDesc, srv) -} - -func _Test_Call_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(Request) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(TestServer).Call(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/helloworld.Test/Call", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(TestServer).Call(ctx, req.(*Request)) - } - return interceptor(ctx, in, info, handler) -} - -var _Test_serviceDesc = grpc.ServiceDesc{ - ServiceName: "helloworld.Test", - HandlerType: (*TestServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Call", - Handler: _Test_Call_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "test.proto", -} diff --git a/codec/segmentio/proto/test_micro.pb.go b/codec/segmentio/proto/test_micro.pb.go new file mode 100644 index 0000000..03fb52c --- /dev/null +++ b/codec/segmentio/proto/test_micro.pb.go @@ -0,0 +1,21 @@ +// Code generated by protoc-gen-micro +// source: test.proto +package pb + +import ( + context "context" + api "github.com/unistack-org/micro/v3/api" + client "github.com/unistack-org/micro/v3/client" +) + +func NewTestEndpoints() []*api.Endpoint { + return []*api.Endpoint{} +} + +type TestClient interface { + Call(ctx context.Context, req *Request, opts ...client.CallOption) (*Response, error) +} + +type TestServer interface { + Call(ctx context.Context, req *Request, rsp *Response) error +} diff --git a/codec/segmentio/proto/test_micro_http.pb.go b/codec/segmentio/proto/test_micro_http.pb.go new file mode 100644 index 0000000..9598cb8 --- /dev/null +++ b/codec/segmentio/proto/test_micro_http.pb.go @@ -0,0 +1,51 @@ +// Code generated by protoc-gen-micro +// source: test.proto +package pb + +import ( + context "context" + _ "github.com/unistack-org/micro-client-http/v3" + api "github.com/unistack-org/micro/v3/api" + client "github.com/unistack-org/micro/v3/client" + server "github.com/unistack-org/micro/v3/server" +) + +type testClient struct { + c client.Client + name string +} + +func NewTestClient(name string, c client.Client) TestClient { + return &testClient{c: c, name: name} +} + +func (c *testClient) Call(ctx context.Context, req *Request, opts ...client.CallOption) (*Response, error) { + rsp := &Response{} + err := c.c.Call(ctx, c.c.NewRequest(c.name, "Test.Call", req), rsp, opts...) + if err != nil { + return nil, err + } + return rsp, nil +} + +type testServer struct { + TestServer +} + +func (h *testServer) Call(ctx context.Context, req *Request, rsp *Response) error { + return h.TestServer.Call(ctx, req, rsp) +} + +func RegisterTestServer(s server.Server, sh TestServer, opts ...server.HandlerOption) error { + type test interface { + Call(ctx context.Context, req *Request, rsp *Response) error + } + type Test struct { + test + } + h := &testServer{sh} + for _, endpoint := range NewTestEndpoints() { + opts = append(opts, api.WithEndpoint(endpoint)) + } + return s.Handle(s.NewHandler(&Test{h}, opts...)) +} diff --git a/server/grpc/proto/test.pb.go b/server/grpc/proto/test.pb.go index 55de140..bca25f0 100644 --- a/server/grpc/proto/test.pb.go +++ b/server/grpc/proto/test.pb.go @@ -7,7 +7,6 @@ package helloworld import ( - proto "github.com/golang/protobuf/proto" _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" @@ -22,10 +21,6 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -// This is a compile-time assertion that a sufficiently up-to-date version -// of the legacy proto package is being used. -const _ = proto.ProtoPackageIsVersion4 - type Request struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache diff --git a/server/http/proto/test.pb.go b/server/http/proto/test.pb.go index a15f3aa..bd9e63f 100644 --- a/server/http/proto/test.pb.go +++ b/server/http/proto/test.pb.go @@ -7,7 +7,6 @@ package pb import ( - proto "github.com/golang/protobuf/proto" wrappers "github.com/golang/protobuf/ptypes/wrappers" _ "github.com/unistack-org/micro-proto/api" _ "github.com/unistack-org/micro-proto/openapiv2" @@ -24,10 +23,6 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -// This is a compile-time assertion that a sufficiently up-to-date version -// of the legacy proto package is being used. -const _ = proto.ProtoPackageIsVersion4 - type CallReq struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache diff --git a/server/http/proto/test_micro_http.pb.go b/server/http/proto/test_micro_http.pb.go index 80e2a34..b8ac6b6 100644 --- a/server/http/proto/test_micro_http.pb.go +++ b/server/http/proto/test_micro_http.pb.go @@ -24,6 +24,8 @@ func (c *testDoubleClient) CallDouble(ctx context.Context, req *CallReq, opts .. errmap["default"] = &Error{} opts = append(opts, v3.ErrorMap(errmap), + ) + opts = append(opts, v3.Method("POST"), v3.Path("/v1/testdouble/call/{name}"), v3.Body("*"), @@ -72,6 +74,8 @@ func (c *testClient) Call(ctx context.Context, req *CallReq, opts ...client.Call errmap["default"] = &Error{} opts = append(opts, v3.ErrorMap(errmap), + ) + opts = append(opts, v3.Method("POST"), v3.Path("/v1/test/call/{name}"), v3.Body("*"), @@ -89,6 +93,8 @@ func (c *testClient) CallError(ctx context.Context, req *CallReq1, opts ...clien errmap["default"] = &Error{} opts = append(opts, v3.ErrorMap(errmap), + ) + opts = append(opts, v3.Method("POST"), v3.Path("/v1/test/callerror/{name}"), v3.Body("*"),