diff --git a/client/grpc/proto/test.pb.go b/client/grpc/proto/test.pb.go index 400b06f..e899804 100644 --- a/client/grpc/proto/test.pb.go +++ b/client/grpc/proto/test.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0-devel +// protoc-gen-go v1.26.0-devel // protoc v3.6.1 // source: test.proto diff --git a/client/http/proto/github.pb.go b/client/http/proto/github.pb.go index 91c29e6..977b0fe 100644 --- a/client/http/proto/github.pb.go +++ b/client/http/proto/github.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0-devel +// protoc-gen-go v1.26.0-devel // protoc v3.6.1 // source: github.proto diff --git a/codec/generate.go b/codec/generate.go new file mode 100644 index 0000000..e19ae45 --- /dev/null +++ b/codec/generate.go @@ -0,0 +1,3 @@ +package grpc + +//go:generate protoc -I./proto -I. -I/home/vtolstov/.cache/go-path/pkg/mod/github.com/unistack-org/micro/v3@v3.2.24 -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 diff --git a/codec/proto/test.pb.go b/codec/proto/test.pb.go new file mode 100644 index 0000000..0140e30 --- /dev/null +++ b/codec/proto/test.pb.go @@ -0,0 +1,74 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.26.0-devel +// protoc v3.6.1 +// source: test.proto + +package pb + +import ( + codec "github.com/unistack-org/micro/v3/codec" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +var File_test_proto protoreflect.FileDescriptor + +var file_test_proto_rawDesc = []byte{ + 0x0a, 0x0a, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0a, 0x68, 0x65, + 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x1a, 0x11, 0x63, 0x6f, 0x64, 0x65, 0x63, 0x2f, + 0x66, 0x72, 0x61, 0x6d, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32, 0x38, 0x0a, 0x04, 0x54, + 0x65, 0x73, 0x74, 0x12, 0x30, 0x0a, 0x04, 0x43, 0x61, 0x6c, 0x6c, 0x12, 0x12, 0x2e, 0x6d, 0x69, + 0x63, 0x72, 0x6f, 0x2e, 0x63, 0x6f, 0x64, 0x65, 0x63, 0x2e, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x1a, + 0x12, 0x2e, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2e, 0x63, 0x6f, 0x64, 0x65, 0x63, 0x2e, 0x46, 0x72, + 0x61, 0x6d, 0x65, 0x22, 0x00, 0x42, 0x34, 0x5a, 0x32, 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, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, +} + +var file_test_proto_goTypes = []interface{}{ + (*codec.Frame)(nil), // 0: micro.codec.Frame +} +var file_test_proto_depIdxs = []int32{ + 0, // 0: helloworld.Test.Call:input_type -> micro.codec.Frame + 0, // 1: helloworld.Test.Call:output_type -> micro.codec.Frame + 1, // [1:2] is the sub-list for method output_type + 0, // [0:1] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_test_proto_init() } +func file_test_proto_init() { + if File_test_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_test_proto_rawDesc, + NumEnums: 0, + NumMessages: 0, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_test_proto_goTypes, + DependencyIndexes: file_test_proto_depIdxs, + }.Build() + File_test_proto = out.File + file_test_proto_rawDesc = nil + file_test_proto_goTypes = nil + file_test_proto_depIdxs = nil +} diff --git a/codec/proto/test.proto b/codec/proto/test.proto new file mode 100644 index 0000000..80a490a --- /dev/null +++ b/codec/proto/test.proto @@ -0,0 +1,12 @@ +syntax = "proto3"; + +package helloworld; +option go_package = "github.com/unistack-org/micro-tests/codec/proto;pb"; + +import "codec/frame.proto"; + + +service Test { + rpc Call(micro.codec.Frame) returns (micro.codec.Frame) {} +} + diff --git a/codec/proto/test_micro.pb.go b/codec/proto/test_micro.pb.go new file mode 100644 index 0000000..77a771b --- /dev/null +++ b/codec/proto/test_micro.pb.go @@ -0,0 +1,22 @@ +// 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" + codec "github.com/unistack-org/micro/v3/codec" +) + +func NewTestEndpoints() []*api.Endpoint { + return []*api.Endpoint{} +} + +type TestClient interface { + Call(ctx context.Context, req *codec.Frame, opts ...client.CallOption) (*codec.Frame, error) +} + +type TestServer interface { + Call(ctx context.Context, req *codec.Frame, rsp *codec.Frame) error +} diff --git a/codec/proto/test_micro_http.pb.go b/codec/proto/test_micro_http.pb.go new file mode 100644 index 0000000..4520dfa --- /dev/null +++ b/codec/proto/test_micro_http.pb.go @@ -0,0 +1,52 @@ +// 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" + codec "github.com/unistack-org/micro/v3/codec" + 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 *codec.Frame, opts ...client.CallOption) (*codec.Frame, error) { + rsp := &codec.Frame{} + 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 *codec.Frame, rsp *codec.Frame) 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 *codec.Frame, rsp *codec.Frame) 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/codec/segmentio/proto/test.pb.go b/codec/segmentio/proto/test.pb.go index 14f85ec..161a444 100644 --- a/codec/segmentio/proto/test.pb.go +++ b/codec/segmentio/proto/test.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0-devel +// protoc-gen-go v1.26.0-devel // protoc v3.6.1 // source: test.proto diff --git a/server/grpc/proto/test.pb.go b/server/grpc/proto/test.pb.go index bca25f0..bb6058f 100644 --- a/server/grpc/proto/test.pb.go +++ b/server/grpc/proto/test.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0-devel +// protoc-gen-go v1.26.0-devel // protoc v3.6.1 // source: test.proto diff --git a/server/http/proto/test.pb.go b/server/http/proto/test.pb.go index bd9e63f..18999fd 100644 --- a/server/http/proto/test.pb.go +++ b/server/http/proto/test.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.25.0-devel +// protoc-gen-go v1.26.0-devel // protoc v3.6.1 // source: test.proto