From 3aa3132caac094020051be7d11f68e975aa6b269 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Thu, 8 Oct 2020 12:37:06 +0300 Subject: [PATCH] fix proto types Signed-off-by: Vasiliy Tolstov --- errors_test.go | 17 ++++ generate.go | 2 +- .../{errors.pb.go => client_errors.pb.go} | 84 +++++++++---------- .../{errors.proto => client_errors.proto} | 2 +- internal/errors/errors.pb.micro.go | 21 ----- 5 files changed, 61 insertions(+), 65 deletions(-) create mode 100644 errors_test.go rename internal/errors/{errors.pb.go => client_errors.pb.go} (51%) rename internal/errors/{errors.proto => client_errors.proto} (80%) delete mode 100644 internal/errors/errors.pb.micro.go diff --git a/errors_test.go b/errors_test.go new file mode 100644 index 0000000..1a243b4 --- /dev/null +++ b/errors_test.go @@ -0,0 +1,17 @@ +package grpc_test + +import ( + "testing" + + pb "github.com/unistack-org/micro-client-grpc/internal/errors" + "google.golang.org/protobuf/types/known/anypb" +) + +func TestErrors(t *testing.T) { + any, err := anypb.New(&pb.Error{}) + if err != nil { + t.Fatal(err) + } + + t.Logf("cli any: %#+v\n", any) +} diff --git a/generate.go b/generate.go index 31c7626..1413b18 100644 --- a/generate.go +++ b/generate.go @@ -1,3 +1,3 @@ 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./internal/errors -I. --go_out=paths=source_relative:./internal/errors internal/errors/client_errors.proto diff --git a/internal/errors/errors.pb.go b/internal/errors/client_errors.pb.go similarity index 51% rename from internal/errors/errors.pb.go rename to internal/errors/client_errors.pb.go index bfc7596..dfd80ea 100644 --- a/internal/errors/errors.pb.go +++ b/internal/errors/client_errors.pb.go @@ -2,7 +2,7 @@ // versions: // protoc-gen-go v1.25.0-devel // protoc v3.6.1 -// source: errors.proto +// source: client_errors.proto package errors @@ -39,7 +39,7 @@ type Error struct { func (x *Error) Reset() { *x = Error{} if protoimpl.UnsafeEnabled { - mi := &file_errors_proto_msgTypes[0] + mi := &file_client_errors_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -52,7 +52,7 @@ func (x *Error) String() string { func (*Error) ProtoMessage() {} func (x *Error) ProtoReflect() protoreflect.Message { - mi := &file_errors_proto_msgTypes[0] + mi := &file_client_errors_proto_msgTypes[0] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -65,7 +65,7 @@ func (x *Error) ProtoReflect() protoreflect.Message { // Deprecated: Use Error.ProtoReflect.Descriptor instead. func (*Error) Descriptor() ([]byte, []int) { - return file_errors_proto_rawDescGZIP(), []int{0} + return file_client_errors_proto_rawDescGZIP(), []int{0} } func (x *Error) GetId() string { @@ -96,42 +96,42 @@ func (x *Error) GetStatus() string { return "" } -var File_errors_proto protoreflect.FileDescriptor +var File_client_errors_proto protoreflect.FileDescriptor -var file_errors_proto_rawDesc = []byte{ - 0x0a, 0x0c, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x25, - 0x6f, 0x72, 0x67, 0x2e, 0x75, 0x6e, 0x69, 0x73, 0x74, 0x61, 0x63, 0x6b, 0x2e, 0x6d, 0x69, 0x63, - 0x72, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x65, - 0x72, 0x72, 0x6f, 0x72, 0x73, 0x22, 0x5b, 0x0a, 0x05, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x0e, - 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, - 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x63, 0x6f, - 0x64, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x06, 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x42, 0x3b, 0x5a, 0x39, 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, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2d, 0x67, 0x72, 0x70, 0x63, 0x2f, - 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +var file_client_errors_proto_rawDesc = []byte{ + 0x0a, 0x13, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x19, 0x6f, 0x72, 0x67, 0x2e, 0x75, 0x6e, 0x69, 0x73, 0x74, + 0x61, 0x63, 0x6b, 0x2e, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x2e, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x73, + 0x22, 0x5b, 0x0a, 0x05, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, + 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x16, 0x0a, + 0x06, 0x64, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x64, + 0x65, 0x74, 0x61, 0x69, 0x6c, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x42, 0x3b, 0x5a, + 0x39, 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, 0x63, + 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2d, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, + 0x6e, 0x61, 0x6c, 0x2f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( - file_errors_proto_rawDescOnce sync.Once - file_errors_proto_rawDescData = file_errors_proto_rawDesc + file_client_errors_proto_rawDescOnce sync.Once + file_client_errors_proto_rawDescData = file_client_errors_proto_rawDesc ) -func file_errors_proto_rawDescGZIP() []byte { - file_errors_proto_rawDescOnce.Do(func() { - file_errors_proto_rawDescData = protoimpl.X.CompressGZIP(file_errors_proto_rawDescData) +func file_client_errors_proto_rawDescGZIP() []byte { + file_client_errors_proto_rawDescOnce.Do(func() { + file_client_errors_proto_rawDescData = protoimpl.X.CompressGZIP(file_client_errors_proto_rawDescData) }) - return file_errors_proto_rawDescData + return file_client_errors_proto_rawDescData } -var file_errors_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_errors_proto_goTypes = []interface{}{ - (*Error)(nil), // 0: org.unistack.micro.client.grpc.errors.Error +var file_client_errors_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_client_errors_proto_goTypes = []interface{}{ + (*Error)(nil), // 0: org.unistack.micro.errors.Error } -var file_errors_proto_depIdxs = []int32{ +var file_client_errors_proto_depIdxs = []int32{ 0, // [0:0] is the sub-list for method output_type 0, // [0:0] is the sub-list for method input_type 0, // [0:0] is the sub-list for extension type_name @@ -139,13 +139,13 @@ var file_errors_proto_depIdxs = []int32{ 0, // [0:0] is the sub-list for field type_name } -func init() { file_errors_proto_init() } -func file_errors_proto_init() { - if File_errors_proto != nil { +func init() { file_client_errors_proto_init() } +func file_client_errors_proto_init() { + if File_client_errors_proto != nil { return } if !protoimpl.UnsafeEnabled { - file_errors_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_client_errors_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Error); i { case 0: return &v.state @@ -162,18 +162,18 @@ func file_errors_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_errors_proto_rawDesc, + RawDescriptor: file_client_errors_proto_rawDesc, NumEnums: 0, NumMessages: 1, NumExtensions: 0, NumServices: 0, }, - GoTypes: file_errors_proto_goTypes, - DependencyIndexes: file_errors_proto_depIdxs, - MessageInfos: file_errors_proto_msgTypes, + GoTypes: file_client_errors_proto_goTypes, + DependencyIndexes: file_client_errors_proto_depIdxs, + MessageInfos: file_client_errors_proto_msgTypes, }.Build() - File_errors_proto = out.File - file_errors_proto_rawDesc = nil - file_errors_proto_goTypes = nil - file_errors_proto_depIdxs = nil + File_client_errors_proto = out.File + file_client_errors_proto_rawDesc = nil + file_client_errors_proto_goTypes = nil + file_client_errors_proto_depIdxs = nil } diff --git a/internal/errors/errors.proto b/internal/errors/client_errors.proto similarity index 80% rename from internal/errors/errors.proto rename to internal/errors/client_errors.proto index 5c48590..0117e1f 100644 --- a/internal/errors/errors.proto +++ b/internal/errors/client_errors.proto @@ -1,7 +1,7 @@ syntax = "proto3"; option go_package = "github.com/unistack-org/micro-client-grpc/internal/errors"; -package org.unistack.micro.client.grpc.errors; +package org.unistack.micro.errors; message Error { string id = 1; diff --git a/internal/errors/errors.pb.micro.go b/internal/errors/errors.pb.micro.go deleted file mode 100644 index f1bb9d4..0000000 --- a/internal/errors/errors.pb.micro.go +++ /dev/null @@ -1,21 +0,0 @@ -// Code generated by protoc-gen-micro. DO NOT EDIT. -// source: errors.proto - -package errors - -import ( - fmt "fmt" - proto "github.com/golang/protobuf/proto" - math "math" -) - -// 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