From d3094b36d0b0bebc02bdcaeb3168a80d701dbade Mon Sep 17 00:00:00 2001 From: Pascal Date: Mon, 18 Aug 2025 10:23:27 +0100 Subject: [PATCH 1/2] fix(#794): Wrapping codes.OK should not cause panic --- testing/testpb/interceptor_suite.go | 4 + testing/testpb/pingservice_test.go | 40 ++++++ testing/testpb/test.pb.go | 160 +++++++-------------- testing/testpb/test_grpc.pb.go | 207 ++++++++++++++++++++-------- 4 files changed, 242 insertions(+), 169 deletions(-) diff --git a/testing/testpb/interceptor_suite.go b/testing/testpb/interceptor_suite.go index 8cef650d..5aadd072 100644 --- a/testing/testpb/interceptor_suite.go +++ b/testing/testpb/interceptor_suite.go @@ -161,6 +161,10 @@ func (err *wrappedErrFields) Unwrap() error { } func (err *wrappedErrFields) Error() string { + if err.wrappedErr == nil { + return "" + } + // Ideally we print wrapped fields as well return err.wrappedErr.Error() } diff --git a/testing/testpb/pingservice_test.go b/testing/testpb/pingservice_test.go index 951721ca..e8c98400 100644 --- a/testing/testpb/pingservice_test.go +++ b/testing/testpb/pingservice_test.go @@ -5,10 +5,12 @@ package testpb import ( "context" + "errors" "fmt" "net" "testing" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "google.golang.org/grpc" "google.golang.org/grpc/codes" @@ -89,3 +91,41 @@ func TestPingServiceOnWire(t *testing.T) { default: } } + +func TestTestServicePing_PingError(t *testing.T) { + testCases := map[string]struct { + request *PingErrorRequest + err error + unwrapped error + msg string + }{ + "NotFound": { + request: &PingErrorRequest{ErrorCodeReturned: uint32(codes.NotFound), Value: "not found"}, + err: &wrappedErrFields{wrappedErr: status.Error(codes.NotFound, "Userspace error"), fields: []any{"error-field", "plop"}}, + unwrapped: status.Error(codes.NotFound, "Userspace error"), + msg: "rpc error: code = NotFound desc = Userspace error", + }, + "OK": { + request: &PingErrorRequest{ErrorCodeReturned: uint32(codes.OK), Value: "ok"}, + err: &wrappedErrFields{wrappedErr: nil, fields: []any{"error-field", "plop"}}, + unwrapped: nil, + msg: "", + }, + } + + for name, testCase := range testCases { + t.Run(name, func(t *testing.T) { + svc := &TestPingService{} + + _, err := svc.PingError(context.Background(), testCase.request) + require.Equal(t, testCase.err, err) + + var we *wrappedErrFields + ok := errors.As(err, &we) + require.True(t, ok) + + assert.Equal(t, testCase.unwrapped, we.Unwrap()) + assert.Equal(t, testCase.msg, we.Error()) + }) + } +} diff --git a/testing/testpb/test.pb.go b/testing/testpb/test.pb.go index fb07e993..2591594c 100644 --- a/testing/testpb/test.pb.go +++ b/testing/testpb/test.pb.go @@ -1,18 +1,17 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.5 +// protoc-gen-go v1.36.6 // protoc v6.31.1 // source: test.proto package testpb import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" unsafe "unsafe" - - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" ) const ( @@ -648,110 +647,55 @@ func (x *PingClientStreamResponse) GetCounter() int32 { var File_test_proto protoreflect.FileDescriptor -var file_test_proto_rawDesc = string([]byte{ - 0x0a, 0x0a, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x11, 0x74, 0x65, - 0x73, 0x74, 0x69, 0x6e, 0x67, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x70, 0x62, 0x2e, 0x76, 0x31, 0x22, - 0x12, 0x0a, 0x10, 0x50, 0x69, 0x6e, 0x67, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x22, 0x13, 0x0a, 0x11, 0x50, 0x69, 0x6e, 0x67, 0x45, 0x6d, 0x70, 0x74, 0x79, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x77, 0x0a, 0x0b, 0x50, 0x69, 0x6e, 0x67, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x22, 0x0a, - 0x0d, 0x73, 0x6c, 0x65, 0x65, 0x70, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x5f, 0x6d, 0x73, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, 0x73, 0x6c, 0x65, 0x65, 0x70, 0x54, 0x69, 0x6d, 0x65, 0x4d, - 0x73, 0x12, 0x2e, 0x0a, 0x13, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x5f, - 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x65, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x11, - 0x65, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x65, - 0x64, 0x22, 0x3e, 0x0a, 0x0c, 0x50, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x75, 0x6e, 0x74, - 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x65, - 0x72, 0x22, 0x7c, 0x0a, 0x10, 0x50, 0x69, 0x6e, 0x67, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x22, 0x0a, 0x0d, 0x73, - 0x6c, 0x65, 0x65, 0x70, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x5f, 0x6d, 0x73, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x05, 0x52, 0x0b, 0x73, 0x6c, 0x65, 0x65, 0x70, 0x54, 0x69, 0x6d, 0x65, 0x4d, 0x73, 0x12, - 0x2e, 0x0a, 0x13, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x5f, 0x72, 0x65, - 0x74, 0x75, 0x72, 0x6e, 0x65, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x11, 0x65, 0x72, - 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x65, 0x64, 0x22, - 0x43, 0x0a, 0x11, 0x50, 0x69, 0x6e, 0x67, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, - 0x75, 0x6e, 0x74, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x63, 0x6f, 0x75, - 0x6e, 0x74, 0x65, 0x72, 0x22, 0x7b, 0x0a, 0x0f, 0x50, 0x69, 0x6e, 0x67, 0x4c, 0x69, 0x73, 0x74, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x22, 0x0a, - 0x0d, 0x73, 0x6c, 0x65, 0x65, 0x70, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x5f, 0x6d, 0x73, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, 0x73, 0x6c, 0x65, 0x65, 0x70, 0x54, 0x69, 0x6d, 0x65, 0x4d, - 0x73, 0x12, 0x2e, 0x0a, 0x13, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x5f, - 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x65, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x11, - 0x65, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x65, - 0x64, 0x22, 0x42, 0x0a, 0x10, 0x50, 0x69, 0x6e, 0x67, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, - 0x6f, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x63, 0x6f, - 0x75, 0x6e, 0x74, 0x65, 0x72, 0x22, 0x7d, 0x0a, 0x11, 0x50, 0x69, 0x6e, 0x67, 0x53, 0x74, 0x72, - 0x65, 0x61, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, - 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, - 0x12, 0x22, 0x0a, 0x0d, 0x73, 0x6c, 0x65, 0x65, 0x70, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x5f, 0x6d, - 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, 0x73, 0x6c, 0x65, 0x65, 0x70, 0x54, 0x69, - 0x6d, 0x65, 0x4d, 0x73, 0x12, 0x2e, 0x0a, 0x13, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x63, 0x6f, - 0x64, 0x65, 0x5f, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x65, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x0d, 0x52, 0x11, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x74, 0x75, - 0x72, 0x6e, 0x65, 0x64, 0x22, 0x44, 0x0a, 0x12, 0x50, 0x69, 0x6e, 0x67, 0x53, 0x74, 0x72, 0x65, - 0x61, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, - 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, - 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x07, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x22, 0x83, 0x01, 0x0a, 0x17, 0x50, - 0x69, 0x6e, 0x67, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x22, 0x0a, 0x0d, - 0x73, 0x6c, 0x65, 0x65, 0x70, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x5f, 0x6d, 0x73, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x05, 0x52, 0x0b, 0x73, 0x6c, 0x65, 0x65, 0x70, 0x54, 0x69, 0x6d, 0x65, 0x4d, 0x73, - 0x12, 0x2e, 0x0a, 0x13, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x5f, 0x72, - 0x65, 0x74, 0x75, 0x72, 0x6e, 0x65, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x11, 0x65, - 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x65, 0x64, - 0x22, 0x34, 0x0a, 0x18, 0x50, 0x69, 0x6e, 0x67, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x53, 0x74, - 0x72, 0x65, 0x61, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, - 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x63, - 0x6f, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x32, 0xb7, 0x04, 0x0a, 0x0b, 0x54, 0x65, 0x73, 0x74, 0x53, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x58, 0x0a, 0x09, 0x50, 0x69, 0x6e, 0x67, 0x45, 0x6d, - 0x70, 0x74, 0x79, 0x12, 0x23, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x2e, 0x74, 0x65, - 0x73, 0x74, 0x70, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x69, 0x6e, 0x67, 0x45, 0x6d, 0x70, 0x74, - 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x24, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x69, - 0x6e, 0x67, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x70, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x69, 0x6e, - 0x67, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, - 0x12, 0x49, 0x0a, 0x04, 0x50, 0x69, 0x6e, 0x67, 0x12, 0x1e, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x69, - 0x6e, 0x67, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x70, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x69, 0x6e, - 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x69, - 0x6e, 0x67, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x70, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x69, 0x6e, - 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x58, 0x0a, 0x09, 0x50, - 0x69, 0x6e, 0x67, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x23, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x69, - 0x6e, 0x67, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x70, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x69, 0x6e, - 0x67, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x24, 0x2e, - 0x74, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x70, 0x62, 0x2e, 0x76, - 0x31, 0x2e, 0x50, 0x69, 0x6e, 0x67, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x57, 0x0a, 0x08, 0x50, 0x69, 0x6e, 0x67, 0x4c, 0x69, 0x73, - 0x74, 0x12, 0x22, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x2e, 0x74, 0x65, 0x73, 0x74, - 0x70, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x69, 0x6e, 0x67, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x23, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x2e, - 0x74, 0x65, 0x73, 0x74, 0x70, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x69, 0x6e, 0x67, 0x4c, 0x69, - 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x30, 0x01, 0x12, 0x5f, - 0x0a, 0x0a, 0x50, 0x69, 0x6e, 0x67, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x24, 0x2e, 0x74, - 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x70, 0x62, 0x2e, 0x76, 0x31, - 0x2e, 0x50, 0x69, 0x6e, 0x67, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x25, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x2e, 0x74, 0x65, 0x73, - 0x74, 0x70, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x69, 0x6e, 0x67, 0x53, 0x74, 0x72, 0x65, 0x61, - 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x28, 0x01, 0x30, 0x01, 0x12, - 0x6f, 0x0a, 0x10, 0x50, 0x69, 0x6e, 0x67, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x53, 0x74, 0x72, - 0x65, 0x61, 0x6d, 0x12, 0x2a, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x2e, 0x74, 0x65, - 0x73, 0x74, 0x70, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x69, 0x6e, 0x67, 0x43, 0x6c, 0x69, 0x65, - 0x6e, 0x74, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x2b, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x70, 0x62, - 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x69, 0x6e, 0x67, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x53, 0x74, - 0x72, 0x65, 0x61, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x28, 0x01, - 0x42, 0x0a, 0x5a, 0x08, 0x2e, 0x3b, 0x74, 0x65, 0x73, 0x74, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x33, -}) +const file_test_proto_rawDesc = "" + + "\n" + + "\n" + + "test.proto\x12\x11testing.testpb.v1\"\x12\n" + + "\x10PingEmptyRequest\"\x13\n" + + "\x11PingEmptyResponse\"w\n" + + "\vPingRequest\x12\x14\n" + + "\x05value\x18\x01 \x01(\tR\x05value\x12\"\n" + + "\rsleep_time_ms\x18\x02 \x01(\x05R\vsleepTimeMs\x12.\n" + + "\x13error_code_returned\x18\x03 \x01(\rR\x11errorCodeReturned\">\n" + + "\fPingResponse\x12\x14\n" + + "\x05value\x18\x01 \x01(\tR\x05value\x12\x18\n" + + "\acounter\x18\x02 \x01(\x05R\acounter\"|\n" + + "\x10PingErrorRequest\x12\x14\n" + + "\x05value\x18\x01 \x01(\tR\x05value\x12\"\n" + + "\rsleep_time_ms\x18\x02 \x01(\x05R\vsleepTimeMs\x12.\n" + + "\x13error_code_returned\x18\x03 \x01(\rR\x11errorCodeReturned\"C\n" + + "\x11PingErrorResponse\x12\x14\n" + + "\x05value\x18\x01 \x01(\tR\x05value\x12\x18\n" + + "\acounter\x18\x02 \x01(\x05R\acounter\"{\n" + + "\x0fPingListRequest\x12\x14\n" + + "\x05value\x18\x01 \x01(\tR\x05value\x12\"\n" + + "\rsleep_time_ms\x18\x02 \x01(\x05R\vsleepTimeMs\x12.\n" + + "\x13error_code_returned\x18\x03 \x01(\rR\x11errorCodeReturned\"B\n" + + "\x10PingListResponse\x12\x14\n" + + "\x05value\x18\x01 \x01(\tR\x05value\x12\x18\n" + + "\acounter\x18\x02 \x01(\x05R\acounter\"}\n" + + "\x11PingStreamRequest\x12\x14\n" + + "\x05value\x18\x01 \x01(\tR\x05value\x12\"\n" + + "\rsleep_time_ms\x18\x02 \x01(\x05R\vsleepTimeMs\x12.\n" + + "\x13error_code_returned\x18\x03 \x01(\rR\x11errorCodeReturned\"D\n" + + "\x12PingStreamResponse\x12\x14\n" + + "\x05value\x18\x01 \x01(\tR\x05value\x12\x18\n" + + "\acounter\x18\x02 \x01(\x05R\acounter\"\x83\x01\n" + + "\x17PingClientStreamRequest\x12\x14\n" + + "\x05value\x18\x01 \x01(\tR\x05value\x12\"\n" + + "\rsleep_time_ms\x18\x02 \x01(\x05R\vsleepTimeMs\x12.\n" + + "\x13error_code_returned\x18\x03 \x01(\rR\x11errorCodeReturned\"4\n" + + "\x18PingClientStreamResponse\x12\x18\n" + + "\acounter\x18\x01 \x01(\x05R\acounter2\xb7\x04\n" + + "\vTestService\x12X\n" + + "\tPingEmpty\x12#.testing.testpb.v1.PingEmptyRequest\x1a$.testing.testpb.v1.PingEmptyResponse\"\x00\x12I\n" + + "\x04Ping\x12\x1e.testing.testpb.v1.PingRequest\x1a\x1f.testing.testpb.v1.PingResponse\"\x00\x12X\n" + + "\tPingError\x12#.testing.testpb.v1.PingErrorRequest\x1a$.testing.testpb.v1.PingErrorResponse\"\x00\x12W\n" + + "\bPingList\x12\".testing.testpb.v1.PingListRequest\x1a#.testing.testpb.v1.PingListResponse\"\x000\x01\x12_\n" + + "\n" + + "PingStream\x12$.testing.testpb.v1.PingStreamRequest\x1a%.testing.testpb.v1.PingStreamResponse\"\x00(\x010\x01\x12o\n" + + "\x10PingClientStream\x12*.testing.testpb.v1.PingClientStreamRequest\x1a+.testing.testpb.v1.PingClientStreamResponse\"\x00(\x01B\n" + + "Z\b.;testpbb\x06proto3" var ( file_test_proto_rawDescOnce sync.Once diff --git a/testing/testpb/test_grpc.pb.go b/testing/testpb/test_grpc.pb.go index 9e5bb2cf..0c26aeb1 100644 --- a/testing/testpb/test_grpc.pb.go +++ b/testing/testpb/test_grpc.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.5.1 +// - protoc-gen-go-grpc v1.3.0 // - protoc v6.31.1 // source: test.proto @@ -8,7 +8,6 @@ package testpb import ( context "context" - grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -16,8 +15,8 @@ import ( // 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.64.0 or later. -const _ = grpc.SupportPackageIsVersion9 +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 const ( TestService_PingEmpty_FullMethodName = "/testing.testpb.v1.TestService/PingEmpty" @@ -35,9 +34,9 @@ type TestServiceClient interface { PingEmpty(ctx context.Context, in *PingEmptyRequest, opts ...grpc.CallOption) (*PingEmptyResponse, error) Ping(ctx context.Context, in *PingRequest, opts ...grpc.CallOption) (*PingResponse, error) PingError(ctx context.Context, in *PingErrorRequest, opts ...grpc.CallOption) (*PingErrorResponse, error) - PingList(ctx context.Context, in *PingListRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[PingListResponse], error) - PingStream(ctx context.Context, opts ...grpc.CallOption) (grpc.BidiStreamingClient[PingStreamRequest, PingStreamResponse], error) - PingClientStream(ctx context.Context, opts ...grpc.CallOption) (grpc.ClientStreamingClient[PingClientStreamRequest, PingClientStreamResponse], error) + PingList(ctx context.Context, in *PingListRequest, opts ...grpc.CallOption) (TestService_PingListClient, error) + PingStream(ctx context.Context, opts ...grpc.CallOption) (TestService_PingStreamClient, error) + PingClientStream(ctx context.Context, opts ...grpc.CallOption) (TestService_PingClientStreamClient, error) } type testServiceClient struct { @@ -49,9 +48,8 @@ func NewTestServiceClient(cc grpc.ClientConnInterface) TestServiceClient { } func (c *testServiceClient) PingEmpty(ctx context.Context, in *PingEmptyRequest, opts ...grpc.CallOption) (*PingEmptyResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(PingEmptyResponse) - err := c.cc.Invoke(ctx, TestService_PingEmpty_FullMethodName, in, out, cOpts...) + err := c.cc.Invoke(ctx, TestService_PingEmpty_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -59,9 +57,8 @@ func (c *testServiceClient) PingEmpty(ctx context.Context, in *PingEmptyRequest, } func (c *testServiceClient) Ping(ctx context.Context, in *PingRequest, opts ...grpc.CallOption) (*PingResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(PingResponse) - err := c.cc.Invoke(ctx, TestService_Ping_FullMethodName, in, out, cOpts...) + err := c.cc.Invoke(ctx, TestService_Ping_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -69,22 +66,20 @@ func (c *testServiceClient) Ping(ctx context.Context, in *PingRequest, opts ...g } func (c *testServiceClient) PingError(ctx context.Context, in *PingErrorRequest, opts ...grpc.CallOption) (*PingErrorResponse, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(PingErrorResponse) - err := c.cc.Invoke(ctx, TestService_PingError_FullMethodName, in, out, cOpts...) + err := c.cc.Invoke(ctx, TestService_PingError_FullMethodName, in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *testServiceClient) PingList(ctx context.Context, in *PingListRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[PingListResponse], error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - stream, err := c.cc.NewStream(ctx, &TestService_ServiceDesc.Streams[0], TestService_PingList_FullMethodName, cOpts...) +func (c *testServiceClient) PingList(ctx context.Context, in *PingListRequest, opts ...grpc.CallOption) (TestService_PingListClient, error) { + stream, err := c.cc.NewStream(ctx, &TestService_ServiceDesc.Streams[0], TestService_PingList_FullMethodName, opts...) if err != nil { return nil, err } - x := &grpc.GenericClientStream[PingListRequest, PingListResponse]{ClientStream: stream} + x := &testServicePingListClient{stream} if err := x.ClientStream.SendMsg(in); err != nil { return nil, err } @@ -94,54 +89,104 @@ func (c *testServiceClient) PingList(ctx context.Context, in *PingListRequest, o return x, nil } -// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. -type TestService_PingListClient = grpc.ServerStreamingClient[PingListResponse] +type TestService_PingListClient interface { + Recv() (*PingListResponse, error) + grpc.ClientStream +} + +type testServicePingListClient struct { + grpc.ClientStream +} + +func (x *testServicePingListClient) Recv() (*PingListResponse, error) { + m := new(PingListResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} -func (c *testServiceClient) PingStream(ctx context.Context, opts ...grpc.CallOption) (grpc.BidiStreamingClient[PingStreamRequest, PingStreamResponse], error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - stream, err := c.cc.NewStream(ctx, &TestService_ServiceDesc.Streams[1], TestService_PingStream_FullMethodName, cOpts...) +func (c *testServiceClient) PingStream(ctx context.Context, opts ...grpc.CallOption) (TestService_PingStreamClient, error) { + stream, err := c.cc.NewStream(ctx, &TestService_ServiceDesc.Streams[1], TestService_PingStream_FullMethodName, opts...) if err != nil { return nil, err } - x := &grpc.GenericClientStream[PingStreamRequest, PingStreamResponse]{ClientStream: stream} + x := &testServicePingStreamClient{stream} return x, nil } -// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. -type TestService_PingStreamClient = grpc.BidiStreamingClient[PingStreamRequest, PingStreamResponse] +type TestService_PingStreamClient interface { + Send(*PingStreamRequest) error + Recv() (*PingStreamResponse, error) + grpc.ClientStream +} + +type testServicePingStreamClient struct { + grpc.ClientStream +} + +func (x *testServicePingStreamClient) Send(m *PingStreamRequest) error { + return x.ClientStream.SendMsg(m) +} + +func (x *testServicePingStreamClient) Recv() (*PingStreamResponse, error) { + m := new(PingStreamResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} -func (c *testServiceClient) PingClientStream(ctx context.Context, opts ...grpc.CallOption) (grpc.ClientStreamingClient[PingClientStreamRequest, PingClientStreamResponse], error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - stream, err := c.cc.NewStream(ctx, &TestService_ServiceDesc.Streams[2], TestService_PingClientStream_FullMethodName, cOpts...) +func (c *testServiceClient) PingClientStream(ctx context.Context, opts ...grpc.CallOption) (TestService_PingClientStreamClient, error) { + stream, err := c.cc.NewStream(ctx, &TestService_ServiceDesc.Streams[2], TestService_PingClientStream_FullMethodName, opts...) if err != nil { return nil, err } - x := &grpc.GenericClientStream[PingClientStreamRequest, PingClientStreamResponse]{ClientStream: stream} + x := &testServicePingClientStreamClient{stream} return x, nil } -// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. -type TestService_PingClientStreamClient = grpc.ClientStreamingClient[PingClientStreamRequest, PingClientStreamResponse] +type TestService_PingClientStreamClient interface { + Send(*PingClientStreamRequest) error + CloseAndRecv() (*PingClientStreamResponse, error) + grpc.ClientStream +} + +type testServicePingClientStreamClient struct { + grpc.ClientStream +} + +func (x *testServicePingClientStreamClient) Send(m *PingClientStreamRequest) error { + return x.ClientStream.SendMsg(m) +} + +func (x *testServicePingClientStreamClient) CloseAndRecv() (*PingClientStreamResponse, error) { + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + m := new(PingClientStreamResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} // TestServiceServer is the server API for TestService service. // All implementations must embed UnimplementedTestServiceServer -// for forward compatibility. +// for forward compatibility type TestServiceServer interface { PingEmpty(context.Context, *PingEmptyRequest) (*PingEmptyResponse, error) Ping(context.Context, *PingRequest) (*PingResponse, error) PingError(context.Context, *PingErrorRequest) (*PingErrorResponse, error) - PingList(*PingListRequest, grpc.ServerStreamingServer[PingListResponse]) error - PingStream(grpc.BidiStreamingServer[PingStreamRequest, PingStreamResponse]) error - PingClientStream(grpc.ClientStreamingServer[PingClientStreamRequest, PingClientStreamResponse]) error + PingList(*PingListRequest, TestService_PingListServer) error + PingStream(TestService_PingStreamServer) error + PingClientStream(TestService_PingClientStreamServer) error mustEmbedUnimplementedTestServiceServer() } -// UnimplementedTestServiceServer must be embedded to have -// forward compatible implementations. -// -// NOTE: this should be embedded by value instead of pointer to avoid a nil -// pointer dereference when methods are called. -type UnimplementedTestServiceServer struct{} +// UnimplementedTestServiceServer must be embedded to have forward compatible implementations. +type UnimplementedTestServiceServer struct { +} func (UnimplementedTestServiceServer) PingEmpty(context.Context, *PingEmptyRequest) (*PingEmptyResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method PingEmpty not implemented") @@ -152,17 +197,16 @@ func (UnimplementedTestServiceServer) Ping(context.Context, *PingRequest) (*Ping func (UnimplementedTestServiceServer) PingError(context.Context, *PingErrorRequest) (*PingErrorResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method PingError not implemented") } -func (UnimplementedTestServiceServer) PingList(*PingListRequest, grpc.ServerStreamingServer[PingListResponse]) error { +func (UnimplementedTestServiceServer) PingList(*PingListRequest, TestService_PingListServer) error { return status.Errorf(codes.Unimplemented, "method PingList not implemented") } -func (UnimplementedTestServiceServer) PingStream(grpc.BidiStreamingServer[PingStreamRequest, PingStreamResponse]) error { +func (UnimplementedTestServiceServer) PingStream(TestService_PingStreamServer) error { return status.Errorf(codes.Unimplemented, "method PingStream not implemented") } -func (UnimplementedTestServiceServer) PingClientStream(grpc.ClientStreamingServer[PingClientStreamRequest, PingClientStreamResponse]) error { +func (UnimplementedTestServiceServer) PingClientStream(TestService_PingClientStreamServer) error { return status.Errorf(codes.Unimplemented, "method PingClientStream not implemented") } func (UnimplementedTestServiceServer) mustEmbedUnimplementedTestServiceServer() {} -func (UnimplementedTestServiceServer) testEmbeddedByValue() {} // 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 @@ -172,13 +216,6 @@ type UnsafeTestServiceServer interface { } func RegisterTestServiceServer(s grpc.ServiceRegistrar, srv TestServiceServer) { - // If the following call pancis, it indicates UnimplementedTestServiceServer was - // embedded by pointer and is nil. This will cause panics if an - // unimplemented method is ever invoked, so we test this at initialization - // time to prevent it from happening at runtime later due to I/O. - if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { - t.testEmbeddedByValue() - } s.RegisterService(&TestService_ServiceDesc, srv) } @@ -241,25 +278,73 @@ func _TestService_PingList_Handler(srv interface{}, stream grpc.ServerStream) er if err := stream.RecvMsg(m); err != nil { return err } - return srv.(TestServiceServer).PingList(m, &grpc.GenericServerStream[PingListRequest, PingListResponse]{ServerStream: stream}) + return srv.(TestServiceServer).PingList(m, &testServicePingListServer{stream}) +} + +type TestService_PingListServer interface { + Send(*PingListResponse) error + grpc.ServerStream +} + +type testServicePingListServer struct { + grpc.ServerStream } -// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. -type TestService_PingListServer = grpc.ServerStreamingServer[PingListResponse] +func (x *testServicePingListServer) Send(m *PingListResponse) error { + return x.ServerStream.SendMsg(m) +} func _TestService_PingStream_Handler(srv interface{}, stream grpc.ServerStream) error { - return srv.(TestServiceServer).PingStream(&grpc.GenericServerStream[PingStreamRequest, PingStreamResponse]{ServerStream: stream}) + return srv.(TestServiceServer).PingStream(&testServicePingStreamServer{stream}) +} + +type TestService_PingStreamServer interface { + Send(*PingStreamResponse) error + Recv() (*PingStreamRequest, error) + grpc.ServerStream } -// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. -type TestService_PingStreamServer = grpc.BidiStreamingServer[PingStreamRequest, PingStreamResponse] +type testServicePingStreamServer struct { + grpc.ServerStream +} + +func (x *testServicePingStreamServer) Send(m *PingStreamResponse) error { + return x.ServerStream.SendMsg(m) +} + +func (x *testServicePingStreamServer) Recv() (*PingStreamRequest, error) { + m := new(PingStreamRequest) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} func _TestService_PingClientStream_Handler(srv interface{}, stream grpc.ServerStream) error { - return srv.(TestServiceServer).PingClientStream(&grpc.GenericServerStream[PingClientStreamRequest, PingClientStreamResponse]{ServerStream: stream}) + return srv.(TestServiceServer).PingClientStream(&testServicePingClientStreamServer{stream}) } -// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. -type TestService_PingClientStreamServer = grpc.ClientStreamingServer[PingClientStreamRequest, PingClientStreamResponse] +type TestService_PingClientStreamServer interface { + SendAndClose(*PingClientStreamResponse) error + Recv() (*PingClientStreamRequest, error) + grpc.ServerStream +} + +type testServicePingClientStreamServer struct { + grpc.ServerStream +} + +func (x *testServicePingClientStreamServer) SendAndClose(m *PingClientStreamResponse) error { + return x.ServerStream.SendMsg(m) +} + +func (x *testServicePingClientStreamServer) Recv() (*PingClientStreamRequest, error) { + m := new(PingClientStreamRequest) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} // TestService_ServiceDesc is the grpc.ServiceDesc for TestService service. // It's only intended for direct use with grpc.RegisterService, From dcd9be55fa1aa55e778bddeccd99db5afca68d9e Mon Sep 17 00:00:00 2001 From: Pascal Date: Mon, 18 Aug 2025 11:39:40 +0100 Subject: [PATCH 2/2] revert proto --- testing/testpb/test.pb.go | 160 ++++++++++++++++--------- testing/testpb/test_grpc.pb.go | 207 ++++++++++----------------------- 2 files changed, 169 insertions(+), 198 deletions(-) diff --git a/testing/testpb/test.pb.go b/testing/testpb/test.pb.go index 2591594c..fb07e993 100644 --- a/testing/testpb/test.pb.go +++ b/testing/testpb/test.pb.go @@ -1,17 +1,18 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.36.6 +// protoc-gen-go v1.36.5 // protoc v6.31.1 // source: test.proto package testpb import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" unsafe "unsafe" + + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" ) const ( @@ -647,55 +648,110 @@ func (x *PingClientStreamResponse) GetCounter() int32 { var File_test_proto protoreflect.FileDescriptor -const file_test_proto_rawDesc = "" + - "\n" + - "\n" + - "test.proto\x12\x11testing.testpb.v1\"\x12\n" + - "\x10PingEmptyRequest\"\x13\n" + - "\x11PingEmptyResponse\"w\n" + - "\vPingRequest\x12\x14\n" + - "\x05value\x18\x01 \x01(\tR\x05value\x12\"\n" + - "\rsleep_time_ms\x18\x02 \x01(\x05R\vsleepTimeMs\x12.\n" + - "\x13error_code_returned\x18\x03 \x01(\rR\x11errorCodeReturned\">\n" + - "\fPingResponse\x12\x14\n" + - "\x05value\x18\x01 \x01(\tR\x05value\x12\x18\n" + - "\acounter\x18\x02 \x01(\x05R\acounter\"|\n" + - "\x10PingErrorRequest\x12\x14\n" + - "\x05value\x18\x01 \x01(\tR\x05value\x12\"\n" + - "\rsleep_time_ms\x18\x02 \x01(\x05R\vsleepTimeMs\x12.\n" + - "\x13error_code_returned\x18\x03 \x01(\rR\x11errorCodeReturned\"C\n" + - "\x11PingErrorResponse\x12\x14\n" + - "\x05value\x18\x01 \x01(\tR\x05value\x12\x18\n" + - "\acounter\x18\x02 \x01(\x05R\acounter\"{\n" + - "\x0fPingListRequest\x12\x14\n" + - "\x05value\x18\x01 \x01(\tR\x05value\x12\"\n" + - "\rsleep_time_ms\x18\x02 \x01(\x05R\vsleepTimeMs\x12.\n" + - "\x13error_code_returned\x18\x03 \x01(\rR\x11errorCodeReturned\"B\n" + - "\x10PingListResponse\x12\x14\n" + - "\x05value\x18\x01 \x01(\tR\x05value\x12\x18\n" + - "\acounter\x18\x02 \x01(\x05R\acounter\"}\n" + - "\x11PingStreamRequest\x12\x14\n" + - "\x05value\x18\x01 \x01(\tR\x05value\x12\"\n" + - "\rsleep_time_ms\x18\x02 \x01(\x05R\vsleepTimeMs\x12.\n" + - "\x13error_code_returned\x18\x03 \x01(\rR\x11errorCodeReturned\"D\n" + - "\x12PingStreamResponse\x12\x14\n" + - "\x05value\x18\x01 \x01(\tR\x05value\x12\x18\n" + - "\acounter\x18\x02 \x01(\x05R\acounter\"\x83\x01\n" + - "\x17PingClientStreamRequest\x12\x14\n" + - "\x05value\x18\x01 \x01(\tR\x05value\x12\"\n" + - "\rsleep_time_ms\x18\x02 \x01(\x05R\vsleepTimeMs\x12.\n" + - "\x13error_code_returned\x18\x03 \x01(\rR\x11errorCodeReturned\"4\n" + - "\x18PingClientStreamResponse\x12\x18\n" + - "\acounter\x18\x01 \x01(\x05R\acounter2\xb7\x04\n" + - "\vTestService\x12X\n" + - "\tPingEmpty\x12#.testing.testpb.v1.PingEmptyRequest\x1a$.testing.testpb.v1.PingEmptyResponse\"\x00\x12I\n" + - "\x04Ping\x12\x1e.testing.testpb.v1.PingRequest\x1a\x1f.testing.testpb.v1.PingResponse\"\x00\x12X\n" + - "\tPingError\x12#.testing.testpb.v1.PingErrorRequest\x1a$.testing.testpb.v1.PingErrorResponse\"\x00\x12W\n" + - "\bPingList\x12\".testing.testpb.v1.PingListRequest\x1a#.testing.testpb.v1.PingListResponse\"\x000\x01\x12_\n" + - "\n" + - "PingStream\x12$.testing.testpb.v1.PingStreamRequest\x1a%.testing.testpb.v1.PingStreamResponse\"\x00(\x010\x01\x12o\n" + - "\x10PingClientStream\x12*.testing.testpb.v1.PingClientStreamRequest\x1a+.testing.testpb.v1.PingClientStreamResponse\"\x00(\x01B\n" + - "Z\b.;testpbb\x06proto3" +var file_test_proto_rawDesc = string([]byte{ + 0x0a, 0x0a, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x11, 0x74, 0x65, + 0x73, 0x74, 0x69, 0x6e, 0x67, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x70, 0x62, 0x2e, 0x76, 0x31, 0x22, + 0x12, 0x0a, 0x10, 0x50, 0x69, 0x6e, 0x67, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x22, 0x13, 0x0a, 0x11, 0x50, 0x69, 0x6e, 0x67, 0x45, 0x6d, 0x70, 0x74, 0x79, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x77, 0x0a, 0x0b, 0x50, 0x69, 0x6e, 0x67, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x22, 0x0a, + 0x0d, 0x73, 0x6c, 0x65, 0x65, 0x70, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x5f, 0x6d, 0x73, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, 0x73, 0x6c, 0x65, 0x65, 0x70, 0x54, 0x69, 0x6d, 0x65, 0x4d, + 0x73, 0x12, 0x2e, 0x0a, 0x13, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x5f, + 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x65, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x11, + 0x65, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x65, + 0x64, 0x22, 0x3e, 0x0a, 0x0c, 0x50, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x75, 0x6e, 0x74, + 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x65, + 0x72, 0x22, 0x7c, 0x0a, 0x10, 0x50, 0x69, 0x6e, 0x67, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x22, 0x0a, 0x0d, 0x73, + 0x6c, 0x65, 0x65, 0x70, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x5f, 0x6d, 0x73, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x0b, 0x73, 0x6c, 0x65, 0x65, 0x70, 0x54, 0x69, 0x6d, 0x65, 0x4d, 0x73, 0x12, + 0x2e, 0x0a, 0x13, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x5f, 0x72, 0x65, + 0x74, 0x75, 0x72, 0x6e, 0x65, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x11, 0x65, 0x72, + 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x65, 0x64, 0x22, + 0x43, 0x0a, 0x11, 0x50, 0x69, 0x6e, 0x67, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, + 0x75, 0x6e, 0x74, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x63, 0x6f, 0x75, + 0x6e, 0x74, 0x65, 0x72, 0x22, 0x7b, 0x0a, 0x0f, 0x50, 0x69, 0x6e, 0x67, 0x4c, 0x69, 0x73, 0x74, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x22, 0x0a, + 0x0d, 0x73, 0x6c, 0x65, 0x65, 0x70, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x5f, 0x6d, 0x73, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, 0x73, 0x6c, 0x65, 0x65, 0x70, 0x54, 0x69, 0x6d, 0x65, 0x4d, + 0x73, 0x12, 0x2e, 0x0a, 0x13, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x5f, + 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x65, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x11, + 0x65, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x65, + 0x64, 0x22, 0x42, 0x0a, 0x10, 0x50, 0x69, 0x6e, 0x67, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, + 0x6f, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x63, 0x6f, + 0x75, 0x6e, 0x74, 0x65, 0x72, 0x22, 0x7d, 0x0a, 0x11, 0x50, 0x69, 0x6e, 0x67, 0x53, 0x74, 0x72, + 0x65, 0x61, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, + 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, + 0x12, 0x22, 0x0a, 0x0d, 0x73, 0x6c, 0x65, 0x65, 0x70, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x5f, 0x6d, + 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, 0x73, 0x6c, 0x65, 0x65, 0x70, 0x54, 0x69, + 0x6d, 0x65, 0x4d, 0x73, 0x12, 0x2e, 0x0a, 0x13, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x63, 0x6f, + 0x64, 0x65, 0x5f, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x65, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x0d, 0x52, 0x11, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x74, 0x75, + 0x72, 0x6e, 0x65, 0x64, 0x22, 0x44, 0x0a, 0x12, 0x50, 0x69, 0x6e, 0x67, 0x53, 0x74, 0x72, 0x65, + 0x61, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, + 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, + 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x07, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x22, 0x83, 0x01, 0x0a, 0x17, 0x50, + 0x69, 0x6e, 0x67, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x22, 0x0a, 0x0d, + 0x73, 0x6c, 0x65, 0x65, 0x70, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x5f, 0x6d, 0x73, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x05, 0x52, 0x0b, 0x73, 0x6c, 0x65, 0x65, 0x70, 0x54, 0x69, 0x6d, 0x65, 0x4d, 0x73, + 0x12, 0x2e, 0x0a, 0x13, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x5f, 0x72, + 0x65, 0x74, 0x75, 0x72, 0x6e, 0x65, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x11, 0x65, + 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x65, 0x64, + 0x22, 0x34, 0x0a, 0x18, 0x50, 0x69, 0x6e, 0x67, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x53, 0x74, + 0x72, 0x65, 0x61, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, + 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x63, + 0x6f, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x32, 0xb7, 0x04, 0x0a, 0x0b, 0x54, 0x65, 0x73, 0x74, 0x53, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x58, 0x0a, 0x09, 0x50, 0x69, 0x6e, 0x67, 0x45, 0x6d, + 0x70, 0x74, 0x79, 0x12, 0x23, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x2e, 0x74, 0x65, + 0x73, 0x74, 0x70, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x69, 0x6e, 0x67, 0x45, 0x6d, 0x70, 0x74, + 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x24, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x69, + 0x6e, 0x67, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x70, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x69, 0x6e, + 0x67, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, + 0x12, 0x49, 0x0a, 0x04, 0x50, 0x69, 0x6e, 0x67, 0x12, 0x1e, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x69, + 0x6e, 0x67, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x70, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x69, 0x6e, + 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x69, + 0x6e, 0x67, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x70, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x69, 0x6e, + 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x58, 0x0a, 0x09, 0x50, + 0x69, 0x6e, 0x67, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x23, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x69, + 0x6e, 0x67, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x70, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x69, 0x6e, + 0x67, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x24, 0x2e, + 0x74, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x70, 0x62, 0x2e, 0x76, + 0x31, 0x2e, 0x50, 0x69, 0x6e, 0x67, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x57, 0x0a, 0x08, 0x50, 0x69, 0x6e, 0x67, 0x4c, 0x69, 0x73, + 0x74, 0x12, 0x22, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x2e, 0x74, 0x65, 0x73, 0x74, + 0x70, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x69, 0x6e, 0x67, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x23, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x2e, + 0x74, 0x65, 0x73, 0x74, 0x70, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x69, 0x6e, 0x67, 0x4c, 0x69, + 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x30, 0x01, 0x12, 0x5f, + 0x0a, 0x0a, 0x50, 0x69, 0x6e, 0x67, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x24, 0x2e, 0x74, + 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x70, 0x62, 0x2e, 0x76, 0x31, + 0x2e, 0x50, 0x69, 0x6e, 0x67, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x25, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x2e, 0x74, 0x65, 0x73, + 0x74, 0x70, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x69, 0x6e, 0x67, 0x53, 0x74, 0x72, 0x65, 0x61, + 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x28, 0x01, 0x30, 0x01, 0x12, + 0x6f, 0x0a, 0x10, 0x50, 0x69, 0x6e, 0x67, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x53, 0x74, 0x72, + 0x65, 0x61, 0x6d, 0x12, 0x2a, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x2e, 0x74, 0x65, + 0x73, 0x74, 0x70, 0x62, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x69, 0x6e, 0x67, 0x43, 0x6c, 0x69, 0x65, + 0x6e, 0x74, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x2b, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x70, 0x62, + 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x69, 0x6e, 0x67, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x53, 0x74, + 0x72, 0x65, 0x61, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x28, 0x01, + 0x42, 0x0a, 0x5a, 0x08, 0x2e, 0x3b, 0x74, 0x65, 0x73, 0x74, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, +}) var ( file_test_proto_rawDescOnce sync.Once diff --git a/testing/testpb/test_grpc.pb.go b/testing/testpb/test_grpc.pb.go index 0c26aeb1..9e5bb2cf 100644 --- a/testing/testpb/test_grpc.pb.go +++ b/testing/testpb/test_grpc.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.3.0 +// - protoc-gen-go-grpc v1.5.1 // - protoc v6.31.1 // source: test.proto @@ -8,6 +8,7 @@ package testpb import ( context "context" + grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -15,8 +16,8 @@ import ( // 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.32.0 or later. -const _ = grpc.SupportPackageIsVersion7 +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 const ( TestService_PingEmpty_FullMethodName = "/testing.testpb.v1.TestService/PingEmpty" @@ -34,9 +35,9 @@ type TestServiceClient interface { PingEmpty(ctx context.Context, in *PingEmptyRequest, opts ...grpc.CallOption) (*PingEmptyResponse, error) Ping(ctx context.Context, in *PingRequest, opts ...grpc.CallOption) (*PingResponse, error) PingError(ctx context.Context, in *PingErrorRequest, opts ...grpc.CallOption) (*PingErrorResponse, error) - PingList(ctx context.Context, in *PingListRequest, opts ...grpc.CallOption) (TestService_PingListClient, error) - PingStream(ctx context.Context, opts ...grpc.CallOption) (TestService_PingStreamClient, error) - PingClientStream(ctx context.Context, opts ...grpc.CallOption) (TestService_PingClientStreamClient, error) + PingList(ctx context.Context, in *PingListRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[PingListResponse], error) + PingStream(ctx context.Context, opts ...grpc.CallOption) (grpc.BidiStreamingClient[PingStreamRequest, PingStreamResponse], error) + PingClientStream(ctx context.Context, opts ...grpc.CallOption) (grpc.ClientStreamingClient[PingClientStreamRequest, PingClientStreamResponse], error) } type testServiceClient struct { @@ -48,8 +49,9 @@ func NewTestServiceClient(cc grpc.ClientConnInterface) TestServiceClient { } func (c *testServiceClient) PingEmpty(ctx context.Context, in *PingEmptyRequest, opts ...grpc.CallOption) (*PingEmptyResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(PingEmptyResponse) - err := c.cc.Invoke(ctx, TestService_PingEmpty_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, TestService_PingEmpty_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -57,8 +59,9 @@ func (c *testServiceClient) PingEmpty(ctx context.Context, in *PingEmptyRequest, } func (c *testServiceClient) Ping(ctx context.Context, in *PingRequest, opts ...grpc.CallOption) (*PingResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(PingResponse) - err := c.cc.Invoke(ctx, TestService_Ping_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, TestService_Ping_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -66,20 +69,22 @@ func (c *testServiceClient) Ping(ctx context.Context, in *PingRequest, opts ...g } func (c *testServiceClient) PingError(ctx context.Context, in *PingErrorRequest, opts ...grpc.CallOption) (*PingErrorResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(PingErrorResponse) - err := c.cc.Invoke(ctx, TestService_PingError_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, TestService_PingError_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } -func (c *testServiceClient) PingList(ctx context.Context, in *PingListRequest, opts ...grpc.CallOption) (TestService_PingListClient, error) { - stream, err := c.cc.NewStream(ctx, &TestService_ServiceDesc.Streams[0], TestService_PingList_FullMethodName, opts...) +func (c *testServiceClient) PingList(ctx context.Context, in *PingListRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[PingListResponse], error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + stream, err := c.cc.NewStream(ctx, &TestService_ServiceDesc.Streams[0], TestService_PingList_FullMethodName, cOpts...) if err != nil { return nil, err } - x := &testServicePingListClient{stream} + x := &grpc.GenericClientStream[PingListRequest, PingListResponse]{ClientStream: stream} if err := x.ClientStream.SendMsg(in); err != nil { return nil, err } @@ -89,104 +94,54 @@ func (c *testServiceClient) PingList(ctx context.Context, in *PingListRequest, o return x, nil } -type TestService_PingListClient interface { - Recv() (*PingListResponse, error) - grpc.ClientStream -} - -type testServicePingListClient struct { - grpc.ClientStream -} - -func (x *testServicePingListClient) Recv() (*PingListResponse, error) { - m := new(PingListResponse) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} +// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. +type TestService_PingListClient = grpc.ServerStreamingClient[PingListResponse] -func (c *testServiceClient) PingStream(ctx context.Context, opts ...grpc.CallOption) (TestService_PingStreamClient, error) { - stream, err := c.cc.NewStream(ctx, &TestService_ServiceDesc.Streams[1], TestService_PingStream_FullMethodName, opts...) +func (c *testServiceClient) PingStream(ctx context.Context, opts ...grpc.CallOption) (grpc.BidiStreamingClient[PingStreamRequest, PingStreamResponse], error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + stream, err := c.cc.NewStream(ctx, &TestService_ServiceDesc.Streams[1], TestService_PingStream_FullMethodName, cOpts...) if err != nil { return nil, err } - x := &testServicePingStreamClient{stream} + x := &grpc.GenericClientStream[PingStreamRequest, PingStreamResponse]{ClientStream: stream} return x, nil } -type TestService_PingStreamClient interface { - Send(*PingStreamRequest) error - Recv() (*PingStreamResponse, error) - grpc.ClientStream -} - -type testServicePingStreamClient struct { - grpc.ClientStream -} - -func (x *testServicePingStreamClient) Send(m *PingStreamRequest) error { - return x.ClientStream.SendMsg(m) -} - -func (x *testServicePingStreamClient) Recv() (*PingStreamResponse, error) { - m := new(PingStreamResponse) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} +// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. +type TestService_PingStreamClient = grpc.BidiStreamingClient[PingStreamRequest, PingStreamResponse] -func (c *testServiceClient) PingClientStream(ctx context.Context, opts ...grpc.CallOption) (TestService_PingClientStreamClient, error) { - stream, err := c.cc.NewStream(ctx, &TestService_ServiceDesc.Streams[2], TestService_PingClientStream_FullMethodName, opts...) +func (c *testServiceClient) PingClientStream(ctx context.Context, opts ...grpc.CallOption) (grpc.ClientStreamingClient[PingClientStreamRequest, PingClientStreamResponse], error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + stream, err := c.cc.NewStream(ctx, &TestService_ServiceDesc.Streams[2], TestService_PingClientStream_FullMethodName, cOpts...) if err != nil { return nil, err } - x := &testServicePingClientStreamClient{stream} + x := &grpc.GenericClientStream[PingClientStreamRequest, PingClientStreamResponse]{ClientStream: stream} return x, nil } -type TestService_PingClientStreamClient interface { - Send(*PingClientStreamRequest) error - CloseAndRecv() (*PingClientStreamResponse, error) - grpc.ClientStream -} - -type testServicePingClientStreamClient struct { - grpc.ClientStream -} - -func (x *testServicePingClientStreamClient) Send(m *PingClientStreamRequest) error { - return x.ClientStream.SendMsg(m) -} - -func (x *testServicePingClientStreamClient) CloseAndRecv() (*PingClientStreamResponse, error) { - if err := x.ClientStream.CloseSend(); err != nil { - return nil, err - } - m := new(PingClientStreamResponse) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} +// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. +type TestService_PingClientStreamClient = grpc.ClientStreamingClient[PingClientStreamRequest, PingClientStreamResponse] // TestServiceServer is the server API for TestService service. // All implementations must embed UnimplementedTestServiceServer -// for forward compatibility +// for forward compatibility. type TestServiceServer interface { PingEmpty(context.Context, *PingEmptyRequest) (*PingEmptyResponse, error) Ping(context.Context, *PingRequest) (*PingResponse, error) PingError(context.Context, *PingErrorRequest) (*PingErrorResponse, error) - PingList(*PingListRequest, TestService_PingListServer) error - PingStream(TestService_PingStreamServer) error - PingClientStream(TestService_PingClientStreamServer) error + PingList(*PingListRequest, grpc.ServerStreamingServer[PingListResponse]) error + PingStream(grpc.BidiStreamingServer[PingStreamRequest, PingStreamResponse]) error + PingClientStream(grpc.ClientStreamingServer[PingClientStreamRequest, PingClientStreamResponse]) error mustEmbedUnimplementedTestServiceServer() } -// UnimplementedTestServiceServer must be embedded to have forward compatible implementations. -type UnimplementedTestServiceServer struct { -} +// UnimplementedTestServiceServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedTestServiceServer struct{} func (UnimplementedTestServiceServer) PingEmpty(context.Context, *PingEmptyRequest) (*PingEmptyResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method PingEmpty not implemented") @@ -197,16 +152,17 @@ func (UnimplementedTestServiceServer) Ping(context.Context, *PingRequest) (*Ping func (UnimplementedTestServiceServer) PingError(context.Context, *PingErrorRequest) (*PingErrorResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method PingError not implemented") } -func (UnimplementedTestServiceServer) PingList(*PingListRequest, TestService_PingListServer) error { +func (UnimplementedTestServiceServer) PingList(*PingListRequest, grpc.ServerStreamingServer[PingListResponse]) error { return status.Errorf(codes.Unimplemented, "method PingList not implemented") } -func (UnimplementedTestServiceServer) PingStream(TestService_PingStreamServer) error { +func (UnimplementedTestServiceServer) PingStream(grpc.BidiStreamingServer[PingStreamRequest, PingStreamResponse]) error { return status.Errorf(codes.Unimplemented, "method PingStream not implemented") } -func (UnimplementedTestServiceServer) PingClientStream(TestService_PingClientStreamServer) error { +func (UnimplementedTestServiceServer) PingClientStream(grpc.ClientStreamingServer[PingClientStreamRequest, PingClientStreamResponse]) error { return status.Errorf(codes.Unimplemented, "method PingClientStream not implemented") } func (UnimplementedTestServiceServer) mustEmbedUnimplementedTestServiceServer() {} +func (UnimplementedTestServiceServer) testEmbeddedByValue() {} // 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 @@ -216,6 +172,13 @@ type UnsafeTestServiceServer interface { } func RegisterTestServiceServer(s grpc.ServiceRegistrar, srv TestServiceServer) { + // If the following call pancis, it indicates UnimplementedTestServiceServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } s.RegisterService(&TestService_ServiceDesc, srv) } @@ -278,73 +241,25 @@ func _TestService_PingList_Handler(srv interface{}, stream grpc.ServerStream) er if err := stream.RecvMsg(m); err != nil { return err } - return srv.(TestServiceServer).PingList(m, &testServicePingListServer{stream}) -} - -type TestService_PingListServer interface { - Send(*PingListResponse) error - grpc.ServerStream -} - -type testServicePingListServer struct { - grpc.ServerStream + return srv.(TestServiceServer).PingList(m, &grpc.GenericServerStream[PingListRequest, PingListResponse]{ServerStream: stream}) } -func (x *testServicePingListServer) Send(m *PingListResponse) error { - return x.ServerStream.SendMsg(m) -} +// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. +type TestService_PingListServer = grpc.ServerStreamingServer[PingListResponse] func _TestService_PingStream_Handler(srv interface{}, stream grpc.ServerStream) error { - return srv.(TestServiceServer).PingStream(&testServicePingStreamServer{stream}) -} - -type TestService_PingStreamServer interface { - Send(*PingStreamResponse) error - Recv() (*PingStreamRequest, error) - grpc.ServerStream + return srv.(TestServiceServer).PingStream(&grpc.GenericServerStream[PingStreamRequest, PingStreamResponse]{ServerStream: stream}) } -type testServicePingStreamServer struct { - grpc.ServerStream -} - -func (x *testServicePingStreamServer) Send(m *PingStreamResponse) error { - return x.ServerStream.SendMsg(m) -} - -func (x *testServicePingStreamServer) Recv() (*PingStreamRequest, error) { - m := new(PingStreamRequest) - if err := x.ServerStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} +// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. +type TestService_PingStreamServer = grpc.BidiStreamingServer[PingStreamRequest, PingStreamResponse] func _TestService_PingClientStream_Handler(srv interface{}, stream grpc.ServerStream) error { - return srv.(TestServiceServer).PingClientStream(&testServicePingClientStreamServer{stream}) + return srv.(TestServiceServer).PingClientStream(&grpc.GenericServerStream[PingClientStreamRequest, PingClientStreamResponse]{ServerStream: stream}) } -type TestService_PingClientStreamServer interface { - SendAndClose(*PingClientStreamResponse) error - Recv() (*PingClientStreamRequest, error) - grpc.ServerStream -} - -type testServicePingClientStreamServer struct { - grpc.ServerStream -} - -func (x *testServicePingClientStreamServer) SendAndClose(m *PingClientStreamResponse) error { - return x.ServerStream.SendMsg(m) -} - -func (x *testServicePingClientStreamServer) Recv() (*PingClientStreamRequest, error) { - m := new(PingClientStreamRequest) - if err := x.ServerStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} +// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. +type TestService_PingClientStreamServer = grpc.ClientStreamingServer[PingClientStreamRequest, PingClientStreamResponse] // TestService_ServiceDesc is the grpc.ServiceDesc for TestService service. // It's only intended for direct use with grpc.RegisterService,