From 78ff02c0001b8fec07404586425d85300523ffda Mon Sep 17 00:00:00 2001 From: Igor Shishkin Date: Mon, 15 Jul 2024 09:06:05 +0300 Subject: [PATCH] Add generated protobufs as a workaround for improper generation (#4) Signed-off-by: Igor Shishkin --- .gitignore | 3 - proto/testservice.pb.go | 213 +++++++++++++++++++++++++++++++++++ proto/testservice_grpc.pb.go | 110 ++++++++++++++++++ 3 files changed, 323 insertions(+), 3 deletions(-) create mode 100644 proto/testservice.pb.go create mode 100644 proto/testservice_grpc.pb.go diff --git a/.gitignore b/.gitignore index 9155a3f..3b735ec 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,3 @@ # Go workspace file go.work - -# Protobuf compiled files -*.pb.go diff --git a/proto/testservice.pb.go b/proto/testservice.pb.go new file mode 100644 index 0000000..636501d --- /dev/null +++ b/proto/testservice.pb.go @@ -0,0 +1,213 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.34.2 +// protoc v5.27.1 +// source: testservice.proto + +package proto + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +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) +) + +type TestRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` +} + +func (x *TestRequest) Reset() { + *x = TestRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_testservice_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *TestRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TestRequest) ProtoMessage() {} + +func (x *TestRequest) ProtoReflect() protoreflect.Message { + mi := &file_testservice_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use TestRequest.ProtoReflect.Descriptor instead. +func (*TestRequest) Descriptor() ([]byte, []int) { + return file_testservice_proto_rawDescGZIP(), []int{0} +} + +func (x *TestRequest) GetMessage() string { + if x != nil { + return x.Message + } + return "" +} + +type TestResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` +} + +func (x *TestResponse) Reset() { + *x = TestResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_testservice_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *TestResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TestResponse) ProtoMessage() {} + +func (x *TestResponse) ProtoReflect() protoreflect.Message { + mi := &file_testservice_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use TestResponse.ProtoReflect.Descriptor instead. +func (*TestResponse) Descriptor() ([]byte, []int) { + return file_testservice_proto_rawDescGZIP(), []int{1} +} + +func (x *TestResponse) GetMessage() string { + if x != nil { + return x.Message + } + return "" +} + +var File_testservice_proto protoreflect.FileDescriptor + +var file_testservice_proto_rawDesc = []byte{ + 0x0a, 0x11, 0x74, 0x65, 0x73, 0x74, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x12, 0x05, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x27, 0x0a, 0x0b, 0x54, 0x65, + 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, + 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, + 0x61, 0x67, 0x65, 0x22, 0x28, 0x0a, 0x0c, 0x54, 0x65, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x32, 0x45, 0x0a, + 0x0b, 0x54, 0x65, 0x73, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x36, 0x0a, 0x0b, + 0x54, 0x65, 0x73, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x12, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x24, 0x5a, 0x22, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, + 0x6f, 0x6d, 0x2f, 0x74, 0x65, 0x72, 0x61, 0x6e, 0x2f, 0x67, 0x6f, 0x2d, 0x67, 0x72, 0x70, 0x63, + 0x74, 0x65, 0x73, 0x74, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, +} + +var ( + file_testservice_proto_rawDescOnce sync.Once + file_testservice_proto_rawDescData = file_testservice_proto_rawDesc +) + +func file_testservice_proto_rawDescGZIP() []byte { + file_testservice_proto_rawDescOnce.Do(func() { + file_testservice_proto_rawDescData = protoimpl.X.CompressGZIP(file_testservice_proto_rawDescData) + }) + return file_testservice_proto_rawDescData +} + +var file_testservice_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_testservice_proto_goTypes = []any{ + (*TestRequest)(nil), // 0: proto.TestRequest + (*TestResponse)(nil), // 1: proto.TestResponse +} +var file_testservice_proto_depIdxs = []int32{ + 0, // 0: proto.TestService.TestMessage:input_type -> proto.TestRequest + 1, // 1: proto.TestService.TestMessage:output_type -> proto.TestResponse + 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_testservice_proto_init() } +func file_testservice_proto_init() { + if File_testservice_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_testservice_proto_msgTypes[0].Exporter = func(v any, i int) any { + switch v := v.(*TestRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_testservice_proto_msgTypes[1].Exporter = func(v any, i int) any { + switch v := v.(*TestResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_testservice_proto_rawDesc, + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_testservice_proto_goTypes, + DependencyIndexes: file_testservice_proto_depIdxs, + MessageInfos: file_testservice_proto_msgTypes, + }.Build() + File_testservice_proto = out.File + file_testservice_proto_rawDesc = nil + file_testservice_proto_goTypes = nil + file_testservice_proto_depIdxs = nil +} diff --git a/proto/testservice_grpc.pb.go b/proto/testservice_grpc.pb.go new file mode 100644 index 0000000..e4783f9 --- /dev/null +++ b/proto/testservice_grpc.pb.go @@ -0,0 +1,110 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.4.0 +// - protoc v5.27.1 +// source: testservice.proto + +package proto + +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. +// Requires gRPC-Go v1.62.0 or later. +const _ = grpc.SupportPackageIsVersion8 + +const ( + TestService_TestMessage_FullMethodName = "/proto.TestService/TestMessage" +) + +// TestServiceClient is the client API for TestService 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 TestServiceClient interface { + TestMessage(ctx context.Context, in *TestRequest, opts ...grpc.CallOption) (*TestResponse, error) +} + +type testServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewTestServiceClient(cc grpc.ClientConnInterface) TestServiceClient { + return &testServiceClient{cc} +} + +func (c *testServiceClient) TestMessage(ctx context.Context, in *TestRequest, opts ...grpc.CallOption) (*TestResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(TestResponse) + err := c.cc.Invoke(ctx, TestService_TestMessage_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +// TestServiceServer is the server API for TestService service. +// All implementations must embed UnimplementedTestServiceServer +// for forward compatibility +type TestServiceServer interface { + TestMessage(context.Context, *TestRequest) (*TestResponse, error) + mustEmbedUnimplementedTestServiceServer() +} + +// UnimplementedTestServiceServer must be embedded to have forward compatible implementations. +type UnimplementedTestServiceServer struct { +} + +func (UnimplementedTestServiceServer) TestMessage(context.Context, *TestRequest) (*TestResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method TestMessage not implemented") +} +func (UnimplementedTestServiceServer) mustEmbedUnimplementedTestServiceServer() {} + +// UnsafeTestServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to TestServiceServer will +// result in compilation errors. +type UnsafeTestServiceServer interface { + mustEmbedUnimplementedTestServiceServer() +} + +func RegisterTestServiceServer(s grpc.ServiceRegistrar, srv TestServiceServer) { + s.RegisterService(&TestService_ServiceDesc, srv) +} + +func _TestService_TestMessage_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(TestRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(TestServiceServer).TestMessage(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: TestService_TestMessage_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(TestServiceServer).TestMessage(ctx, req.(*TestRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// TestService_ServiceDesc is the grpc.ServiceDesc for TestService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var TestService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "proto.TestService", + HandlerType: (*TestServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "TestMessage", + Handler: _TestService_TestMessage_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "testservice.proto", +}