diff --git a/CHANGELOG.md b/CHANGELOG.md index ca16273c..83647fb5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## v1.7.0 + +CHANGES: + +* When go-plugin encounters a stack trace on the server stderr stream, it now raises output to a log-level of Error instead of Debug. [[GH-292](https://github.com/hashicorp/go-plugin/pull/292)] + + ## v1.6.2 ENHANCEMENTS: diff --git a/client.go b/client.go index a7e7019f..1f14db99 100644 --- a/client.go +++ b/client.go @@ -1175,10 +1175,13 @@ func (c *Client) logStderr(name string, r io.Reader) { reader := bufio.NewReaderSize(r, c.config.PluginLogBufferSize) // continuation indicates the previous line was a prefix continuation := false - // panic indicates the previous line was the start of a panic output - panic := false + + // inPanic indicates we saw the start of a stack trace and should divert all + // remaining untagged lines to stderr + var inPanic bool for { + line, isPrefix, err := reader.ReadLine() switch { case err == io.EOF: @@ -1225,33 +1228,24 @@ func (c *Client) logStderr(name string, r io.Reader) { // string prefixes switch line := string(line); { case strings.HasPrefix(line, "[TRACE]"): - panic = false l.Trace(line) case strings.HasPrefix(line, "[DEBUG]"): - panic = false l.Debug(line) case strings.HasPrefix(line, "[INFO]"): - panic = false l.Info(line) case strings.HasPrefix(line, "[WARN]"): - panic = false l.Warn(line) case strings.HasPrefix(line, "[ERROR]"): - panic = false l.Error(line) - case strings.HasPrefix(line, "panic:"): - panic = true + case strings.HasPrefix(line, "panic: ") || strings.HasPrefix(line, "fatal error: "): + inPanic = true + fallthrough + case inPanic: l.Error(line) default: - if panic { - l.Error(line) - } else { - l.Debug(line) - } + l.Debug(line) } } else { - panic = false - logLevel := hclog.LevelFromString(entry.Level) if logLevel != hclog.NoLevel && logLevel < loggerLevel { // The logger will ignore this log entry anyway, so we diff --git a/client_test.go b/client_test.go index e7f1b025..6ed80f96 100644 --- a/client_test.go +++ b/client_test.go @@ -1443,7 +1443,7 @@ func TestClient_mtlsNetRPCClient(t *testing.T) { } func TestClient_logger(t *testing.T) { - t.Run("net/rpc", func(t *testing.T) { testClient_logger(t, "netrpc") }) + t.Run("netrpc", func(t *testing.T) { testClient_logger(t, "netrpc") }) t.Run("grpc", func(t *testing.T) { testClient_logger(t, "grpc") }) } @@ -1454,16 +1454,21 @@ func testClient_logger(t *testing.T, proto string) { // Custom hclog.Logger clientLogger := hclog.New(&hclog.LoggerOptions{ Name: "test-logger", - Level: hclog.Trace, + Level: hclog.Debug, Output: stderr, Mutex: mutex, }) + plugins := map[string]map[string]Plugin{ + "netrpc": testPluginMap, + "grpc": testGRPCPluginMap, + } + process := helperProcess("test-interface-logger-" + proto) c := NewClient(&ClientConfig{ Cmd: process, HandshakeConfig: testHandshake, - Plugins: testGRPCPluginMap, + Plugins: plugins[proto], Logger: clientLogger, AllowedProtocols: []Protocol{ProtocolNetRPC, ProtocolGRPC}, }) @@ -1486,7 +1491,7 @@ func testClient_logger(t *testing.T, proto string) { t.Fatalf("bad: %#v", raw) } - { + t.Run("-1", func(t *testing.T) { // Discard everything else, and capture the output we care about mutex.Lock() buffer.Reset() @@ -1502,9 +1507,9 @@ func testClient_logger(t *testing.T, proto string) { if !strings.Contains(line, "foo=bar") { t.Fatalf("bad: %q", line) } - } + }) - { + t.Run("-2", func(t *testing.T) { // Try an integer type mutex.Lock() buffer.Reset() @@ -1520,7 +1525,7 @@ func testClient_logger(t *testing.T, proto string) { if !strings.Contains(line, "foo=12") { t.Fatalf("bad: %q", line) } - } + }) // Kill it c.Kill() @@ -1535,6 +1540,84 @@ func testClient_logger(t *testing.T, proto string) { } } +func TestServerLogPanic(t *testing.T) { + var buffer bytes.Buffer + mutex := new(sync.Mutex) + stderr := io.MultiWriter(os.Stderr, &buffer) + // Custom hclog.Logger + clientLogger := hclog.New(&hclog.LoggerOptions{ + Name: "test-logger", + Level: hclog.Error, + Output: stderr, + Mutex: mutex, + }) + + process := helperProcess("test-interface-logger-grpc") + c := NewClient(&ClientConfig{ + Cmd: process, + HandshakeConfig: testHandshake, + Plugins: testGRPCPluginMap, + Logger: clientLogger, + AllowedProtocols: []Protocol{ProtocolNetRPC, ProtocolGRPC}, + }) + defer c.Kill() + + // Grab the RPC client + client, err := c.Client() + if err != nil { + t.Fatalf("err should be nil, got %s", err) + } + + // Grab the impl + raw, err := client.Dispense("test") + if err != nil { + t.Fatalf("err should be nil, got %s", err) + } + + impl, ok := raw.(testInterface) + if !ok { + t.Fatalf("bad: %#v", raw) + } + + mutex.Lock() + buffer.Reset() + mutex.Unlock() + err = impl.Panic("invalid foo bar") + time.Sleep(100 * time.Millisecond) + mutex.Lock() + + panicFound := false + stackLines := 0 + + for _, line := range strings.Split(buffer.String(), "\n") { + if strings.Contains(line, "[ERROR] test-logger.go-plugin.test: panic: invalid foo bar") { + panicFound = true + continue + } + + // make sure we are not just capturing the panic line, and have the rest + // of the output too + if panicFound { + // there should only be [ERROR] lines past this point, but the log + // level is Error, so we can just verify there are lines + stackLines++ + } + } + + if !panicFound { + t.Fatal("failed to find panic in error log output") + } + + if stackLines < 10 { + t.Fatalf("only found %d stack lines after panic", stackLines) + } + + mutex.Unlock() + if err == nil { + t.Fatal("expected error due to panic") + } +} + // Test that we continue to consume stderr over long lines. func TestClient_logStderr(t *testing.T) { stderr := bytes.Buffer{} diff --git a/plugin_test.go b/plugin_test.go index 090ac813..c66d2083 100644 --- a/plugin_test.go +++ b/plugin_test.go @@ -43,6 +43,7 @@ type testInterface interface { PrintKV(string, interface{}) Bidirectional() error PrintStdio(stdout, stderr []byte) + Panic(msg string) error } // testStreamer is used to test the grpc streaming interface @@ -150,6 +151,10 @@ func (i *testInterfaceImpl) PrintStdio(stdout, stderr []byte) { } } +func (i *testInterfaceImpl) Panic(msg string) error { + panic(msg) +} + // testInterfaceClient implements testInterface to communicate over RPC type testInterfaceClient struct { Client *rpc.Client @@ -186,6 +191,10 @@ func (impl *testInterfaceClient) PrintStdio(stdout, stderr []byte) { // put in the effort. } +func (impl *testInterfaceClient) Panic(msg string) error { + return nil +} + // testInterfaceServer is the RPC server for testInterfaceClient type testInterfaceServer struct { Broker *MuxBroker @@ -214,6 +223,7 @@ var testGRPCPluginMap = map[string]Plugin{ // testGRPCServer is the implementation of our GRPC service. type testGRPCServer struct { + grpctest.UnimplementedTestServer Impl testInterface broker *GRPCBroker } @@ -280,7 +290,14 @@ func (s *testGRPCServer) PrintStdio( return &empty.Empty{}, nil } -type pingPongServer struct{} +func (s *testGRPCServer) Panic(ctx context.Context, req *grpctest.PanicRequest) (*empty.Empty, error) { + err := s.Impl.Panic(req.Message) + return &empty.Empty{}, err +} + +type pingPongServer struct { + grpctest.UnimplementedPingPongServer +} func (p *pingPongServer) Ping(ctx context.Context, req *grpctest.PingRequest) (*grpctest.PongResponse, error) { return &grpctest.PongResponse{ @@ -416,6 +433,11 @@ func (c *testGRPCClient) PrintStdio(stdout, stderr []byte) { } } +func (c *testGRPCClient) Panic(msg string) error { + _, err := c.Client.Panic(context.Background(), &grpctest.PanicRequest{Message: msg}) + return err +} + func helperProcess(s ...string) *exec.Cmd { cs := []string{"-test.run=TestHelperProcess", "--"} cs = append(cs, s...) @@ -577,7 +599,7 @@ func TestHelperProcess(*testing.T) { case "test-interface-logger-grpc": Serve(&ServeConfig{ HandshakeConfig: testHandshake, - Plugins: testPluginMap, + Plugins: testGRPCPluginMap, GRPCServer: DefaultGRPCServer, }) // Shouldn't reach here but make sure we exit anyways diff --git a/test/grpc/buf.gen.yaml b/test/grpc/buf.gen.yaml new file mode 100644 index 00000000..033d0153 --- /dev/null +++ b/test/grpc/buf.gen.yaml @@ -0,0 +1,14 @@ +# Copyright (c) HashiCorp, Inc. +# SPDX-License-Identifier: MPL-2.0 + +version: v1 +plugins: + - plugin: buf.build/protocolbuffers/go + out: . + opt: + - paths=source_relative + - plugin: buf.build/grpc/go:v1.3.0 + out: . + opt: + - paths=source_relative + - require_unimplemented_servers=false diff --git a/test/grpc/buf.yaml b/test/grpc/buf.yaml new file mode 100644 index 00000000..0a945b38 --- /dev/null +++ b/test/grpc/buf.yaml @@ -0,0 +1,4 @@ +# Copyright (c) HashiCorp, Inc. +# SPDX-License-Identifier: MPL-2.0 + +version: v1 diff --git a/test/grpc/test.pb.go b/test/grpc/test.pb.go index 4c740e34..6aab61fa 100644 --- a/test/grpc/test.pb.go +++ b/test/grpc/test.pb.go @@ -3,9 +3,9 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.36.6 // protoc (unknown) -// source: test/grpc/test.proto +// source: test.proto package grpctest @@ -15,6 +15,7 @@ import ( emptypb "google.golang.org/protobuf/types/known/emptypb" reflect "reflect" sync "sync" + unsafe "unsafe" ) const ( @@ -25,20 +26,17 @@ const ( ) type TestRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Input int32 `protobuf:"varint,1,opt,name=Input,proto3" json:"Input,omitempty"` unknownFields protoimpl.UnknownFields - - Input int32 `protobuf:"varint,1,opt,name=Input,proto3" json:"Input,omitempty"` + sizeCache protoimpl.SizeCache } func (x *TestRequest) Reset() { *x = TestRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_test_grpc_test_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_test_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *TestRequest) String() string { @@ -48,8 +46,8 @@ func (x *TestRequest) String() string { func (*TestRequest) ProtoMessage() {} func (x *TestRequest) ProtoReflect() protoreflect.Message { - mi := &file_test_grpc_test_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + mi := &file_test_proto_msgTypes[0] + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -61,7 +59,7 @@ func (x *TestRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use TestRequest.ProtoReflect.Descriptor instead. func (*TestRequest) Descriptor() ([]byte, []int) { - return file_test_grpc_test_proto_rawDescGZIP(), []int{0} + return file_test_proto_rawDescGZIP(), []int{0} } func (x *TestRequest) GetInput() int32 { @@ -72,20 +70,17 @@ func (x *TestRequest) GetInput() int32 { } type TestResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Output int32 `protobuf:"varint,2,opt,name=Output,proto3" json:"Output,omitempty"` unknownFields protoimpl.UnknownFields - - Output int32 `protobuf:"varint,2,opt,name=Output,proto3" json:"Output,omitempty"` + sizeCache protoimpl.SizeCache } func (x *TestResponse) Reset() { *x = TestResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_test_grpc_test_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_test_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *TestResponse) String() string { @@ -95,8 +90,8 @@ func (x *TestResponse) String() string { func (*TestResponse) ProtoMessage() {} func (x *TestResponse) ProtoReflect() protoreflect.Message { - mi := &file_test_grpc_test_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + mi := &file_test_proto_msgTypes[1] + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -108,7 +103,7 @@ func (x *TestResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use TestResponse.ProtoReflect.Descriptor instead. func (*TestResponse) Descriptor() ([]byte, []int) { - return file_test_grpc_test_proto_rawDescGZIP(), []int{1} + return file_test_proto_rawDescGZIP(), []int{1} } func (x *TestResponse) GetOutput() int32 { @@ -119,25 +114,22 @@ func (x *TestResponse) GetOutput() int32 { } type PrintKVRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Key string `protobuf:"bytes,1,opt,name=Key,proto3" json:"Key,omitempty"` - // Types that are assignable to Value: + state protoimpl.MessageState `protogen:"open.v1"` + Key string `protobuf:"bytes,1,opt,name=Key,proto3" json:"Key,omitempty"` + // Types that are valid to be assigned to Value: // // *PrintKVRequest_ValueString // *PrintKVRequest_ValueInt - Value isPrintKVRequest_Value `protobuf_oneof:"Value"` + Value isPrintKVRequest_Value `protobuf_oneof:"Value"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *PrintKVRequest) Reset() { *x = PrintKVRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_test_grpc_test_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_test_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *PrintKVRequest) String() string { @@ -147,8 +139,8 @@ func (x *PrintKVRequest) String() string { func (*PrintKVRequest) ProtoMessage() {} func (x *PrintKVRequest) ProtoReflect() protoreflect.Message { - mi := &file_test_grpc_test_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { + mi := &file_test_proto_msgTypes[2] + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -160,7 +152,7 @@ func (x *PrintKVRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use PrintKVRequest.ProtoReflect.Descriptor instead. func (*PrintKVRequest) Descriptor() ([]byte, []int) { - return file_test_grpc_test_proto_rawDescGZIP(), []int{2} + return file_test_proto_rawDescGZIP(), []int{2} } func (x *PrintKVRequest) GetKey() string { @@ -170,23 +162,27 @@ func (x *PrintKVRequest) GetKey() string { return "" } -func (m *PrintKVRequest) GetValue() isPrintKVRequest_Value { - if m != nil { - return m.Value +func (x *PrintKVRequest) GetValue() isPrintKVRequest_Value { + if x != nil { + return x.Value } return nil } func (x *PrintKVRequest) GetValueString() string { - if x, ok := x.GetValue().(*PrintKVRequest_ValueString); ok { - return x.ValueString + if x != nil { + if x, ok := x.Value.(*PrintKVRequest_ValueString); ok { + return x.ValueString + } } return "" } func (x *PrintKVRequest) GetValueInt() int32 { - if x, ok := x.GetValue().(*PrintKVRequest_ValueInt); ok { - return x.ValueInt + if x != nil { + if x, ok := x.Value.(*PrintKVRequest_ValueInt); ok { + return x.ValueInt + } } return 0 } @@ -208,18 +204,16 @@ func (*PrintKVRequest_ValueString) isPrintKVRequest_Value() {} func (*PrintKVRequest_ValueInt) isPrintKVRequest_Value() {} type PrintKVResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *PrintKVResponse) Reset() { *x = PrintKVResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_test_grpc_test_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_test_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *PrintKVResponse) String() string { @@ -229,8 +223,8 @@ func (x *PrintKVResponse) String() string { func (*PrintKVResponse) ProtoMessage() {} func (x *PrintKVResponse) ProtoReflect() protoreflect.Message { - mi := &file_test_grpc_test_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { + mi := &file_test_proto_msgTypes[3] + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -242,24 +236,21 @@ func (x *PrintKVResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use PrintKVResponse.ProtoReflect.Descriptor instead. func (*PrintKVResponse) Descriptor() ([]byte, []int) { - return file_test_grpc_test_proto_rawDescGZIP(), []int{3} + return file_test_proto_rawDescGZIP(), []int{3} } type BidirectionalRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Id uint32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` unknownFields protoimpl.UnknownFields - - Id uint32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + sizeCache protoimpl.SizeCache } func (x *BidirectionalRequest) Reset() { *x = BidirectionalRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_test_grpc_test_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_test_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *BidirectionalRequest) String() string { @@ -269,8 +260,8 @@ func (x *BidirectionalRequest) String() string { func (*BidirectionalRequest) ProtoMessage() {} func (x *BidirectionalRequest) ProtoReflect() protoreflect.Message { - mi := &file_test_grpc_test_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { + mi := &file_test_proto_msgTypes[4] + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -282,7 +273,7 @@ func (x *BidirectionalRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use BidirectionalRequest.ProtoReflect.Descriptor instead. func (*BidirectionalRequest) Descriptor() ([]byte, []int) { - return file_test_grpc_test_proto_rawDescGZIP(), []int{4} + return file_test_proto_rawDescGZIP(), []int{4} } func (x *BidirectionalRequest) GetId() uint32 { @@ -293,20 +284,17 @@ func (x *BidirectionalRequest) GetId() uint32 { } type BidirectionalResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Id uint32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` unknownFields protoimpl.UnknownFields - - Id uint32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + sizeCache protoimpl.SizeCache } func (x *BidirectionalResponse) Reset() { *x = BidirectionalResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_test_grpc_test_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_test_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *BidirectionalResponse) String() string { @@ -316,8 +304,8 @@ func (x *BidirectionalResponse) String() string { func (*BidirectionalResponse) ProtoMessage() {} func (x *BidirectionalResponse) ProtoReflect() protoreflect.Message { - mi := &file_test_grpc_test_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { + mi := &file_test_proto_msgTypes[5] + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -329,7 +317,7 @@ func (x *BidirectionalResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use BidirectionalResponse.ProtoReflect.Descriptor instead. func (*BidirectionalResponse) Descriptor() ([]byte, []int) { - return file_test_grpc_test_proto_rawDescGZIP(), []int{5} + return file_test_proto_rawDescGZIP(), []int{5} } func (x *BidirectionalResponse) GetId() uint32 { @@ -340,21 +328,18 @@ func (x *BidirectionalResponse) GetId() uint32 { } type PrintStdioRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Stdout []byte `protobuf:"bytes,1,opt,name=stdout,proto3" json:"stdout,omitempty"` + Stderr []byte `protobuf:"bytes,2,opt,name=stderr,proto3" json:"stderr,omitempty"` unknownFields protoimpl.UnknownFields - - Stdout []byte `protobuf:"bytes,1,opt,name=stdout,proto3" json:"stdout,omitempty"` - Stderr []byte `protobuf:"bytes,2,opt,name=stderr,proto3" json:"stderr,omitempty"` + sizeCache protoimpl.SizeCache } func (x *PrintStdioRequest) Reset() { *x = PrintStdioRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_test_grpc_test_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_test_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *PrintStdioRequest) String() string { @@ -364,8 +349,8 @@ func (x *PrintStdioRequest) String() string { func (*PrintStdioRequest) ProtoMessage() {} func (x *PrintStdioRequest) ProtoReflect() protoreflect.Message { - mi := &file_test_grpc_test_proto_msgTypes[6] - if protoimpl.UnsafeEnabled && x != nil { + mi := &file_test_proto_msgTypes[6] + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -377,7 +362,7 @@ func (x *PrintStdioRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use PrintStdioRequest.ProtoReflect.Descriptor instead. func (*PrintStdioRequest) Descriptor() ([]byte, []int) { - return file_test_grpc_test_proto_rawDescGZIP(), []int{6} + return file_test_proto_rawDescGZIP(), []int{6} } func (x *PrintStdioRequest) GetStdout() []byte { @@ -394,19 +379,61 @@ func (x *PrintStdioRequest) GetStderr() []byte { return nil } -type PingRequest struct { - state protoimpl.MessageState +type PanicRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` + unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache +} + +func (x *PanicRequest) Reset() { + *x = PanicRequest{} + mi := &file_test_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *PanicRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PanicRequest) ProtoMessage() {} + +func (x *PanicRequest) ProtoReflect() protoreflect.Message { + mi := &file_test_proto_msgTypes[7] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PanicRequest.ProtoReflect.Descriptor instead. +func (*PanicRequest) Descriptor() ([]byte, []int) { + return file_test_proto_rawDescGZIP(), []int{7} +} + +func (x *PanicRequest) GetMessage() string { + if x != nil { + return x.Message + } + return "" +} + +type PingRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *PingRequest) Reset() { *x = PingRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_test_grpc_test_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_test_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *PingRequest) String() string { @@ -416,8 +443,8 @@ func (x *PingRequest) String() string { func (*PingRequest) ProtoMessage() {} func (x *PingRequest) ProtoReflect() protoreflect.Message { - mi := &file_test_grpc_test_proto_msgTypes[7] - if protoimpl.UnsafeEnabled && x != nil { + mi := &file_test_proto_msgTypes[8] + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -429,24 +456,21 @@ func (x *PingRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use PingRequest.ProtoReflect.Descriptor instead. func (*PingRequest) Descriptor() ([]byte, []int) { - return file_test_grpc_test_proto_rawDescGZIP(), []int{7} + return file_test_proto_rawDescGZIP(), []int{8} } type PongResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Msg string `protobuf:"bytes,1,opt,name=msg,proto3" json:"msg,omitempty"` unknownFields protoimpl.UnknownFields - - Msg string `protobuf:"bytes,1,opt,name=msg,proto3" json:"msg,omitempty"` + sizeCache protoimpl.SizeCache } func (x *PongResponse) Reset() { *x = PongResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_test_grpc_test_proto_msgTypes[8] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_test_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *PongResponse) String() string { @@ -456,8 +480,8 @@ func (x *PongResponse) String() string { func (*PongResponse) ProtoMessage() {} func (x *PongResponse) ProtoReflect() protoreflect.Message { - mi := &file_test_grpc_test_proto_msgTypes[8] - if protoimpl.UnsafeEnabled && x != nil { + mi := &file_test_proto_msgTypes[9] + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -469,7 +493,7 @@ func (x *PongResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use PongResponse.ProtoReflect.Descriptor instead. func (*PongResponse) Descriptor() ([]byte, []int) { - return file_test_grpc_test_proto_rawDescGZIP(), []int{8} + return file_test_proto_rawDescGZIP(), []int{9} } func (x *PongResponse) GetMsg() string { @@ -479,82 +503,60 @@ func (x *PongResponse) GetMsg() string { return "" } -var File_test_grpc_test_proto protoreflect.FileDescriptor - -var file_test_grpc_test_proto_rawDesc = []byte{ - 0x0a, 0x14, 0x74, 0x65, 0x73, 0x74, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x74, 0x65, 0x73, 0x74, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x08, 0x67, 0x72, 0x70, 0x63, 0x74, 0x65, 0x73, 0x74, - 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, - 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x23, 0x0a, - 0x0b, 0x54, 0x65, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, - 0x49, 0x6e, 0x70, 0x75, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x49, 0x6e, 0x70, - 0x75, 0x74, 0x22, 0x26, 0x0a, 0x0c, 0x54, 0x65, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x05, 0x52, 0x06, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x22, 0x6d, 0x0a, 0x0e, 0x50, 0x72, - 0x69, 0x6e, 0x74, 0x4b, 0x56, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, - 0x4b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x4b, 0x65, 0x79, 0x12, 0x22, - 0x0a, 0x0b, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x0b, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x53, 0x74, 0x72, 0x69, - 0x6e, 0x67, 0x12, 0x1c, 0x0a, 0x08, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x49, 0x6e, 0x74, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x05, 0x48, 0x00, 0x52, 0x08, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x49, 0x6e, 0x74, - 0x42, 0x07, 0x0a, 0x05, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x11, 0x0a, 0x0f, 0x50, 0x72, 0x69, - 0x6e, 0x74, 0x4b, 0x56, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x26, 0x0a, 0x14, - 0x42, 0x69, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, - 0x52, 0x02, 0x69, 0x64, 0x22, 0x27, 0x0a, 0x15, 0x42, 0x69, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, - 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x0e, 0x0a, - 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x02, 0x69, 0x64, 0x22, 0x43, 0x0a, - 0x11, 0x50, 0x72, 0x69, 0x6e, 0x74, 0x53, 0x74, 0x64, 0x69, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x64, 0x6f, 0x75, 0x74, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0c, 0x52, 0x06, 0x73, 0x74, 0x64, 0x6f, 0x75, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, - 0x64, 0x65, 0x72, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x73, 0x74, 0x64, 0x65, - 0x72, 0x72, 0x22, 0x0d, 0x0a, 0x0b, 0x50, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x22, 0x20, 0x0a, 0x0c, 0x50, 0x6f, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x73, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, - 0x6d, 0x73, 0x67, 0x32, 0xdb, 0x02, 0x0a, 0x04, 0x54, 0x65, 0x73, 0x74, 0x12, 0x39, 0x0a, 0x06, - 0x44, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x12, 0x15, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x74, 0x65, 0x73, - 0x74, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, - 0x67, 0x72, 0x70, 0x63, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x40, 0x0a, 0x07, 0x50, 0x72, 0x69, 0x6e, 0x74, - 0x4b, 0x56, 0x12, 0x18, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x50, 0x72, - 0x69, 0x6e, 0x74, 0x4b, 0x56, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x67, - 0x72, 0x70, 0x63, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x50, 0x72, 0x69, 0x6e, 0x74, 0x4b, 0x56, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x52, 0x0a, 0x0d, 0x42, 0x69, 0x64, - 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x12, 0x1e, 0x2e, 0x67, 0x72, 0x70, - 0x63, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x42, 0x69, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, - 0x6e, 0x61, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x67, 0x72, 0x70, - 0x63, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x42, 0x69, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, - 0x6e, 0x61, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3d, 0x0a, - 0x06, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x15, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x74, 0x65, - 0x73, 0x74, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, - 0x2e, 0x67, 0x72, 0x70, 0x63, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x28, 0x01, 0x30, 0x01, 0x12, 0x43, 0x0a, 0x0a, - 0x50, 0x72, 0x69, 0x6e, 0x74, 0x53, 0x74, 0x64, 0x69, 0x6f, 0x12, 0x1b, 0x2e, 0x67, 0x72, 0x70, - 0x63, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x50, 0x72, 0x69, 0x6e, 0x74, 0x53, 0x74, 0x64, 0x69, 0x6f, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, - 0x00, 0x32, 0x43, 0x0a, 0x08, 0x50, 0x69, 0x6e, 0x67, 0x50, 0x6f, 0x6e, 0x67, 0x12, 0x37, 0x0a, - 0x04, 0x50, 0x69, 0x6e, 0x67, 0x12, 0x15, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x74, 0x65, 0x73, 0x74, - 0x2e, 0x50, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x67, - 0x72, 0x70, 0x63, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x50, 0x6f, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x0c, 0x5a, 0x0a, 0x2e, 0x2f, 0x67, 0x72, 0x70, 0x63, - 0x74, 0x65, 0x73, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} +var File_test_proto protoreflect.FileDescriptor + +const file_test_proto_rawDesc = "" + + "\n" + + "\n" + + "test.proto\x12\bgrpctest\x1a\x1bgoogle/protobuf/empty.proto\"#\n" + + "\vTestRequest\x12\x14\n" + + "\x05Input\x18\x01 \x01(\x05R\x05Input\"&\n" + + "\fTestResponse\x12\x16\n" + + "\x06Output\x18\x02 \x01(\x05R\x06Output\"m\n" + + "\x0ePrintKVRequest\x12\x10\n" + + "\x03Key\x18\x01 \x01(\tR\x03Key\x12\"\n" + + "\vValueString\x18\x02 \x01(\tH\x00R\vValueString\x12\x1c\n" + + "\bValueInt\x18\x03 \x01(\x05H\x00R\bValueIntB\a\n" + + "\x05Value\"\x11\n" + + "\x0fPrintKVResponse\"&\n" + + "\x14BidirectionalRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\rR\x02id\"'\n" + + "\x15BidirectionalResponse\x12\x0e\n" + + "\x02id\x18\x01 \x01(\rR\x02id\"C\n" + + "\x11PrintStdioRequest\x12\x16\n" + + "\x06stdout\x18\x01 \x01(\fR\x06stdout\x12\x16\n" + + "\x06stderr\x18\x02 \x01(\fR\x06stderr\"(\n" + + "\fPanicRequest\x12\x18\n" + + "\amessage\x18\x01 \x01(\tR\amessage\"\r\n" + + "\vPingRequest\" \n" + + "\fPongResponse\x12\x10\n" + + "\x03msg\x18\x01 \x01(\tR\x03msg2\x96\x03\n" + + "\x04Test\x129\n" + + "\x06Double\x12\x15.grpctest.TestRequest\x1a\x16.grpctest.TestResponse\"\x00\x12@\n" + + "\aPrintKV\x12\x18.grpctest.PrintKVRequest\x1a\x19.grpctest.PrintKVResponse\"\x00\x12R\n" + + "\rBidirectional\x12\x1e.grpctest.BidirectionalRequest\x1a\x1f.grpctest.BidirectionalResponse\"\x00\x12=\n" + + "\x06Stream\x12\x15.grpctest.TestRequest\x1a\x16.grpctest.TestResponse\"\x00(\x010\x01\x12C\n" + + "\n" + + "PrintStdio\x12\x1b.grpctest.PrintStdioRequest\x1a\x16.google.protobuf.Empty\"\x00\x129\n" + + "\x05Panic\x12\x16.grpctest.PanicRequest\x1a\x16.google.protobuf.Empty\"\x002C\n" + + "\bPingPong\x127\n" + + "\x04Ping\x12\x15.grpctest.PingRequest\x1a\x16.grpctest.PongResponse\"\x00B\fZ\n" + + "./grpctestb\x06proto3" var ( - file_test_grpc_test_proto_rawDescOnce sync.Once - file_test_grpc_test_proto_rawDescData = file_test_grpc_test_proto_rawDesc + file_test_proto_rawDescOnce sync.Once + file_test_proto_rawDescData []byte ) -func file_test_grpc_test_proto_rawDescGZIP() []byte { - file_test_grpc_test_proto_rawDescOnce.Do(func() { - file_test_grpc_test_proto_rawDescData = protoimpl.X.CompressGZIP(file_test_grpc_test_proto_rawDescData) +func file_test_proto_rawDescGZIP() []byte { + file_test_proto_rawDescOnce.Do(func() { + file_test_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_test_proto_rawDesc), len(file_test_proto_rawDesc))) }) - return file_test_grpc_test_proto_rawDescData + return file_test_proto_rawDescData } -var file_test_grpc_test_proto_msgTypes = make([]protoimpl.MessageInfo, 9) -var file_test_grpc_test_proto_goTypes = []interface{}{ +var file_test_proto_msgTypes = make([]protoimpl.MessageInfo, 10) +var file_test_proto_goTypes = []any{ (*TestRequest)(nil), // 0: grpctest.TestRequest (*TestResponse)(nil), // 1: grpctest.TestResponse (*PrintKVRequest)(nil), // 2: grpctest.PrintKVRequest @@ -562,146 +564,39 @@ var file_test_grpc_test_proto_goTypes = []interface{}{ (*BidirectionalRequest)(nil), // 4: grpctest.BidirectionalRequest (*BidirectionalResponse)(nil), // 5: grpctest.BidirectionalResponse (*PrintStdioRequest)(nil), // 6: grpctest.PrintStdioRequest - (*PingRequest)(nil), // 7: grpctest.PingRequest - (*PongResponse)(nil), // 8: grpctest.PongResponse - (*emptypb.Empty)(nil), // 9: google.protobuf.Empty -} -var file_test_grpc_test_proto_depIdxs = []int32{ - 0, // 0: grpctest.Test.Double:input_type -> grpctest.TestRequest - 2, // 1: grpctest.Test.PrintKV:input_type -> grpctest.PrintKVRequest - 4, // 2: grpctest.Test.Bidirectional:input_type -> grpctest.BidirectionalRequest - 0, // 3: grpctest.Test.Stream:input_type -> grpctest.TestRequest - 6, // 4: grpctest.Test.PrintStdio:input_type -> grpctest.PrintStdioRequest - 7, // 5: grpctest.PingPong.Ping:input_type -> grpctest.PingRequest - 1, // 6: grpctest.Test.Double:output_type -> grpctest.TestResponse - 3, // 7: grpctest.Test.PrintKV:output_type -> grpctest.PrintKVResponse - 5, // 8: grpctest.Test.Bidirectional:output_type -> grpctest.BidirectionalResponse - 1, // 9: grpctest.Test.Stream:output_type -> grpctest.TestResponse - 9, // 10: grpctest.Test.PrintStdio:output_type -> google.protobuf.Empty - 8, // 11: grpctest.PingPong.Ping:output_type -> grpctest.PongResponse - 6, // [6:12] is the sub-list for method output_type - 0, // [0:6] 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_grpc_test_proto_init() } -func file_test_grpc_test_proto_init() { - if File_test_grpc_test_proto != nil { + (*PanicRequest)(nil), // 7: grpctest.PanicRequest + (*PingRequest)(nil), // 8: grpctest.PingRequest + (*PongResponse)(nil), // 9: grpctest.PongResponse + (*emptypb.Empty)(nil), // 10: google.protobuf.Empty +} +var file_test_proto_depIdxs = []int32{ + 0, // 0: grpctest.Test.Double:input_type -> grpctest.TestRequest + 2, // 1: grpctest.Test.PrintKV:input_type -> grpctest.PrintKVRequest + 4, // 2: grpctest.Test.Bidirectional:input_type -> grpctest.BidirectionalRequest + 0, // 3: grpctest.Test.Stream:input_type -> grpctest.TestRequest + 6, // 4: grpctest.Test.PrintStdio:input_type -> grpctest.PrintStdioRequest + 7, // 5: grpctest.Test.Panic:input_type -> grpctest.PanicRequest + 8, // 6: grpctest.PingPong.Ping:input_type -> grpctest.PingRequest + 1, // 7: grpctest.Test.Double:output_type -> grpctest.TestResponse + 3, // 8: grpctest.Test.PrintKV:output_type -> grpctest.PrintKVResponse + 5, // 9: grpctest.Test.Bidirectional:output_type -> grpctest.BidirectionalResponse + 1, // 10: grpctest.Test.Stream:output_type -> grpctest.TestResponse + 10, // 11: grpctest.Test.PrintStdio:output_type -> google.protobuf.Empty + 10, // 12: grpctest.Test.Panic:output_type -> google.protobuf.Empty + 9, // 13: grpctest.PingPong.Ping:output_type -> grpctest.PongResponse + 7, // [7:14] is the sub-list for method output_type + 0, // [0:7] 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 } - if !protoimpl.UnsafeEnabled { - file_test_grpc_test_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*TestRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_test_grpc_test_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*TestResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_test_grpc_test_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*PrintKVRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_test_grpc_test_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*PrintKVResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_test_grpc_test_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*BidirectionalRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_test_grpc_test_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*BidirectionalResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_test_grpc_test_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*PrintStdioRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_test_grpc_test_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*PingRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_test_grpc_test_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*PongResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - file_test_grpc_test_proto_msgTypes[2].OneofWrappers = []interface{}{ + file_test_proto_msgTypes[2].OneofWrappers = []any{ (*PrintKVRequest_ValueString)(nil), (*PrintKVRequest_ValueInt)(nil), } @@ -709,18 +604,17 @@ func file_test_grpc_test_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_test_grpc_test_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_test_proto_rawDesc), len(file_test_proto_rawDesc)), NumEnums: 0, - NumMessages: 9, + NumMessages: 10, NumExtensions: 0, NumServices: 2, }, - GoTypes: file_test_grpc_test_proto_goTypes, - DependencyIndexes: file_test_grpc_test_proto_depIdxs, - MessageInfos: file_test_grpc_test_proto_msgTypes, + GoTypes: file_test_proto_goTypes, + DependencyIndexes: file_test_proto_depIdxs, + MessageInfos: file_test_proto_msgTypes, }.Build() - File_test_grpc_test_proto = out.File - file_test_grpc_test_proto_rawDesc = nil - file_test_grpc_test_proto_goTypes = nil - file_test_grpc_test_proto_depIdxs = nil + File_test_proto = out.File + file_test_proto_goTypes = nil + file_test_proto_depIdxs = nil } diff --git a/test/grpc/test.proto b/test/grpc/test.proto index 9204ae5c..b6de35e4 100644 --- a/test/grpc/test.proto +++ b/test/grpc/test.proto @@ -42,12 +42,17 @@ message PrintStdioRequest { bytes stderr = 2; } +message PanicRequest { + string message = 1; +} + service Test { rpc Double(TestRequest) returns (TestResponse) {} rpc PrintKV(PrintKVRequest) returns (PrintKVResponse) {} rpc Bidirectional(BidirectionalRequest) returns (BidirectionalResponse) {} rpc Stream(stream TestRequest) returns (stream TestResponse) {} rpc PrintStdio(PrintStdioRequest) returns (google.protobuf.Empty) {} + rpc Panic(PanicRequest) returns (google.protobuf.Empty) {} } message PingRequest { diff --git a/test/grpc/test_grpc.pb.go b/test/grpc/test_grpc.pb.go index bd9ecca7..09e0fd76 100644 --- a/test/grpc/test_grpc.pb.go +++ b/test/grpc/test_grpc.pb.go @@ -5,7 +5,7 @@ // versions: // - protoc-gen-go-grpc v1.3.0 // - protoc (unknown) -// source: test/grpc/test.proto +// source: test.proto package grpctest @@ -28,6 +28,7 @@ const ( Test_Bidirectional_FullMethodName = "/grpctest.Test/Bidirectional" Test_Stream_FullMethodName = "/grpctest.Test/Stream" Test_PrintStdio_FullMethodName = "/grpctest.Test/PrintStdio" + Test_Panic_FullMethodName = "/grpctest.Test/Panic" ) // TestClient is the client API for Test service. @@ -39,6 +40,7 @@ type TestClient interface { Bidirectional(ctx context.Context, in *BidirectionalRequest, opts ...grpc.CallOption) (*BidirectionalResponse, error) Stream(ctx context.Context, opts ...grpc.CallOption) (Test_StreamClient, error) PrintStdio(ctx context.Context, in *PrintStdioRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) + Panic(ctx context.Context, in *PanicRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) } type testClient struct { @@ -116,6 +118,15 @@ func (c *testClient) PrintStdio(ctx context.Context, in *PrintStdioRequest, opts return out, nil } +func (c *testClient) Panic(ctx context.Context, in *PanicRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) { + out := new(emptypb.Empty) + err := c.cc.Invoke(ctx, Test_Panic_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // TestServer is the server API for Test service. // All implementations should embed UnimplementedTestServer // for forward compatibility @@ -125,6 +136,7 @@ type TestServer interface { Bidirectional(context.Context, *BidirectionalRequest) (*BidirectionalResponse, error) Stream(Test_StreamServer) error PrintStdio(context.Context, *PrintStdioRequest) (*emptypb.Empty, error) + Panic(context.Context, *PanicRequest) (*emptypb.Empty, error) } // UnimplementedTestServer should be embedded to have forward compatible implementations. @@ -146,6 +158,9 @@ func (UnimplementedTestServer) Stream(Test_StreamServer) error { func (UnimplementedTestServer) PrintStdio(context.Context, *PrintStdioRequest) (*emptypb.Empty, error) { return nil, status.Errorf(codes.Unimplemented, "method PrintStdio not implemented") } +func (UnimplementedTestServer) Panic(context.Context, *PanicRequest) (*emptypb.Empty, error) { + return nil, status.Errorf(codes.Unimplemented, "method Panic not implemented") +} // UnsafeTestServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to TestServer will @@ -256,6 +271,24 @@ func _Test_PrintStdio_Handler(srv interface{}, ctx context.Context, dec func(int return interceptor(ctx, in, info, handler) } +func _Test_Panic_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(PanicRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(TestServer).Panic(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Test_Panic_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(TestServer).Panic(ctx, req.(*PanicRequest)) + } + return interceptor(ctx, in, info, handler) +} + // Test_ServiceDesc is the grpc.ServiceDesc for Test service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -279,6 +312,10 @@ var Test_ServiceDesc = grpc.ServiceDesc{ MethodName: "PrintStdio", Handler: _Test_PrintStdio_Handler, }, + { + MethodName: "Panic", + Handler: _Test_Panic_Handler, + }, }, Streams: []grpc.StreamDesc{ { @@ -288,7 +325,7 @@ var Test_ServiceDesc = grpc.ServiceDesc{ ClientStreams: true, }, }, - Metadata: "test/grpc/test.proto", + Metadata: "test.proto", } const ( @@ -376,5 +413,5 @@ var PingPong_ServiceDesc = grpc.ServiceDesc{ }, }, Streams: []grpc.StreamDesc{}, - Metadata: "test/grpc/test.proto", + Metadata: "test.proto", }