From 34ab77fcb1d40cb2eaa07acdc28ed361a6586303 Mon Sep 17 00:00:00 2001 From: Tom Proctor Date: Wed, 11 Oct 2023 14:10:57 +0100 Subject: [PATCH 1/6] Switch docs and scaffolding to buf: * Delete old generate code * Add buf yaml files * Update .proto files to use relative package paths * Update proto generation docs * Update example python plugin instructions * Updated proto import path for example python plugin * Update .gitignore rules --- buf.gen.yaml | 14 ++++++++++++++ buf.yaml | 7 +++++++ examples/bidirectional/README.md | 4 +--- examples/bidirectional/buf.gen.yaml | 14 ++++++++++++++ examples/bidirectional/buf.yaml | 4 ++++ examples/bidirectional/proto/kv.proto | 1 + examples/grpc/.gitignore | 7 +++---- examples/grpc/README.md | 13 ++++--------- examples/grpc/buf.gen.yaml | 17 +++++++++++++++++ examples/grpc/buf.yaml | 4 ++++ examples/grpc/plugin-python/.gitignore | 1 + examples/grpc/plugin-python/plugin.py | 4 ++-- .../grpc/plugin-python/{ => proto}/kv_pb2.py | 0 .../plugin-python/{ => proto}/kv_pb2_grpc.py | 0 examples/grpc/plugin-python/requirements.txt | 3 +++ examples/grpc/proto/kv.proto | 1 + internal/plugin/gen.go | 6 ------ internal/plugin/grpc_broker.proto | 2 +- internal/plugin/grpc_controller.proto | 2 +- internal/plugin/grpc_stdio.proto | 2 +- test/grpc/gen.go | 6 ------ test/grpc/test.proto | 2 ++ 22 files changed, 81 insertions(+), 33 deletions(-) create mode 100644 buf.gen.yaml create mode 100644 buf.yaml create mode 100644 examples/bidirectional/buf.gen.yaml create mode 100644 examples/bidirectional/buf.yaml create mode 100644 examples/grpc/buf.gen.yaml create mode 100644 examples/grpc/buf.yaml create mode 100644 examples/grpc/plugin-python/.gitignore rename examples/grpc/plugin-python/{ => proto}/kv_pb2.py (100%) rename examples/grpc/plugin-python/{ => proto}/kv_pb2_grpc.py (100%) create mode 100644 examples/grpc/plugin-python/requirements.txt delete mode 100644 internal/plugin/gen.go delete mode 100644 test/grpc/gen.go diff --git a/buf.gen.yaml b/buf.gen.yaml new file mode 100644 index 00000000..26c7d7ea --- /dev/null +++ b/buf.gen.yaml @@ -0,0 +1,14 @@ +# Copyright (c) HashiCorp, Inc. +# SPDX-License-Identifier: MPL-2.0 + +version: v1 +plugins: + - plugin: go + out: . + opt: + - paths=source_relative + - plugin: go-grpc + out: . + opt: + - paths=source_relative + diff --git a/buf.yaml b/buf.yaml new file mode 100644 index 00000000..3d0da4c7 --- /dev/null +++ b/buf.yaml @@ -0,0 +1,7 @@ +# Copyright (c) HashiCorp, Inc. +# SPDX-License-Identifier: MPL-2.0 + +version: v1 +build: + excludes: + - examples/ \ No newline at end of file diff --git a/examples/bidirectional/README.md b/examples/bidirectional/README.md index f128307d..4822bbf0 100644 --- a/examples/bidirectional/README.md +++ b/examples/bidirectional/README.md @@ -41,8 +41,6 @@ If you update the protocol buffers file, you can regenerate the file using the following command from this directory. You do not need to run this if you're just trying the example. -For Go: - ```sh -$ protoc -I proto/ proto/kv.proto --go_out=plugins=grpc:proto/ +$ buf generate ``` diff --git a/examples/bidirectional/buf.gen.yaml b/examples/bidirectional/buf.gen.yaml new file mode 100644 index 00000000..26c7d7ea --- /dev/null +++ b/examples/bidirectional/buf.gen.yaml @@ -0,0 +1,14 @@ +# Copyright (c) HashiCorp, Inc. +# SPDX-License-Identifier: MPL-2.0 + +version: v1 +plugins: + - plugin: go + out: . + opt: + - paths=source_relative + - plugin: go-grpc + out: . + opt: + - paths=source_relative + diff --git a/examples/bidirectional/buf.yaml b/examples/bidirectional/buf.yaml new file mode 100644 index 00000000..0a945b38 --- /dev/null +++ b/examples/bidirectional/buf.yaml @@ -0,0 +1,4 @@ +# Copyright (c) HashiCorp, Inc. +# SPDX-License-Identifier: MPL-2.0 + +version: v1 diff --git a/examples/bidirectional/proto/kv.proto b/examples/bidirectional/proto/kv.proto index eff0c511..312ff47d 100644 --- a/examples/bidirectional/proto/kv.proto +++ b/examples/bidirectional/proto/kv.proto @@ -3,6 +3,7 @@ syntax = "proto3"; package proto; +option go_package = "./proto"; message GetRequest { string key = 1; diff --git a/examples/grpc/.gitignore b/examples/grpc/.gitignore index 953e359b..51a065b1 100644 --- a/examples/grpc/.gitignore +++ b/examples/grpc/.gitignore @@ -1,5 +1,4 @@ *.pyc -kv -kv-* -kv_* -!kv_*.py +/kv +/kv-* +/kv_* diff --git a/examples/grpc/README.md b/examples/grpc/README.md index 7b3b647a..63c4af5e 100644 --- a/examples/grpc/README.md +++ b/examples/grpc/README.md @@ -49,6 +49,9 @@ $ export KV_PLUGIN="./kv-go-netrpc" This plugin is written in Python: ``` +$ python -m venv plugin-python/.venv +$ source plugin-python/.venv/bin/activate +$ pip install -r plugin-python/requirements.txt $ export KV_PLUGIN="python plugin-python/plugin.py" ``` @@ -58,14 +61,6 @@ If you update the protocol buffers file, you can regenerate the file using the following command from this directory. You do not need to run this if you're just trying the example. -For Go: - -```sh -$ protoc -I proto/ proto/kv.proto --go_out=plugins=grpc:proto/ -``` - -For Python: - ```sh -$ python -m grpc_tools.protoc -I ./proto/ --python_out=./plugin-python/ --grpc_python_out=./plugin-python/ ./proto/kv.proto +$ buf generate ``` diff --git a/examples/grpc/buf.gen.yaml b/examples/grpc/buf.gen.yaml new file mode 100644 index 00000000..8c945272 --- /dev/null +++ b/examples/grpc/buf.gen.yaml @@ -0,0 +1,17 @@ +# Copyright (c) HashiCorp, Inc. +# SPDX-License-Identifier: MPL-2.0 + +version: v1 +plugins: + - plugin: go + out: . + opt: + - paths=source_relative + - plugin: go-grpc + out: . + opt: + - paths=source_relative + - plugin: python + out: plugin-python + - plugin: buf.build/grpc/python:v1.58.1 + out: plugin-python diff --git a/examples/grpc/buf.yaml b/examples/grpc/buf.yaml new file mode 100644 index 00000000..0a945b38 --- /dev/null +++ b/examples/grpc/buf.yaml @@ -0,0 +1,4 @@ +# Copyright (c) HashiCorp, Inc. +# SPDX-License-Identifier: MPL-2.0 + +version: v1 diff --git a/examples/grpc/plugin-python/.gitignore b/examples/grpc/plugin-python/.gitignore new file mode 100644 index 00000000..fb9df047 --- /dev/null +++ b/examples/grpc/plugin-python/.gitignore @@ -0,0 +1 @@ +/.venv \ No newline at end of file diff --git a/examples/grpc/plugin-python/plugin.py b/examples/grpc/plugin-python/plugin.py index fa5b18c0..ce5f668d 100644 --- a/examples/grpc/plugin-python/plugin.py +++ b/examples/grpc/plugin-python/plugin.py @@ -7,8 +7,8 @@ import grpc -import kv_pb2 -import kv_pb2_grpc +from proto import kv_pb2 +from proto import kv_pb2_grpc from grpc_health.v1.health import HealthServicer from grpc_health.v1 import health_pb2, health_pb2_grpc diff --git a/examples/grpc/plugin-python/kv_pb2.py b/examples/grpc/plugin-python/proto/kv_pb2.py similarity index 100% rename from examples/grpc/plugin-python/kv_pb2.py rename to examples/grpc/plugin-python/proto/kv_pb2.py diff --git a/examples/grpc/plugin-python/kv_pb2_grpc.py b/examples/grpc/plugin-python/proto/kv_pb2_grpc.py similarity index 100% rename from examples/grpc/plugin-python/kv_pb2_grpc.py rename to examples/grpc/plugin-python/proto/kv_pb2_grpc.py diff --git a/examples/grpc/plugin-python/requirements.txt b/examples/grpc/plugin-python/requirements.txt new file mode 100644 index 00000000..736f742a --- /dev/null +++ b/examples/grpc/plugin-python/requirements.txt @@ -0,0 +1,3 @@ +grpcio==1.59.0 +grpcio-health-checking==1.59.0 +protobuf==4.24.4 diff --git a/examples/grpc/proto/kv.proto b/examples/grpc/proto/kv.proto index 516c5174..ab59b5d5 100644 --- a/examples/grpc/proto/kv.proto +++ b/examples/grpc/proto/kv.proto @@ -3,6 +3,7 @@ syntax = "proto3"; package proto; +option go_package = "./proto"; message GetRequest { string key = 1; diff --git a/internal/plugin/gen.go b/internal/plugin/gen.go deleted file mode 100644 index a3b5fb12..00000000 --- a/internal/plugin/gen.go +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -//go:generate protoc -I ./ ./grpc_broker.proto ./grpc_controller.proto ./grpc_stdio.proto --go_out=plugins=grpc:. - -package plugin diff --git a/internal/plugin/grpc_broker.proto b/internal/plugin/grpc_broker.proto index 038423de..195ca16e 100644 --- a/internal/plugin/grpc_broker.proto +++ b/internal/plugin/grpc_broker.proto @@ -3,7 +3,7 @@ syntax = "proto3"; package plugin; -option go_package = "plugin"; +option go_package = "./plugin"; message ConnInfo { uint32 service_id = 1; diff --git a/internal/plugin/grpc_controller.proto b/internal/plugin/grpc_controller.proto index 3157eb88..2755fa63 100644 --- a/internal/plugin/grpc_controller.proto +++ b/internal/plugin/grpc_controller.proto @@ -3,7 +3,7 @@ syntax = "proto3"; package plugin; -option go_package = "plugin"; +option go_package = "./plugin"; message Empty { } diff --git a/internal/plugin/grpc_stdio.proto b/internal/plugin/grpc_stdio.proto index 1c0d1d05..f48ac76c 100644 --- a/internal/plugin/grpc_stdio.proto +++ b/internal/plugin/grpc_stdio.proto @@ -3,7 +3,7 @@ syntax = "proto3"; package plugin; -option go_package = "plugin"; +option go_package = "./plugin"; import "google/protobuf/empty.proto"; diff --git a/test/grpc/gen.go b/test/grpc/gen.go deleted file mode 100644 index daf7efe0..00000000 --- a/test/grpc/gen.go +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package grpctest - -//go:generate protoc -I ./ ./test.proto --go_out=plugins=grpc:. diff --git a/test/grpc/test.proto b/test/grpc/test.proto index 2501ec50..9204ae5c 100644 --- a/test/grpc/test.proto +++ b/test/grpc/test.proto @@ -5,6 +5,8 @@ syntax = "proto3"; package grpctest; +option go_package = "./grpctest"; + import "google/protobuf/empty.proto"; message TestRequest { From 6817befe708fd46f2b3ffbc95c592a9fb0efab6b Mon Sep 17 00:00:00 2001 From: Tom Proctor Date: Thu, 12 Oct 2023 10:48:05 +0100 Subject: [PATCH 2/6] buf generate --- examples/bidirectional/proto/kv.pb.go | 643 +++++---- examples/bidirectional/proto/kv_grpc.pb.go | 223 +++ examples/grpc/plugin-python/proto/kv_pb2.py | 328 +---- .../grpc/plugin-python/proto/kv_pb2_grpc.py | 125 +- examples/grpc/proto/kv.pb.go | 440 +++--- examples/grpc/proto/kv_grpc.pb.go | 137 ++ internal/plugin/grpc_broker.pb.go | 297 ++-- internal/plugin/grpc_broker_grpc.pb.go | 133 ++ internal/plugin/grpc_controller.pb.go | 224 ++- internal/plugin/grpc_controller_grpc.pb.go | 101 ++ internal/plugin/grpc_stdio.pb.go | 356 +++-- internal/plugin/grpc_stdio_grpc.pb.go | 139 ++ test/grpc/test.pb.go | 1201 ++++++++--------- test/grpc/test_grpc.pb.go | 365 +++++ 14 files changed, 2842 insertions(+), 1870 deletions(-) create mode 100644 examples/bidirectional/proto/kv_grpc.pb.go create mode 100644 examples/grpc/proto/kv_grpc.pb.go create mode 100644 internal/plugin/grpc_broker_grpc.pb.go create mode 100644 internal/plugin/grpc_controller_grpc.pb.go create mode 100644 internal/plugin/grpc_stdio_grpc.pb.go create mode 100644 test/grpc/test_grpc.pb.go diff --git a/examples/bidirectional/proto/kv.pb.go b/examples/bidirectional/proto/kv.pb.go index 59aed9f5..04951566 100644 --- a/examples/bidirectional/proto/kv.pb.go +++ b/examples/bidirectional/proto/kv.pb.go @@ -1,350 +1,487 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + // Code generated by protoc-gen-go. DO NOT EDIT. -// source: kv.proto - -/* -Package proto is a generated protocol buffer package. - -It is generated from these files: - kv.proto - -It has these top-level messages: - GetRequest - GetResponse - PutRequest - Empty - SumRequest - SumResponse -*/ -package proto +// versions: +// protoc-gen-go v1.28.1 +// protoc (unknown) +// source: proto/kv.proto -import proto1 "github.com/golang/protobuf/proto" -import fmt "fmt" -import math "math" +package proto import ( - context "context" - grpc "google.golang.org/grpc" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" ) -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto1.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto1.ProtoPackageIsVersion2 // please upgrade the proto package +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) type GetRequest struct { - Key string `protobuf:"bytes,1,opt,name=key" json:"key,omitempty"` + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` +} + +func (x *GetRequest) Reset() { + *x = GetRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_proto_kv_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *GetRequest) Reset() { *m = GetRequest{} } -func (m *GetRequest) String() string { return proto1.CompactTextString(m) } -func (*GetRequest) ProtoMessage() {} -func (*GetRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } +func (x *GetRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetRequest) ProtoMessage() {} -func (m *GetRequest) GetKey() string { - if m != nil { - return m.Key +func (x *GetRequest) ProtoReflect() protoreflect.Message { + mi := &file_proto_kv_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetRequest.ProtoReflect.Descriptor instead. +func (*GetRequest) Descriptor() ([]byte, []int) { + return file_proto_kv_proto_rawDescGZIP(), []int{0} +} + +func (x *GetRequest) GetKey() string { + if x != nil { + return x.Key } return "" } type GetResponse struct { - Value int64 `protobuf:"varint,1,opt,name=value" json:"value,omitempty"` -} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func (m *GetResponse) Reset() { *m = GetResponse{} } -func (m *GetResponse) String() string { return proto1.CompactTextString(m) } -func (*GetResponse) ProtoMessage() {} -func (*GetResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} } + Value int64 `protobuf:"varint,1,opt,name=value,proto3" json:"value,omitempty"` +} -func (m *GetResponse) GetValue() int64 { - if m != nil { - return m.Value +func (x *GetResponse) Reset() { + *x = GetResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_proto_kv_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } - return 0 } -type PutRequest struct { - AddServer uint32 `protobuf:"varint,1,opt,name=add_server,json=addServer" json:"add_server,omitempty"` - Key string `protobuf:"bytes,2,opt,name=key" json:"key,omitempty"` - Value int64 `protobuf:"varint,3,opt,name=value" json:"value,omitempty"` +func (x *GetResponse) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *PutRequest) Reset() { *m = PutRequest{} } -func (m *PutRequest) String() string { return proto1.CompactTextString(m) } -func (*PutRequest) ProtoMessage() {} -func (*PutRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} } +func (*GetResponse) ProtoMessage() {} -func (m *PutRequest) GetAddServer() uint32 { - if m != nil { - return m.AddServer +func (x *GetResponse) ProtoReflect() protoreflect.Message { + mi := &file_proto_kv_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms } - return 0 + return mi.MessageOf(x) } -func (m *PutRequest) GetKey() string { - if m != nil { - return m.Key - } - return "" +// Deprecated: Use GetResponse.ProtoReflect.Descriptor instead. +func (*GetResponse) Descriptor() ([]byte, []int) { + return file_proto_kv_proto_rawDescGZIP(), []int{1} } -func (m *PutRequest) GetValue() int64 { - if m != nil { - return m.Value +func (x *GetResponse) GetValue() int64 { + if x != nil { + return x.Value } return 0 } -type Empty struct { +type PutRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + AddServer uint32 `protobuf:"varint,1,opt,name=add_server,json=addServer,proto3" json:"add_server,omitempty"` + Key string `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"` + Value int64 `protobuf:"varint,3,opt,name=value,proto3" json:"value,omitempty"` } -func (m *Empty) Reset() { *m = Empty{} } -func (m *Empty) String() string { return proto1.CompactTextString(m) } -func (*Empty) ProtoMessage() {} -func (*Empty) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} } +func (x *PutRequest) Reset() { + *x = PutRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_proto_kv_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} -type SumRequest struct { - A int64 `protobuf:"varint,1,opt,name=a" json:"a,omitempty"` - B int64 `protobuf:"varint,2,opt,name=b" json:"b,omitempty"` +func (x *PutRequest) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *SumRequest) Reset() { *m = SumRequest{} } -func (m *SumRequest) String() string { return proto1.CompactTextString(m) } -func (*SumRequest) ProtoMessage() {} -func (*SumRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{4} } +func (*PutRequest) ProtoMessage() {} -func (m *SumRequest) GetA() int64 { - if m != nil { - return m.A +func (x *PutRequest) ProtoReflect() protoreflect.Message { + mi := &file_proto_kv_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms } - return 0 + return mi.MessageOf(x) +} + +// Deprecated: Use PutRequest.ProtoReflect.Descriptor instead. +func (*PutRequest) Descriptor() ([]byte, []int) { + return file_proto_kv_proto_rawDescGZIP(), []int{2} } -func (m *SumRequest) GetB() int64 { - if m != nil { - return m.B +func (x *PutRequest) GetAddServer() uint32 { + if x != nil { + return x.AddServer } return 0 } -type SumResponse struct { - R int64 `protobuf:"varint,1,opt,name=r" json:"r,omitempty"` +func (x *PutRequest) GetKey() string { + if x != nil { + return x.Key + } + return "" } -func (m *SumResponse) Reset() { *m = SumResponse{} } -func (m *SumResponse) String() string { return proto1.CompactTextString(m) } -func (*SumResponse) ProtoMessage() {} -func (*SumResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{5} } - -func (m *SumResponse) GetR() int64 { - if m != nil { - return m.R +func (x *PutRequest) GetValue() int64 { + if x != nil { + return x.Value } return 0 } -func init() { - proto1.RegisterType((*GetRequest)(nil), "proto.GetRequest") - proto1.RegisterType((*GetResponse)(nil), "proto.GetResponse") - proto1.RegisterType((*PutRequest)(nil), "proto.PutRequest") - proto1.RegisterType((*Empty)(nil), "proto.Empty") - proto1.RegisterType((*SumRequest)(nil), "proto.SumRequest") - proto1.RegisterType((*SumResponse)(nil), "proto.SumResponse") +type Empty struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields } -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn +func (x *Empty) Reset() { + *x = Empty{} + if protoimpl.UnsafeEnabled { + mi := &file_proto_kv_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 +func (x *Empty) String() string { + return protoimpl.X.MessageStringOf(x) +} -// Client API for Counter service +func (*Empty) ProtoMessage() {} -type CounterClient interface { - Get(ctx context.Context, in *GetRequest, opts ...grpc.CallOption) (*GetResponse, error) - Put(ctx context.Context, in *PutRequest, opts ...grpc.CallOption) (*Empty, error) +func (x *Empty) ProtoReflect() protoreflect.Message { + mi := &file_proto_kv_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -type counterClient struct { - cc *grpc.ClientConn +// Deprecated: Use Empty.ProtoReflect.Descriptor instead. +func (*Empty) Descriptor() ([]byte, []int) { + return file_proto_kv_proto_rawDescGZIP(), []int{3} } -func NewCounterClient(cc *grpc.ClientConn) CounterClient { - return &counterClient{cc} +type SumRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + A int64 `protobuf:"varint,1,opt,name=a,proto3" json:"a,omitempty"` + B int64 `protobuf:"varint,2,opt,name=b,proto3" json:"b,omitempty"` } -func (c *counterClient) Get(ctx context.Context, in *GetRequest, opts ...grpc.CallOption) (*GetResponse, error) { - out := new(GetResponse) - err := grpc.Invoke(ctx, "/proto.Counter/Get", in, out, c.cc, opts...) - if err != nil { - return nil, err +func (x *SumRequest) Reset() { + *x = SumRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_proto_kv_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } - return out, nil } -func (c *counterClient) Put(ctx context.Context, in *PutRequest, opts ...grpc.CallOption) (*Empty, error) { - out := new(Empty) - err := grpc.Invoke(ctx, "/proto.Counter/Put", in, out, c.cc, opts...) - if err != nil { - return nil, err - } - return out, nil +func (x *SumRequest) String() string { + return protoimpl.X.MessageStringOf(x) } -// Server API for Counter service +func (*SumRequest) ProtoMessage() {} -type CounterServer interface { - Get(context.Context, *GetRequest) (*GetResponse, error) - Put(context.Context, *PutRequest) (*Empty, error) +func (x *SumRequest) ProtoReflect() protoreflect.Message { + mi := &file_proto_kv_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -func RegisterCounterServer(s *grpc.Server, srv CounterServer) { - s.RegisterService(&_Counter_serviceDesc, srv) +// Deprecated: Use SumRequest.ProtoReflect.Descriptor instead. +func (*SumRequest) Descriptor() ([]byte, []int) { + return file_proto_kv_proto_rawDescGZIP(), []int{4} } -func _Counter_Get_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(CounterServer).Get(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/proto.Counter/Get", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(CounterServer).Get(ctx, req.(*GetRequest)) +func (x *SumRequest) GetA() int64 { + if x != nil { + return x.A } - return interceptor(ctx, in, info, handler) + return 0 } -func _Counter_Put_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(PutRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(CounterServer).Put(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/proto.Counter/Put", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(CounterServer).Put(ctx, req.(*PutRequest)) +func (x *SumRequest) GetB() int64 { + if x != nil { + return x.B } - return interceptor(ctx, in, info, handler) -} - -var _Counter_serviceDesc = grpc.ServiceDesc{ - ServiceName: "proto.Counter", - HandlerType: (*CounterServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Get", - Handler: _Counter_Get_Handler, - }, - { - MethodName: "Put", - Handler: _Counter_Put_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "kv.proto", + return 0 } -// Client API for AddHelper service +type SumResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -type AddHelperClient interface { - Sum(ctx context.Context, in *SumRequest, opts ...grpc.CallOption) (*SumResponse, error) + R int64 `protobuf:"varint,1,opt,name=r,proto3" json:"r,omitempty"` } -type addHelperClient struct { - cc *grpc.ClientConn +func (x *SumResponse) Reset() { + *x = SumResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_proto_kv_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func NewAddHelperClient(cc *grpc.ClientConn) AddHelperClient { - return &addHelperClient{cc} +func (x *SumResponse) String() string { + return protoimpl.X.MessageStringOf(x) } -func (c *addHelperClient) Sum(ctx context.Context, in *SumRequest, opts ...grpc.CallOption) (*SumResponse, error) { - out := new(SumResponse) - err := grpc.Invoke(ctx, "/proto.AddHelper/Sum", in, out, c.cc, opts...) - if err != nil { - return nil, err +func (*SumResponse) ProtoMessage() {} + +func (x *SumResponse) ProtoReflect() protoreflect.Message { + mi := &file_proto_kv_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms } - return out, nil + return mi.MessageOf(x) } -// Server API for AddHelper service - -type AddHelperServer interface { - Sum(context.Context, *SumRequest) (*SumResponse, error) +// Deprecated: Use SumResponse.ProtoReflect.Descriptor instead. +func (*SumResponse) Descriptor() ([]byte, []int) { + return file_proto_kv_proto_rawDescGZIP(), []int{5} } -func RegisterAddHelperServer(s *grpc.Server, srv AddHelperServer) { - s.RegisterService(&_AddHelper_serviceDesc, srv) +func (x *SumResponse) GetR() int64 { + if x != nil { + return x.R + } + return 0 } -func _AddHelper_Sum_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(SumRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(AddHelperServer).Sum(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/proto.AddHelper/Sum", +var File_proto_kv_proto protoreflect.FileDescriptor + +var file_proto_kv_proto_rawDesc = []byte{ + 0x0a, 0x0e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x6b, 0x76, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x12, 0x05, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x1e, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x22, 0x23, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x53, 0x0a, 0x0a, + 0x50, 0x75, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x61, 0x64, + 0x64, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, + 0x61, 0x64, 0x64, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, + 0x65, 0x22, 0x07, 0x0a, 0x05, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x28, 0x0a, 0x0a, 0x53, 0x75, + 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0c, 0x0a, 0x01, 0x61, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x03, 0x52, 0x01, 0x61, 0x12, 0x0c, 0x0a, 0x01, 0x62, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x03, 0x52, 0x01, 0x62, 0x22, 0x1b, 0x0a, 0x0b, 0x53, 0x75, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x0c, 0x0a, 0x01, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x01, + 0x72, 0x32, 0x5f, 0x0a, 0x07, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x65, 0x72, 0x12, 0x2c, 0x0a, 0x03, + 0x47, 0x65, 0x74, 0x12, 0x11, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x47, 0x65, 0x74, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x47, + 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x26, 0x0a, 0x03, 0x50, 0x75, + 0x74, 0x12, 0x11, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x75, 0x74, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x45, 0x6d, 0x70, + 0x74, 0x79, 0x32, 0x39, 0x0a, 0x09, 0x41, 0x64, 0x64, 0x48, 0x65, 0x6c, 0x70, 0x65, 0x72, 0x12, + 0x2c, 0x0a, 0x03, 0x53, 0x75, 0x6d, 0x12, 0x11, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x53, + 0x75, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x2e, 0x53, 0x75, 0x6d, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x09, 0x5a, + 0x07, 0x2e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_proto_kv_proto_rawDescOnce sync.Once + file_proto_kv_proto_rawDescData = file_proto_kv_proto_rawDesc +) + +func file_proto_kv_proto_rawDescGZIP() []byte { + file_proto_kv_proto_rawDescOnce.Do(func() { + file_proto_kv_proto_rawDescData = protoimpl.X.CompressGZIP(file_proto_kv_proto_rawDescData) + }) + return file_proto_kv_proto_rawDescData +} + +var file_proto_kv_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_proto_kv_proto_goTypes = []interface{}{ + (*GetRequest)(nil), // 0: proto.GetRequest + (*GetResponse)(nil), // 1: proto.GetResponse + (*PutRequest)(nil), // 2: proto.PutRequest + (*Empty)(nil), // 3: proto.Empty + (*SumRequest)(nil), // 4: proto.SumRequest + (*SumResponse)(nil), // 5: proto.SumResponse +} +var file_proto_kv_proto_depIdxs = []int32{ + 0, // 0: proto.Counter.Get:input_type -> proto.GetRequest + 2, // 1: proto.Counter.Put:input_type -> proto.PutRequest + 4, // 2: proto.AddHelper.Sum:input_type -> proto.SumRequest + 1, // 3: proto.Counter.Get:output_type -> proto.GetResponse + 3, // 4: proto.Counter.Put:output_type -> proto.Empty + 5, // 5: proto.AddHelper.Sum:output_type -> proto.SumResponse + 3, // [3:6] is the sub-list for method output_type + 0, // [0:3] 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_proto_kv_proto_init() } +func file_proto_kv_proto_init() { + if File_proto_kv_proto != nil { + return } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(AddHelperServer).Sum(ctx, req.(*SumRequest)) + if !protoimpl.UnsafeEnabled { + file_proto_kv_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_proto_kv_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_proto_kv_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PutRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_proto_kv_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Empty); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_proto_kv_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SumRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_proto_kv_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SumResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } - return interceptor(ctx, in, info, handler) -} - -var _AddHelper_serviceDesc = grpc.ServiceDesc{ - ServiceName: "proto.AddHelper", - HandlerType: (*AddHelperServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Sum", - Handler: _AddHelper_Sum_Handler, + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_proto_kv_proto_rawDesc, + NumEnums: 0, + NumMessages: 6, + NumExtensions: 0, + NumServices: 2, }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "kv.proto", -} - -func init() { proto1.RegisterFile("kv.proto", fileDescriptor0) } - -var fileDescriptor0 = []byte{ - // 253 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x90, 0x4f, 0x4b, 0x03, 0x31, - 0x10, 0xc5, 0x89, 0x61, 0xad, 0xfb, 0xba, 0x82, 0x06, 0x0f, 0x52, 0x51, 0x24, 0x82, 0xf4, 0x20, - 0x3d, 0xd4, 0x93, 0x47, 0x11, 0xa9, 0xc7, 0x92, 0xfd, 0x00, 0x25, 0x4b, 0xe6, 0xd4, 0x6e, 0x77, - 0xcd, 0x26, 0x0b, 0xfd, 0xf6, 0xa5, 0xd9, 0x3f, 0xd9, 0x53, 0x32, 0x2f, 0x2f, 0xbf, 0x37, 0x33, - 0xb8, 0xd9, 0xb7, 0xab, 0xda, 0x56, 0xae, 0x12, 0x49, 0x38, 0xe4, 0x0b, 0xb0, 0x21, 0xa7, 0xe8, - 0xdf, 0x53, 0xe3, 0xc4, 0x1d, 0xf8, 0x9e, 0x4e, 0x8f, 0xec, 0x95, 0x2d, 0x53, 0x75, 0xb9, 0xca, - 0x37, 0xcc, 0xc3, 0x7b, 0x53, 0x57, 0xc7, 0x86, 0xc4, 0x03, 0x92, 0x56, 0x1f, 0x3c, 0x05, 0x0b, - 0x57, 0x5d, 0x21, 0x73, 0x60, 0xeb, 0x47, 0xc8, 0x33, 0xa0, 0x8d, 0xd9, 0x35, 0x64, 0x5b, 0xb2, - 0xc1, 0x78, 0xab, 0x52, 0x6d, 0x4c, 0x1e, 0x84, 0x21, 0xe3, 0x6a, 0xcc, 0x88, 0x50, 0x3e, 0x85, - 0xce, 0x90, 0xfc, 0x96, 0xb5, 0x3b, 0xc9, 0x25, 0x90, 0xfb, 0x72, 0xa0, 0x67, 0x60, 0xba, 0x4f, - 0x67, 0xfa, 0x52, 0x15, 0x01, 0xc5, 0x15, 0x2b, 0xe4, 0x13, 0xe6, 0xc1, 0xd9, 0x37, 0x9b, 0x81, - 0xd9, 0xc1, 0x6a, 0xd7, 0x3b, 0xcc, 0x7e, 0x2a, 0x7f, 0x74, 0x64, 0xc5, 0x07, 0xf8, 0x86, 0x9c, - 0xb8, 0xef, 0x56, 0xb1, 0x8a, 0x0b, 0x58, 0x88, 0xa9, 0xd4, 0x63, 0xde, 0xc1, 0xb7, 0x3e, 0xba, - 0xe3, 0xa4, 0x8b, 0xac, 0x97, 0x42, 0x9f, 0xeb, 0x2f, 0xa4, 0xdf, 0xc6, 0xfc, 0xd1, 0xa1, 0xee, - 0x22, 0x72, 0x5f, 0x8e, 0x9f, 0xe2, 0x00, 0x63, 0xc4, 0xa4, 0xd3, 0xe2, 0x3a, 0x48, 0x9f, 0xe7, - 0x00, 0x00, 0x00, 0xff, 0xff, 0x40, 0xa3, 0x85, 0x07, 0x9f, 0x01, 0x00, 0x00, + GoTypes: file_proto_kv_proto_goTypes, + DependencyIndexes: file_proto_kv_proto_depIdxs, + MessageInfos: file_proto_kv_proto_msgTypes, + }.Build() + File_proto_kv_proto = out.File + file_proto_kv_proto_rawDesc = nil + file_proto_kv_proto_goTypes = nil + file_proto_kv_proto_depIdxs = nil } diff --git a/examples/bidirectional/proto/kv_grpc.pb.go b/examples/bidirectional/proto/kv_grpc.pb.go new file mode 100644 index 00000000..186fec2c --- /dev/null +++ b/examples/bidirectional/proto/kv_grpc.pb.go @@ -0,0 +1,223 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. + +package proto + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +// CounterClient is the client API for Counter service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type CounterClient interface { + Get(ctx context.Context, in *GetRequest, opts ...grpc.CallOption) (*GetResponse, error) + Put(ctx context.Context, in *PutRequest, opts ...grpc.CallOption) (*Empty, error) +} + +type counterClient struct { + cc grpc.ClientConnInterface +} + +func NewCounterClient(cc grpc.ClientConnInterface) CounterClient { + return &counterClient{cc} +} + +func (c *counterClient) Get(ctx context.Context, in *GetRequest, opts ...grpc.CallOption) (*GetResponse, error) { + out := new(GetResponse) + err := c.cc.Invoke(ctx, "/proto.Counter/Get", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *counterClient) Put(ctx context.Context, in *PutRequest, opts ...grpc.CallOption) (*Empty, error) { + out := new(Empty) + err := c.cc.Invoke(ctx, "/proto.Counter/Put", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// CounterServer is the server API for Counter service. +// All implementations must embed UnimplementedCounterServer +// for forward compatibility +type CounterServer interface { + Get(context.Context, *GetRequest) (*GetResponse, error) + Put(context.Context, *PutRequest) (*Empty, error) + mustEmbedUnimplementedCounterServer() +} + +// UnimplementedCounterServer must be embedded to have forward compatible implementations. +type UnimplementedCounterServer struct { +} + +func (UnimplementedCounterServer) Get(context.Context, *GetRequest) (*GetResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Get not implemented") +} +func (UnimplementedCounterServer) Put(context.Context, *PutRequest) (*Empty, error) { + return nil, status.Errorf(codes.Unimplemented, "method Put not implemented") +} +func (UnimplementedCounterServer) mustEmbedUnimplementedCounterServer() {} + +// UnsafeCounterServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to CounterServer will +// result in compilation errors. +type UnsafeCounterServer interface { + mustEmbedUnimplementedCounterServer() +} + +func RegisterCounterServer(s grpc.ServiceRegistrar, srv CounterServer) { + s.RegisterService(&Counter_ServiceDesc, srv) +} + +func _Counter_Get_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(CounterServer).Get(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/proto.Counter/Get", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(CounterServer).Get(ctx, req.(*GetRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Counter_Put_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(PutRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(CounterServer).Put(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/proto.Counter/Put", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(CounterServer).Put(ctx, req.(*PutRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// Counter_ServiceDesc is the grpc.ServiceDesc for Counter service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var Counter_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "proto.Counter", + HandlerType: (*CounterServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Get", + Handler: _Counter_Get_Handler, + }, + { + MethodName: "Put", + Handler: _Counter_Put_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "proto/kv.proto", +} + +// AddHelperClient is the client API for AddHelper service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type AddHelperClient interface { + Sum(ctx context.Context, in *SumRequest, opts ...grpc.CallOption) (*SumResponse, error) +} + +type addHelperClient struct { + cc grpc.ClientConnInterface +} + +func NewAddHelperClient(cc grpc.ClientConnInterface) AddHelperClient { + return &addHelperClient{cc} +} + +func (c *addHelperClient) Sum(ctx context.Context, in *SumRequest, opts ...grpc.CallOption) (*SumResponse, error) { + out := new(SumResponse) + err := c.cc.Invoke(ctx, "/proto.AddHelper/Sum", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// AddHelperServer is the server API for AddHelper service. +// All implementations must embed UnimplementedAddHelperServer +// for forward compatibility +type AddHelperServer interface { + Sum(context.Context, *SumRequest) (*SumResponse, error) + mustEmbedUnimplementedAddHelperServer() +} + +// UnimplementedAddHelperServer must be embedded to have forward compatible implementations. +type UnimplementedAddHelperServer struct { +} + +func (UnimplementedAddHelperServer) Sum(context.Context, *SumRequest) (*SumResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Sum not implemented") +} +func (UnimplementedAddHelperServer) mustEmbedUnimplementedAddHelperServer() {} + +// UnsafeAddHelperServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to AddHelperServer will +// result in compilation errors. +type UnsafeAddHelperServer interface { + mustEmbedUnimplementedAddHelperServer() +} + +func RegisterAddHelperServer(s grpc.ServiceRegistrar, srv AddHelperServer) { + s.RegisterService(&AddHelper_ServiceDesc, srv) +} + +func _AddHelper_Sum_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(SumRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AddHelperServer).Sum(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/proto.AddHelper/Sum", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AddHelperServer).Sum(ctx, req.(*SumRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// AddHelper_ServiceDesc is the grpc.ServiceDesc for AddHelper service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var AddHelper_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "proto.AddHelper", + HandlerType: (*AddHelperServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Sum", + Handler: _AddHelper_Sum_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "proto/kv.proto", +} diff --git a/examples/grpc/plugin-python/proto/kv_pb2.py b/examples/grpc/plugin-python/proto/kv_pb2.py index 7221ca1e..c44c5b8e 100644 --- a/examples/grpc/plugin-python/proto/kv_pb2.py +++ b/examples/grpc/plugin-python/proto/kv_pb2.py @@ -1,16 +1,11 @@ -# Copyright (c) HashiCorp, Inc. -# SPDX-License-Identifier: MPL-2.0 - +# -*- coding: utf-8 -*- # Generated by the protocol buffer compiler. DO NOT EDIT! -# source: kv.proto - -import sys -_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1')) +# source: proto/kv.proto +"""Generated protocol buffer code.""" +from google.protobuf.internal import builder as _builder from google.protobuf import descriptor as _descriptor -from google.protobuf import message as _message -from google.protobuf import reflection as _reflection +from google.protobuf import descriptor_pool as _descriptor_pool from google.protobuf import symbol_database as _symbol_database -from google.protobuf import descriptor_pb2 # @@protoc_insertion_point(imports) _sym_db = _symbol_database.Default() @@ -18,303 +13,22 @@ -DESCRIPTOR = _descriptor.FileDescriptor( - name='kv.proto', - package='proto', - syntax='proto3', - serialized_pb=_b('\n\x08kv.proto\x12\x05proto\"\x19\n\nGetRequest\x12\x0b\n\x03key\x18\x01 \x01(\t\"\x1c\n\x0bGetResponse\x12\r\n\x05value\x18\x01 \x01(\x0c\"(\n\nPutRequest\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\x0c\"\x07\n\x05\x45mpty2Z\n\x02KV\x12,\n\x03Get\x12\x11.proto.GetRequest\x1a\x12.proto.GetResponse\x12&\n\x03Put\x12\x11.proto.PutRequest\x1a\x0c.proto.Emptyb\x06proto3') -) -_sym_db.RegisterFileDescriptor(DESCRIPTOR) - - - - -_GETREQUEST = _descriptor.Descriptor( - name='GetRequest', - full_name='proto.GetRequest', - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name='key', full_name='proto.GetRequest.key', index=0, - number=1, type=9, cpp_type=9, label=1, - has_default_value=False, default_value=_b("").decode('utf-8'), - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - options=None), - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=19, - serialized_end=44, -) - - -_GETRESPONSE = _descriptor.Descriptor( - name='GetResponse', - full_name='proto.GetResponse', - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name='value', full_name='proto.GetResponse.value', index=0, - number=1, type=12, cpp_type=9, label=1, - has_default_value=False, default_value=_b(""), - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - options=None), - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=46, - serialized_end=74, -) - - -_PUTREQUEST = _descriptor.Descriptor( - name='PutRequest', - full_name='proto.PutRequest', - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name='key', full_name='proto.PutRequest.key', index=0, - number=1, type=9, cpp_type=9, label=1, - has_default_value=False, default_value=_b("").decode('utf-8'), - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - options=None), - _descriptor.FieldDescriptor( - name='value', full_name='proto.PutRequest.value', index=1, - number=2, type=12, cpp_type=9, label=1, - has_default_value=False, default_value=_b(""), - message_type=None, enum_type=None, containing_type=None, - is_extension=False, extension_scope=None, - options=None), - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=76, - serialized_end=116, -) - - -_EMPTY = _descriptor.Descriptor( - name='Empty', - full_name='proto.Empty', - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - ], - extensions=[ - ], - nested_types=[], - enum_types=[ - ], - options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[ - ], - serialized_start=118, - serialized_end=125, -) - -DESCRIPTOR.message_types_by_name['GetRequest'] = _GETREQUEST -DESCRIPTOR.message_types_by_name['GetResponse'] = _GETRESPONSE -DESCRIPTOR.message_types_by_name['PutRequest'] = _PUTREQUEST -DESCRIPTOR.message_types_by_name['Empty'] = _EMPTY - -GetRequest = _reflection.GeneratedProtocolMessageType('GetRequest', (_message.Message,), dict( - DESCRIPTOR = _GETREQUEST, - __module__ = 'kv_pb2' - # @@protoc_insertion_point(class_scope:proto.GetRequest) - )) -_sym_db.RegisterMessage(GetRequest) - -GetResponse = _reflection.GeneratedProtocolMessageType('GetResponse', (_message.Message,), dict( - DESCRIPTOR = _GETRESPONSE, - __module__ = 'kv_pb2' - # @@protoc_insertion_point(class_scope:proto.GetResponse) - )) -_sym_db.RegisterMessage(GetResponse) - -PutRequest = _reflection.GeneratedProtocolMessageType('PutRequest', (_message.Message,), dict( - DESCRIPTOR = _PUTREQUEST, - __module__ = 'kv_pb2' - # @@protoc_insertion_point(class_scope:proto.PutRequest) - )) -_sym_db.RegisterMessage(PutRequest) - -Empty = _reflection.GeneratedProtocolMessageType('Empty', (_message.Message,), dict( - DESCRIPTOR = _EMPTY, - __module__ = 'kv_pb2' - # @@protoc_insertion_point(class_scope:proto.Empty) - )) -_sym_db.RegisterMessage(Empty) - - -try: - # THESE ELEMENTS WILL BE DEPRECATED. - # Please use the generated *_pb2_grpc.py files instead. - import grpc - from grpc.beta import implementations as beta_implementations - from grpc.beta import interfaces as beta_interfaces - from grpc.framework.common import cardinality - from grpc.framework.interfaces.face import utilities as face_utilities - - - class KVStub(object): - - def __init__(self, channel): - """Constructor. - - Args: - channel: A grpc.Channel. - """ - self.Get = channel.unary_unary( - '/proto.KV/Get', - request_serializer=GetRequest.SerializeToString, - response_deserializer=GetResponse.FromString, - ) - self.Put = channel.unary_unary( - '/proto.KV/Put', - request_serializer=PutRequest.SerializeToString, - response_deserializer=Empty.FromString, - ) - - - class KVServicer(object): - - def Get(self, request, context): - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def Put(self, request, context): - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - - def add_KVServicer_to_server(servicer, server): - rpc_method_handlers = { - 'Get': grpc.unary_unary_rpc_method_handler( - servicer.Get, - request_deserializer=GetRequest.FromString, - response_serializer=GetResponse.SerializeToString, - ), - 'Put': grpc.unary_unary_rpc_method_handler( - servicer.Put, - request_deserializer=PutRequest.FromString, - response_serializer=Empty.SerializeToString, - ), - } - generic_handler = grpc.method_handlers_generic_handler( - 'proto.KV', rpc_method_handlers) - server.add_generic_rpc_handlers((generic_handler,)) - - - class BetaKVServicer(object): - """The Beta API is deprecated for 0.15.0 and later. - - It is recommended to use the GA API (classes and functions in this - file not marked beta) for all further purposes. This class was generated - only to ease transition from grpcio<0.15.0 to grpcio>=0.15.0.""" - def Get(self, request, context): - context.code(beta_interfaces.StatusCode.UNIMPLEMENTED) - def Put(self, request, context): - context.code(beta_interfaces.StatusCode.UNIMPLEMENTED) - - - class BetaKVStub(object): - """The Beta API is deprecated for 0.15.0 and later. - - It is recommended to use the GA API (classes and functions in this - file not marked beta) for all further purposes. This class was generated - only to ease transition from grpcio<0.15.0 to grpcio>=0.15.0.""" - def Get(self, request, timeout, metadata=None, with_call=False, protocol_options=None): - raise NotImplementedError() - Get.future = None - def Put(self, request, timeout, metadata=None, with_call=False, protocol_options=None): - raise NotImplementedError() - Put.future = None - - - def beta_create_KV_server(servicer, pool=None, pool_size=None, default_timeout=None, maximum_timeout=None): - """The Beta API is deprecated for 0.15.0 and later. - - It is recommended to use the GA API (classes and functions in this - file not marked beta) for all further purposes. This function was - generated only to ease transition from grpcio<0.15.0 to grpcio>=0.15.0""" - request_deserializers = { - ('proto.KV', 'Get'): GetRequest.FromString, - ('proto.KV', 'Put'): PutRequest.FromString, - } - response_serializers = { - ('proto.KV', 'Get'): GetResponse.SerializeToString, - ('proto.KV', 'Put'): Empty.SerializeToString, - } - method_implementations = { - ('proto.KV', 'Get'): face_utilities.unary_unary_inline(servicer.Get), - ('proto.KV', 'Put'): face_utilities.unary_unary_inline(servicer.Put), - } - server_options = beta_implementations.server_options(request_deserializers=request_deserializers, response_serializers=response_serializers, thread_pool=pool, thread_pool_size=pool_size, default_timeout=default_timeout, maximum_timeout=maximum_timeout) - return beta_implementations.server(method_implementations, options=server_options) - +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0eproto/kv.proto\x12\x05proto\"\x1e\n\nGetRequest\x12\x10\n\x03key\x18\x01 \x01(\tR\x03key\"#\n\x0bGetResponse\x12\x14\n\x05value\x18\x01 \x01(\x0cR\x05value\"4\n\nPutRequest\x12\x10\n\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n\x05value\x18\x02 \x01(\x0cR\x05value\"\x07\n\x05\x45mpty2Z\n\x02KV\x12,\n\x03Get\x12\x11.proto.GetRequest\x1a\x12.proto.GetResponse\x12&\n\x03Put\x12\x11.proto.PutRequest\x1a\x0c.proto.EmptyB\tZ\x07./protob\x06proto3') - def beta_create_KV_stub(channel, host=None, metadata_transformer=None, pool=None, pool_size=None): - """The Beta API is deprecated for 0.15.0 and later. +_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) +_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'proto.kv_pb2', globals()) +if _descriptor._USE_C_DESCRIPTORS == False: - It is recommended to use the GA API (classes and functions in this - file not marked beta) for all further purposes. This function was - generated only to ease transition from grpcio<0.15.0 to grpcio>=0.15.0""" - request_serializers = { - ('proto.KV', 'Get'): GetRequest.SerializeToString, - ('proto.KV', 'Put'): PutRequest.SerializeToString, - } - response_deserializers = { - ('proto.KV', 'Get'): GetResponse.FromString, - ('proto.KV', 'Put'): Empty.FromString, - } - cardinalities = { - 'Get': cardinality.Cardinality.UNARY_UNARY, - 'Put': cardinality.Cardinality.UNARY_UNARY, - } - stub_options = beta_implementations.stub_options(host=host, metadata_transformer=metadata_transformer, request_serializers=request_serializers, response_deserializers=response_deserializers, thread_pool=pool, thread_pool_size=pool_size) - return beta_implementations.dynamic_stub(channel, 'proto.KV', cardinalities, options=stub_options) -except ImportError: - pass + DESCRIPTOR._options = None + DESCRIPTOR._serialized_options = b'Z\007./proto' + _GETREQUEST._serialized_start=25 + _GETREQUEST._serialized_end=55 + _GETRESPONSE._serialized_start=57 + _GETRESPONSE._serialized_end=92 + _PUTREQUEST._serialized_start=94 + _PUTREQUEST._serialized_end=146 + _EMPTY._serialized_start=148 + _EMPTY._serialized_end=155 + _KV._serialized_start=157 + _KV._serialized_end=247 # @@protoc_insertion_point(module_scope) diff --git a/examples/grpc/plugin-python/proto/kv_pb2_grpc.py b/examples/grpc/plugin-python/proto/kv_pb2_grpc.py index 5a8f1794..33bcd068 100644 --- a/examples/grpc/plugin-python/proto/kv_pb2_grpc.py +++ b/examples/grpc/plugin-python/proto/kv_pb2_grpc.py @@ -1,58 +1,99 @@ -# Copyright (c) HashiCorp, Inc. -# SPDX-License-Identifier: MPL-2.0 - # Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! +"""Client and server classes corresponding to protobuf-defined services.""" import grpc -import kv_pb2 as kv__pb2 +from proto import kv_pb2 as proto_dot_kv__pb2 class KVStub(object): + """Missing associated documentation comment in .proto file.""" - def __init__(self, channel): - """Constructor. + def __init__(self, channel): + """Constructor. - Args: - channel: A grpc.Channel. - """ - self.Get = channel.unary_unary( - '/proto.KV/Get', - request_serializer=kv__pb2.GetRequest.SerializeToString, - response_deserializer=kv__pb2.GetResponse.FromString, - ) - self.Put = channel.unary_unary( - '/proto.KV/Put', - request_serializer=kv__pb2.PutRequest.SerializeToString, - response_deserializer=kv__pb2.Empty.FromString, - ) + Args: + channel: A grpc.Channel. + """ + self.Get = channel.unary_unary( + '/proto.KV/Get', + request_serializer=proto_dot_kv__pb2.GetRequest.SerializeToString, + response_deserializer=proto_dot_kv__pb2.GetResponse.FromString, + ) + self.Put = channel.unary_unary( + '/proto.KV/Put', + request_serializer=proto_dot_kv__pb2.PutRequest.SerializeToString, + response_deserializer=proto_dot_kv__pb2.Empty.FromString, + ) class KVServicer(object): + """Missing associated documentation comment in .proto file.""" - def Get(self, request, context): - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') + def Get(self, request, context): + """Missing associated documentation comment in .proto file.""" + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') - def Put(self, request, context): - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') + def Put(self, request, context): + """Missing associated documentation comment in .proto file.""" + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') def add_KVServicer_to_server(servicer, server): - rpc_method_handlers = { - 'Get': grpc.unary_unary_rpc_method_handler( - servicer.Get, - request_deserializer=kv__pb2.GetRequest.FromString, - response_serializer=kv__pb2.GetResponse.SerializeToString, - ), - 'Put': grpc.unary_unary_rpc_method_handler( - servicer.Put, - request_deserializer=kv__pb2.PutRequest.FromString, - response_serializer=kv__pb2.Empty.SerializeToString, - ), - } - generic_handler = grpc.method_handlers_generic_handler( - 'proto.KV', rpc_method_handlers) - server.add_generic_rpc_handlers((generic_handler,)) + rpc_method_handlers = { + 'Get': grpc.unary_unary_rpc_method_handler( + servicer.Get, + request_deserializer=proto_dot_kv__pb2.GetRequest.FromString, + response_serializer=proto_dot_kv__pb2.GetResponse.SerializeToString, + ), + 'Put': grpc.unary_unary_rpc_method_handler( + servicer.Put, + request_deserializer=proto_dot_kv__pb2.PutRequest.FromString, + response_serializer=proto_dot_kv__pb2.Empty.SerializeToString, + ), + } + generic_handler = grpc.method_handlers_generic_handler( + 'proto.KV', rpc_method_handlers) + server.add_generic_rpc_handlers((generic_handler,)) + + + # This class is part of an EXPERIMENTAL API. +class KV(object): + """Missing associated documentation comment in .proto file.""" + + @staticmethod + def Get(request, + target, + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None): + return grpc.experimental.unary_unary(request, target, '/proto.KV/Get', + proto_dot_kv__pb2.GetRequest.SerializeToString, + proto_dot_kv__pb2.GetResponse.FromString, + options, channel_credentials, + insecure, call_credentials, compression, wait_for_ready, timeout, metadata) + + @staticmethod + def Put(request, + target, + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None): + return grpc.experimental.unary_unary(request, target, '/proto.KV/Put', + proto_dot_kv__pb2.PutRequest.SerializeToString, + proto_dot_kv__pb2.Empty.FromString, + options, channel_credentials, + insecure, call_credentials, compression, wait_for_ready, timeout, metadata) diff --git a/examples/grpc/proto/kv.pb.go b/examples/grpc/proto/kv.pb.go index 6e906405..1c805482 100644 --- a/examples/grpc/proto/kv.pb.go +++ b/examples/grpc/proto/kv.pb.go @@ -1,229 +1,339 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// source: kv.proto - -/* -Package proto is a generated protocol buffer package. +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 -It is generated from these files: - kv.proto +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.1 +// protoc (unknown) +// source: proto/kv.proto -It has these top-level messages: - GetRequest - GetResponse - PutRequest - Empty -*/ package proto -import proto1 "github.com/golang/protobuf/proto" -import fmt "fmt" -import math "math" - import ( - context "context" - grpc "google.golang.org/grpc" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" ) -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto1.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto1.ProtoPackageIsVersion2 // please upgrade the proto package +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) type GetRequest struct { - Key string `protobuf:"bytes,1,opt,name=key" json:"key,omitempty"` + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` +} + +func (x *GetRequest) Reset() { + *x = GetRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_proto_kv_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetRequest) ProtoMessage() {} + +func (x *GetRequest) ProtoReflect() protoreflect.Message { + mi := &file_proto_kv_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -func (m *GetRequest) Reset() { *m = GetRequest{} } -func (m *GetRequest) String() string { return proto1.CompactTextString(m) } -func (*GetRequest) ProtoMessage() {} -func (*GetRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } +// Deprecated: Use GetRequest.ProtoReflect.Descriptor instead. +func (*GetRequest) Descriptor() ([]byte, []int) { + return file_proto_kv_proto_rawDescGZIP(), []int{0} +} -func (m *GetRequest) GetKey() string { - if m != nil { - return m.Key +func (x *GetRequest) GetKey() string { + if x != nil { + return x.Key } return "" } type GetResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + Value []byte `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"` } -func (m *GetResponse) Reset() { *m = GetResponse{} } -func (m *GetResponse) String() string { return proto1.CompactTextString(m) } -func (*GetResponse) ProtoMessage() {} -func (*GetResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} } - -func (m *GetResponse) GetValue() []byte { - if m != nil { - return m.Value +func (x *GetResponse) Reset() { + *x = GetResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_proto_kv_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } - return nil } -type PutRequest struct { - Key string `protobuf:"bytes,1,opt,name=key" json:"key,omitempty"` - Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` +func (x *GetResponse) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *PutRequest) Reset() { *m = PutRequest{} } -func (m *PutRequest) String() string { return proto1.CompactTextString(m) } -func (*PutRequest) ProtoMessage() {} -func (*PutRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} } +func (*GetResponse) ProtoMessage() {} -func (m *PutRequest) GetKey() string { - if m != nil { - return m.Key +func (x *GetResponse) ProtoReflect() protoreflect.Message { + mi := &file_proto_kv_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms } - return "" + return mi.MessageOf(x) +} + +// Deprecated: Use GetResponse.ProtoReflect.Descriptor instead. +func (*GetResponse) Descriptor() ([]byte, []int) { + return file_proto_kv_proto_rawDescGZIP(), []int{1} } -func (m *PutRequest) GetValue() []byte { - if m != nil { - return m.Value +func (x *GetResponse) GetValue() []byte { + if x != nil { + return x.Value } return nil } -type Empty struct { +type PutRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` } -func (m *Empty) Reset() { *m = Empty{} } -func (m *Empty) String() string { return proto1.CompactTextString(m) } -func (*Empty) ProtoMessage() {} -func (*Empty) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} } +func (x *PutRequest) Reset() { + *x = PutRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_proto_kv_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} -func init() { - proto1.RegisterType((*GetRequest)(nil), "proto.GetRequest") - proto1.RegisterType((*GetResponse)(nil), "proto.GetResponse") - proto1.RegisterType((*PutRequest)(nil), "proto.PutRequest") - proto1.RegisterType((*Empty)(nil), "proto.Empty") +func (x *PutRequest) String() string { + return protoimpl.X.MessageStringOf(x) } -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn +func (*PutRequest) ProtoMessage() {} -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 +func (x *PutRequest) ProtoReflect() protoreflect.Message { + mi := &file_proto_kv_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} -// Client API for KV service +// Deprecated: Use PutRequest.ProtoReflect.Descriptor instead. +func (*PutRequest) Descriptor() ([]byte, []int) { + return file_proto_kv_proto_rawDescGZIP(), []int{2} +} -type KVClient interface { - Get(ctx context.Context, in *GetRequest, opts ...grpc.CallOption) (*GetResponse, error) - Put(ctx context.Context, in *PutRequest, opts ...grpc.CallOption) (*Empty, error) +func (x *PutRequest) GetKey() string { + if x != nil { + return x.Key + } + return "" } -type kVClient struct { - cc *grpc.ClientConn +func (x *PutRequest) GetValue() []byte { + if x != nil { + return x.Value + } + return nil } -func NewKVClient(cc *grpc.ClientConn) KVClient { - return &kVClient{cc} +type Empty struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields } -func (c *kVClient) Get(ctx context.Context, in *GetRequest, opts ...grpc.CallOption) (*GetResponse, error) { - out := new(GetResponse) - err := grpc.Invoke(ctx, "/proto.KV/Get", in, out, c.cc, opts...) - if err != nil { - return nil, err +func (x *Empty) Reset() { + *x = Empty{} + if protoimpl.UnsafeEnabled { + mi := &file_proto_kv_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } - return out, nil } -func (c *kVClient) Put(ctx context.Context, in *PutRequest, opts ...grpc.CallOption) (*Empty, error) { - out := new(Empty) - err := grpc.Invoke(ctx, "/proto.KV/Put", in, out, c.cc, opts...) - if err != nil { - return nil, err +func (x *Empty) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Empty) ProtoMessage() {} + +func (x *Empty) ProtoReflect() protoreflect.Message { + mi := &file_proto_kv_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms } - return out, nil + return mi.MessageOf(x) } -// Server API for KV service +// Deprecated: Use Empty.ProtoReflect.Descriptor instead. +func (*Empty) Descriptor() ([]byte, []int) { + return file_proto_kv_proto_rawDescGZIP(), []int{3} +} -type KVServer interface { - Get(context.Context, *GetRequest) (*GetResponse, error) - Put(context.Context, *PutRequest) (*Empty, error) +var File_proto_kv_proto protoreflect.FileDescriptor + +var file_proto_kv_proto_rawDesc = []byte{ + 0x0a, 0x0e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x6b, 0x76, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x12, 0x05, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x1e, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x22, 0x23, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x34, 0x0a, 0x0a, + 0x50, 0x75, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, + 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x76, 0x61, 0x6c, + 0x75, 0x65, 0x22, 0x07, 0x0a, 0x05, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x32, 0x5a, 0x0a, 0x02, 0x4b, + 0x56, 0x12, 0x2c, 0x0a, 0x03, 0x47, 0x65, 0x74, 0x12, 0x11, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x26, 0x0a, 0x03, 0x50, 0x75, 0x74, 0x12, 0x11, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, + 0x75, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0c, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x42, 0x09, 0x5a, 0x07, 0x2e, 0x2f, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } -func RegisterKVServer(s *grpc.Server, srv KVServer) { - s.RegisterService(&_KV_serviceDesc, srv) +var ( + file_proto_kv_proto_rawDescOnce sync.Once + file_proto_kv_proto_rawDescData = file_proto_kv_proto_rawDesc +) + +func file_proto_kv_proto_rawDescGZIP() []byte { + file_proto_kv_proto_rawDescOnce.Do(func() { + file_proto_kv_proto_rawDescData = protoimpl.X.CompressGZIP(file_proto_kv_proto_rawDescData) + }) + return file_proto_kv_proto_rawDescData } -func _KV_Get_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(GetRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(KVServer).Get(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/proto.KV/Get", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(KVServer).Get(ctx, req.(*GetRequest)) - } - return interceptor(ctx, in, info, handler) +var file_proto_kv_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_proto_kv_proto_goTypes = []interface{}{ + (*GetRequest)(nil), // 0: proto.GetRequest + (*GetResponse)(nil), // 1: proto.GetResponse + (*PutRequest)(nil), // 2: proto.PutRequest + (*Empty)(nil), // 3: proto.Empty +} +var file_proto_kv_proto_depIdxs = []int32{ + 0, // 0: proto.KV.Get:input_type -> proto.GetRequest + 2, // 1: proto.KV.Put:input_type -> proto.PutRequest + 1, // 2: proto.KV.Get:output_type -> proto.GetResponse + 3, // 3: proto.KV.Put:output_type -> proto.Empty + 2, // [2:4] is the sub-list for method output_type + 0, // [0:2] 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 _KV_Put_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(PutRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(KVServer).Put(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/proto.KV/Put", +func init() { file_proto_kv_proto_init() } +func file_proto_kv_proto_init() { + if File_proto_kv_proto != nil { + return } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(KVServer).Put(ctx, req.(*PutRequest)) + if !protoimpl.UnsafeEnabled { + file_proto_kv_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_proto_kv_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_proto_kv_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PutRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_proto_kv_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Empty); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } - return interceptor(ctx, in, info, handler) -} - -var _KV_serviceDesc = grpc.ServiceDesc{ - ServiceName: "proto.KV", - HandlerType: (*KVServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Get", - Handler: _KV_Get_Handler, - }, - { - MethodName: "Put", - Handler: _KV_Put_Handler, + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_proto_kv_proto_rawDesc, + NumEnums: 0, + NumMessages: 4, + NumExtensions: 0, + NumServices: 1, }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "kv.proto", -} - -func init() { proto1.RegisterFile("kv.proto", fileDescriptor0) } - -var fileDescriptor0 = []byte{ - // 162 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0xc8, 0x2e, 0xd3, 0x2b, - 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x05, 0x53, 0x4a, 0x72, 0x5c, 0x5c, 0xee, 0xa9, 0x25, 0x41, - 0xa9, 0x85, 0xa5, 0xa9, 0xc5, 0x25, 0x42, 0x02, 0x5c, 0xcc, 0xd9, 0xa9, 0x95, 0x12, 0x8c, 0x0a, - 0x8c, 0x1a, 0x9c, 0x41, 0x20, 0xa6, 0x92, 0x32, 0x17, 0x37, 0x58, 0xbe, 0xb8, 0x20, 0x3f, 0xaf, - 0x38, 0x55, 0x48, 0x84, 0x8b, 0xb5, 0x2c, 0x31, 0xa7, 0x34, 0x15, 0xac, 0x84, 0x27, 0x08, 0xc2, - 0x51, 0x32, 0xe1, 0xe2, 0x0a, 0x28, 0xc5, 0x6d, 0x08, 0x42, 0x17, 0x13, 0xb2, 0x2e, 0x76, 0x2e, - 0x56, 0xd7, 0xdc, 0x82, 0x92, 0x4a, 0xa3, 0x28, 0x2e, 0x26, 0xef, 0x30, 0x21, 0x1d, 0x2e, 0x66, - 0xf7, 0xd4, 0x12, 0x21, 0x41, 0x88, 0xfb, 0xf4, 0x10, 0xae, 0x92, 0x12, 0x42, 0x16, 0x82, 0x3a, - 0x44, 0x8d, 0x8b, 0x39, 0xa0, 0x14, 0xa1, 0x1a, 0x61, 0xbd, 0x14, 0x0f, 0x54, 0x08, 0x6c, 0x76, - 0x12, 0x1b, 0x98, 0x63, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0x06, 0x32, 0x05, 0x89, 0xf9, 0x00, - 0x00, 0x00, + GoTypes: file_proto_kv_proto_goTypes, + DependencyIndexes: file_proto_kv_proto_depIdxs, + MessageInfos: file_proto_kv_proto_msgTypes, + }.Build() + File_proto_kv_proto = out.File + file_proto_kv_proto_rawDesc = nil + file_proto_kv_proto_goTypes = nil + file_proto_kv_proto_depIdxs = nil } diff --git a/examples/grpc/proto/kv_grpc.pb.go b/examples/grpc/proto/kv_grpc.pb.go new file mode 100644 index 00000000..9acfb411 --- /dev/null +++ b/examples/grpc/proto/kv_grpc.pb.go @@ -0,0 +1,137 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. + +package proto + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +// KVClient is the client API for KV service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type KVClient interface { + Get(ctx context.Context, in *GetRequest, opts ...grpc.CallOption) (*GetResponse, error) + Put(ctx context.Context, in *PutRequest, opts ...grpc.CallOption) (*Empty, error) +} + +type kVClient struct { + cc grpc.ClientConnInterface +} + +func NewKVClient(cc grpc.ClientConnInterface) KVClient { + return &kVClient{cc} +} + +func (c *kVClient) Get(ctx context.Context, in *GetRequest, opts ...grpc.CallOption) (*GetResponse, error) { + out := new(GetResponse) + err := c.cc.Invoke(ctx, "/proto.KV/Get", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *kVClient) Put(ctx context.Context, in *PutRequest, opts ...grpc.CallOption) (*Empty, error) { + out := new(Empty) + err := c.cc.Invoke(ctx, "/proto.KV/Put", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// KVServer is the server API for KV service. +// All implementations must embed UnimplementedKVServer +// for forward compatibility +type KVServer interface { + Get(context.Context, *GetRequest) (*GetResponse, error) + Put(context.Context, *PutRequest) (*Empty, error) + mustEmbedUnimplementedKVServer() +} + +// UnimplementedKVServer must be embedded to have forward compatible implementations. +type UnimplementedKVServer struct { +} + +func (UnimplementedKVServer) Get(context.Context, *GetRequest) (*GetResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Get not implemented") +} +func (UnimplementedKVServer) Put(context.Context, *PutRequest) (*Empty, error) { + return nil, status.Errorf(codes.Unimplemented, "method Put not implemented") +} +func (UnimplementedKVServer) mustEmbedUnimplementedKVServer() {} + +// UnsafeKVServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to KVServer will +// result in compilation errors. +type UnsafeKVServer interface { + mustEmbedUnimplementedKVServer() +} + +func RegisterKVServer(s grpc.ServiceRegistrar, srv KVServer) { + s.RegisterService(&KV_ServiceDesc, srv) +} + +func _KV_Get_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(KVServer).Get(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/proto.KV/Get", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(KVServer).Get(ctx, req.(*GetRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _KV_Put_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(PutRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(KVServer).Put(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/proto.KV/Put", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(KVServer).Put(ctx, req.(*PutRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// KV_ServiceDesc is the grpc.ServiceDesc for KV service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var KV_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "proto.KV", + HandlerType: (*KVServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Get", + Handler: _KV_Get_Handler, + }, + { + MethodName: "Put", + Handler: _KV_Put_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "proto/kv.proto", +} diff --git a/internal/plugin/grpc_broker.pb.go b/internal/plugin/grpc_broker.pb.go index 303b63e4..54e8b3f0 100644 --- a/internal/plugin/grpc_broker.pb.go +++ b/internal/plugin/grpc_broker.pb.go @@ -1,203 +1,172 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + // Code generated by protoc-gen-go. DO NOT EDIT. -// source: grpc_broker.proto +// versions: +// protoc-gen-go v1.28.1 +// protoc (unknown) +// source: internal/plugin/grpc_broker.proto package plugin -import proto "github.com/golang/protobuf/proto" -import fmt "fmt" -import math "math" - import ( - context "context" - grpc "google.golang.org/grpc" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" ) -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) type ConnInfo struct { - ServiceId uint32 `protobuf:"varint,1,opt,name=service_id,json=serviceId,proto3" json:"service_id,omitempty"` - Network string `protobuf:"bytes,2,opt,name=network,proto3" json:"network,omitempty"` - Address string `protobuf:"bytes,3,opt,name=address,proto3" json:"address,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func (m *ConnInfo) Reset() { *m = ConnInfo{} } -func (m *ConnInfo) String() string { return proto.CompactTextString(m) } -func (*ConnInfo) ProtoMessage() {} -func (*ConnInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_grpc_broker_3322b07398605250, []int{0} + ServiceId uint32 `protobuf:"varint,1,opt,name=service_id,json=serviceId,proto3" json:"service_id,omitempty"` + Network string `protobuf:"bytes,2,opt,name=network,proto3" json:"network,omitempty"` + Address string `protobuf:"bytes,3,opt,name=address,proto3" json:"address,omitempty"` } -func (m *ConnInfo) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ConnInfo.Unmarshal(m, b) -} -func (m *ConnInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ConnInfo.Marshal(b, m, deterministic) -} -func (dst *ConnInfo) XXX_Merge(src proto.Message) { - xxx_messageInfo_ConnInfo.Merge(dst, src) -} -func (m *ConnInfo) XXX_Size() int { - return xxx_messageInfo_ConnInfo.Size(m) -} -func (m *ConnInfo) XXX_DiscardUnknown() { - xxx_messageInfo_ConnInfo.DiscardUnknown(m) -} - -var xxx_messageInfo_ConnInfo proto.InternalMessageInfo -func (m *ConnInfo) GetServiceId() uint32 { - if m != nil { - return m.ServiceId +func (x *ConnInfo) Reset() { + *x = ConnInfo{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_plugin_grpc_broker_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } - return 0 -} - -func (m *ConnInfo) GetNetwork() string { - if m != nil { - return m.Network - } - return "" -} - -func (m *ConnInfo) GetAddress() string { - if m != nil { - return m.Address - } - return "" -} - -func init() { - proto.RegisterType((*ConnInfo)(nil), "plugin.ConnInfo") } -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 - -// GRPCBrokerClient is the client API for GRPCBroker service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type GRPCBrokerClient interface { - StartStream(ctx context.Context, opts ...grpc.CallOption) (GRPCBroker_StartStreamClient, error) -} - -type gRPCBrokerClient struct { - cc *grpc.ClientConn +func (x *ConnInfo) String() string { + return protoimpl.X.MessageStringOf(x) } -func NewGRPCBrokerClient(cc *grpc.ClientConn) GRPCBrokerClient { - return &gRPCBrokerClient{cc} -} +func (*ConnInfo) ProtoMessage() {} -func (c *gRPCBrokerClient) StartStream(ctx context.Context, opts ...grpc.CallOption) (GRPCBroker_StartStreamClient, error) { - stream, err := c.cc.NewStream(ctx, &_GRPCBroker_serviceDesc.Streams[0], "/plugin.GRPCBroker/StartStream", opts...) - if err != nil { - return nil, err +func (x *ConnInfo) ProtoReflect() protoreflect.Message { + mi := &file_internal_plugin_grpc_broker_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms } - x := &gRPCBrokerStartStreamClient{stream} - return x, nil -} - -type GRPCBroker_StartStreamClient interface { - Send(*ConnInfo) error - Recv() (*ConnInfo, error) - grpc.ClientStream -} - -type gRPCBrokerStartStreamClient struct { - grpc.ClientStream + return mi.MessageOf(x) } -func (x *gRPCBrokerStartStreamClient) Send(m *ConnInfo) error { - return x.ClientStream.SendMsg(m) +// Deprecated: Use ConnInfo.ProtoReflect.Descriptor instead. +func (*ConnInfo) Descriptor() ([]byte, []int) { + return file_internal_plugin_grpc_broker_proto_rawDescGZIP(), []int{0} } -func (x *gRPCBrokerStartStreamClient) Recv() (*ConnInfo, error) { - m := new(ConnInfo) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err +func (x *ConnInfo) GetServiceId() uint32 { + if x != nil { + return x.ServiceId } - return m, nil + return 0 } -// GRPCBrokerServer is the server API for GRPCBroker service. -type GRPCBrokerServer interface { - StartStream(GRPCBroker_StartStreamServer) error +func (x *ConnInfo) GetNetwork() string { + if x != nil { + return x.Network + } + return "" } -func RegisterGRPCBrokerServer(s *grpc.Server, srv GRPCBrokerServer) { - s.RegisterService(&_GRPCBroker_serviceDesc, srv) +func (x *ConnInfo) GetAddress() string { + if x != nil { + return x.Address + } + return "" } -func _GRPCBroker_StartStream_Handler(srv interface{}, stream grpc.ServerStream) error { - return srv.(GRPCBrokerServer).StartStream(&gRPCBrokerStartStreamServer{stream}) -} +var File_internal_plugin_grpc_broker_proto protoreflect.FileDescriptor + +var file_internal_plugin_grpc_broker_proto_rawDesc = []byte{ + 0x0a, 0x21, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x6c, 0x75, 0x67, 0x69, + 0x6e, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x5f, 0x62, 0x72, 0x6f, 0x6b, 0x65, 0x72, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x12, 0x06, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x22, 0x5d, 0x0a, 0x08, 0x43, + 0x6f, 0x6e, 0x6e, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, 0x73, 0x65, 0x72, + 0x76, 0x69, 0x63, 0x65, 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, + 0x6b, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, + 0x12, 0x18, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x32, 0x43, 0x0a, 0x0a, 0x47, 0x52, + 0x50, 0x43, 0x42, 0x72, 0x6f, 0x6b, 0x65, 0x72, 0x12, 0x35, 0x0a, 0x0b, 0x53, 0x74, 0x61, 0x72, + 0x74, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x10, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, + 0x2e, 0x43, 0x6f, 0x6e, 0x6e, 0x49, 0x6e, 0x66, 0x6f, 0x1a, 0x10, 0x2e, 0x70, 0x6c, 0x75, 0x67, + 0x69, 0x6e, 0x2e, 0x43, 0x6f, 0x6e, 0x6e, 0x49, 0x6e, 0x66, 0x6f, 0x28, 0x01, 0x30, 0x01, 0x42, + 0x0a, 0x5a, 0x08, 0x2e, 0x2f, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, +} + +var ( + file_internal_plugin_grpc_broker_proto_rawDescOnce sync.Once + file_internal_plugin_grpc_broker_proto_rawDescData = file_internal_plugin_grpc_broker_proto_rawDesc +) -type GRPCBroker_StartStreamServer interface { - Send(*ConnInfo) error - Recv() (*ConnInfo, error) - grpc.ServerStream +func file_internal_plugin_grpc_broker_proto_rawDescGZIP() []byte { + file_internal_plugin_grpc_broker_proto_rawDescOnce.Do(func() { + file_internal_plugin_grpc_broker_proto_rawDescData = protoimpl.X.CompressGZIP(file_internal_plugin_grpc_broker_proto_rawDescData) + }) + return file_internal_plugin_grpc_broker_proto_rawDescData } -type gRPCBrokerStartStreamServer struct { - grpc.ServerStream +var file_internal_plugin_grpc_broker_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_internal_plugin_grpc_broker_proto_goTypes = []interface{}{ + (*ConnInfo)(nil), // 0: plugin.ConnInfo } - -func (x *gRPCBrokerStartStreamServer) Send(m *ConnInfo) error { - return x.ServerStream.SendMsg(m) +var file_internal_plugin_grpc_broker_proto_depIdxs = []int32{ + 0, // 0: plugin.GRPCBroker.StartStream:input_type -> plugin.ConnInfo + 0, // 1: plugin.GRPCBroker.StartStream:output_type -> plugin.ConnInfo + 1, // [1:2] is the sub-list for method output_type + 0, // [0:1] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name } -func (x *gRPCBrokerStartStreamServer) Recv() (*ConnInfo, error) { - m := new(ConnInfo) - if err := x.ServerStream.RecvMsg(m); err != nil { - return nil, err +func init() { file_internal_plugin_grpc_broker_proto_init() } +func file_internal_plugin_grpc_broker_proto_init() { + if File_internal_plugin_grpc_broker_proto != nil { + return } - return m, nil -} - -var _GRPCBroker_serviceDesc = grpc.ServiceDesc{ - ServiceName: "plugin.GRPCBroker", - HandlerType: (*GRPCBrokerServer)(nil), - Methods: []grpc.MethodDesc{}, - Streams: []grpc.StreamDesc{ - { - StreamName: "StartStream", - Handler: _GRPCBroker_StartStream_Handler, - ServerStreams: true, - ClientStreams: true, + if !protoimpl.UnsafeEnabled { + file_internal_plugin_grpc_broker_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ConnInfo); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_internal_plugin_grpc_broker_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 1, }, - }, - Metadata: "grpc_broker.proto", -} - -func init() { proto.RegisterFile("grpc_broker.proto", fileDescriptor_grpc_broker_3322b07398605250) } - -var fileDescriptor_grpc_broker_3322b07398605250 = []byte{ - // 175 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x4c, 0x2f, 0x2a, 0x48, - 0x8e, 0x4f, 0x2a, 0xca, 0xcf, 0x4e, 0x2d, 0xd2, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x2b, - 0xc8, 0x29, 0x4d, 0xcf, 0xcc, 0x53, 0x8a, 0xe5, 0xe2, 0x70, 0xce, 0xcf, 0xcb, 0xf3, 0xcc, 0x4b, - 0xcb, 0x17, 0x92, 0xe5, 0xe2, 0x2a, 0x4e, 0x2d, 0x2a, 0xcb, 0x4c, 0x4e, 0x8d, 0xcf, 0x4c, 0x91, - 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x0d, 0xe2, 0x84, 0x8a, 0x78, 0xa6, 0x08, 0x49, 0x70, 0xb1, 0xe7, - 0xa5, 0x96, 0x94, 0xe7, 0x17, 0x65, 0x4b, 0x30, 0x29, 0x30, 0x6a, 0x70, 0x06, 0xc1, 0xb8, 0x20, - 0x99, 0xc4, 0x94, 0x94, 0xa2, 0xd4, 0xe2, 0x62, 0x09, 0x66, 0x88, 0x0c, 0x94, 0x6b, 0xe4, 0xcc, - 0xc5, 0xe5, 0x1e, 0x14, 0xe0, 0xec, 0x04, 0xb6, 0x5a, 0xc8, 0x94, 0x8b, 0x3b, 0xb8, 0x24, 0xb1, - 0xa8, 0x24, 0xb8, 0xa4, 0x28, 0x35, 0x31, 0x57, 0x48, 0x40, 0x0f, 0xe2, 0x08, 0x3d, 0x98, 0x0b, - 0xa4, 0x30, 0x44, 0x34, 0x18, 0x0d, 0x18, 0x9d, 0x38, 0xa2, 0xa0, 0xae, 0x4d, 0x62, 0x03, 0x3b, - 0xde, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0x10, 0x15, 0x39, 0x47, 0xd1, 0x00, 0x00, 0x00, + GoTypes: file_internal_plugin_grpc_broker_proto_goTypes, + DependencyIndexes: file_internal_plugin_grpc_broker_proto_depIdxs, + MessageInfos: file_internal_plugin_grpc_broker_proto_msgTypes, + }.Build() + File_internal_plugin_grpc_broker_proto = out.File + file_internal_plugin_grpc_broker_proto_rawDesc = nil + file_internal_plugin_grpc_broker_proto_goTypes = nil + file_internal_plugin_grpc_broker_proto_depIdxs = nil } diff --git a/internal/plugin/grpc_broker_grpc.pb.go b/internal/plugin/grpc_broker_grpc.pb.go new file mode 100644 index 00000000..b31216cf --- /dev/null +++ b/internal/plugin/grpc_broker_grpc.pb.go @@ -0,0 +1,133 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. + +package plugin + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +// GRPCBrokerClient is the client API for GRPCBroker service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type GRPCBrokerClient interface { + StartStream(ctx context.Context, opts ...grpc.CallOption) (GRPCBroker_StartStreamClient, error) +} + +type gRPCBrokerClient struct { + cc grpc.ClientConnInterface +} + +func NewGRPCBrokerClient(cc grpc.ClientConnInterface) GRPCBrokerClient { + return &gRPCBrokerClient{cc} +} + +func (c *gRPCBrokerClient) StartStream(ctx context.Context, opts ...grpc.CallOption) (GRPCBroker_StartStreamClient, error) { + stream, err := c.cc.NewStream(ctx, &GRPCBroker_ServiceDesc.Streams[0], "/plugin.GRPCBroker/StartStream", opts...) + if err != nil { + return nil, err + } + x := &gRPCBrokerStartStreamClient{stream} + return x, nil +} + +type GRPCBroker_StartStreamClient interface { + Send(*ConnInfo) error + Recv() (*ConnInfo, error) + grpc.ClientStream +} + +type gRPCBrokerStartStreamClient struct { + grpc.ClientStream +} + +func (x *gRPCBrokerStartStreamClient) Send(m *ConnInfo) error { + return x.ClientStream.SendMsg(m) +} + +func (x *gRPCBrokerStartStreamClient) Recv() (*ConnInfo, error) { + m := new(ConnInfo) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +// GRPCBrokerServer is the server API for GRPCBroker service. +// All implementations must embed UnimplementedGRPCBrokerServer +// for forward compatibility +type GRPCBrokerServer interface { + StartStream(GRPCBroker_StartStreamServer) error + mustEmbedUnimplementedGRPCBrokerServer() +} + +// UnimplementedGRPCBrokerServer must be embedded to have forward compatible implementations. +type UnimplementedGRPCBrokerServer struct { +} + +func (UnimplementedGRPCBrokerServer) StartStream(GRPCBroker_StartStreamServer) error { + return status.Errorf(codes.Unimplemented, "method StartStream not implemented") +} +func (UnimplementedGRPCBrokerServer) mustEmbedUnimplementedGRPCBrokerServer() {} + +// UnsafeGRPCBrokerServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to GRPCBrokerServer will +// result in compilation errors. +type UnsafeGRPCBrokerServer interface { + mustEmbedUnimplementedGRPCBrokerServer() +} + +func RegisterGRPCBrokerServer(s grpc.ServiceRegistrar, srv GRPCBrokerServer) { + s.RegisterService(&GRPCBroker_ServiceDesc, srv) +} + +func _GRPCBroker_StartStream_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(GRPCBrokerServer).StartStream(&gRPCBrokerStartStreamServer{stream}) +} + +type GRPCBroker_StartStreamServer interface { + Send(*ConnInfo) error + Recv() (*ConnInfo, error) + grpc.ServerStream +} + +type gRPCBrokerStartStreamServer struct { + grpc.ServerStream +} + +func (x *gRPCBrokerStartStreamServer) Send(m *ConnInfo) error { + return x.ServerStream.SendMsg(m) +} + +func (x *gRPCBrokerStartStreamServer) Recv() (*ConnInfo, error) { + m := new(ConnInfo) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +// GRPCBroker_ServiceDesc is the grpc.ServiceDesc for GRPCBroker service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var GRPCBroker_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "plugin.GRPCBroker", + HandlerType: (*GRPCBrokerServer)(nil), + Methods: []grpc.MethodDesc{}, + Streams: []grpc.StreamDesc{ + { + StreamName: "StartStream", + Handler: _GRPCBroker_StartStream_Handler, + ServerStreams: true, + ClientStreams: true, + }, + }, + Metadata: "internal/plugin/grpc_broker.proto", +} diff --git a/internal/plugin/grpc_controller.pb.go b/internal/plugin/grpc_controller.pb.go index 982fca0a..2530a32e 100644 --- a/internal/plugin/grpc_controller.pb.go +++ b/internal/plugin/grpc_controller.pb.go @@ -1,145 +1,141 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + // Code generated by protoc-gen-go. DO NOT EDIT. -// source: grpc_controller.proto +// versions: +// protoc-gen-go v1.28.1 +// protoc (unknown) +// source: internal/plugin/grpc_controller.proto package plugin -import proto "github.com/golang/protobuf/proto" -import fmt "fmt" -import math "math" - import ( - context "context" - grpc "google.golang.org/grpc" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" ) -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) type Empty struct { - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields } -func (m *Empty) Reset() { *m = Empty{} } -func (m *Empty) String() string { return proto.CompactTextString(m) } -func (*Empty) ProtoMessage() {} -func (*Empty) Descriptor() ([]byte, []int) { - return fileDescriptor_grpc_controller_08f8296ef6d80436, []int{0} -} -func (m *Empty) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Empty.Unmarshal(m, b) -} -func (m *Empty) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Empty.Marshal(b, m, deterministic) -} -func (dst *Empty) XXX_Merge(src proto.Message) { - xxx_messageInfo_Empty.Merge(dst, src) -} -func (m *Empty) XXX_Size() int { - return xxx_messageInfo_Empty.Size(m) -} -func (m *Empty) XXX_DiscardUnknown() { - xxx_messageInfo_Empty.DiscardUnknown(m) +func (x *Empty) Reset() { + *x = Empty{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_plugin_grpc_controller_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -var xxx_messageInfo_Empty proto.InternalMessageInfo - -func init() { - proto.RegisterType((*Empty)(nil), "plugin.Empty") +func (x *Empty) String() string { + return protoimpl.X.MessageStringOf(x) } -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 +func (*Empty) ProtoMessage() {} -// GRPCControllerClient is the client API for GRPCController service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type GRPCControllerClient interface { - Shutdown(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*Empty, error) +func (x *Empty) ProtoReflect() protoreflect.Message { + mi := &file_internal_plugin_grpc_controller_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -type gRPCControllerClient struct { - cc *grpc.ClientConn +// Deprecated: Use Empty.ProtoReflect.Descriptor instead. +func (*Empty) Descriptor() ([]byte, []int) { + return file_internal_plugin_grpc_controller_proto_rawDescGZIP(), []int{0} } -func NewGRPCControllerClient(cc *grpc.ClientConn) GRPCControllerClient { - return &gRPCControllerClient{cc} -} +var File_internal_plugin_grpc_controller_proto protoreflect.FileDescriptor -func (c *gRPCControllerClient) Shutdown(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*Empty, error) { - out := new(Empty) - err := c.cc.Invoke(ctx, "/plugin.GRPCController/Shutdown", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil +var file_internal_plugin_grpc_controller_proto_rawDesc = []byte{ + 0x0a, 0x25, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x6c, 0x75, 0x67, 0x69, + 0x6e, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, + 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x06, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x22, + 0x07, 0x0a, 0x05, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x32, 0x3a, 0x0a, 0x0e, 0x47, 0x52, 0x50, 0x43, + 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x12, 0x28, 0x0a, 0x08, 0x53, 0x68, + 0x75, 0x74, 0x64, 0x6f, 0x77, 0x6e, 0x12, 0x0d, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, + 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x0d, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x45, + 0x6d, 0x70, 0x74, 0x79, 0x42, 0x0a, 0x5a, 0x08, 0x2e, 0x2f, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } -// GRPCControllerServer is the server API for GRPCController service. -type GRPCControllerServer interface { - Shutdown(context.Context, *Empty) (*Empty, error) +var ( + file_internal_plugin_grpc_controller_proto_rawDescOnce sync.Once + file_internal_plugin_grpc_controller_proto_rawDescData = file_internal_plugin_grpc_controller_proto_rawDesc +) + +func file_internal_plugin_grpc_controller_proto_rawDescGZIP() []byte { + file_internal_plugin_grpc_controller_proto_rawDescOnce.Do(func() { + file_internal_plugin_grpc_controller_proto_rawDescData = protoimpl.X.CompressGZIP(file_internal_plugin_grpc_controller_proto_rawDescData) + }) + return file_internal_plugin_grpc_controller_proto_rawDescData } -func RegisterGRPCControllerServer(s *grpc.Server, srv GRPCControllerServer) { - s.RegisterService(&_GRPCController_serviceDesc, srv) +var file_internal_plugin_grpc_controller_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_internal_plugin_grpc_controller_proto_goTypes = []interface{}{ + (*Empty)(nil), // 0: plugin.Empty +} +var file_internal_plugin_grpc_controller_proto_depIdxs = []int32{ + 0, // 0: plugin.GRPCController.Shutdown:input_type -> plugin.Empty + 0, // 1: plugin.GRPCController.Shutdown:output_type -> plugin.Empty + 1, // [1:2] is the sub-list for method output_type + 0, // [0:1] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name } -func _GRPCController_Shutdown_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(Empty) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(GRPCControllerServer).Shutdown(ctx, in) +func init() { file_internal_plugin_grpc_controller_proto_init() } +func file_internal_plugin_grpc_controller_proto_init() { + if File_internal_plugin_grpc_controller_proto != nil { + return } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/plugin.GRPCController/Shutdown", + if !protoimpl.UnsafeEnabled { + file_internal_plugin_grpc_controller_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Empty); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(GRPCControllerServer).Shutdown(ctx, req.(*Empty)) - } - return interceptor(ctx, in, info, handler) -} - -var _GRPCController_serviceDesc = grpc.ServiceDesc{ - ServiceName: "plugin.GRPCController", - HandlerType: (*GRPCControllerServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Shutdown", - Handler: _GRPCController_Shutdown_Handler, + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_internal_plugin_grpc_controller_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 1, }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "grpc_controller.proto", -} - -func init() { - proto.RegisterFile("grpc_controller.proto", fileDescriptor_grpc_controller_08f8296ef6d80436) -} - -var fileDescriptor_grpc_controller_08f8296ef6d80436 = []byte{ - // 108 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x4d, 0x2f, 0x2a, 0x48, - 0x8e, 0x4f, 0xce, 0xcf, 0x2b, 0x29, 0xca, 0xcf, 0xc9, 0x49, 0x2d, 0xd2, 0x2b, 0x28, 0xca, 0x2f, - 0xc9, 0x17, 0x62, 0x2b, 0xc8, 0x29, 0x4d, 0xcf, 0xcc, 0x53, 0x62, 0xe7, 0x62, 0x75, 0xcd, 0x2d, - 0x28, 0xa9, 0x34, 0xb2, 0xe2, 0xe2, 0x73, 0x0f, 0x0a, 0x70, 0x76, 0x86, 0x2b, 0x14, 0xd2, 0xe0, - 0xe2, 0x08, 0xce, 0x28, 0x2d, 0x49, 0xc9, 0x2f, 0xcf, 0x13, 0xe2, 0xd5, 0x83, 0xa8, 0xd7, 0x03, - 0x2b, 0x96, 0x42, 0xe5, 0x3a, 0x71, 0x44, 0x41, 0x8d, 0x4b, 0x62, 0x03, 0x9b, 0x6e, 0x0c, 0x08, - 0x00, 0x00, 0xff, 0xff, 0xab, 0x7c, 0x27, 0xe5, 0x76, 0x00, 0x00, 0x00, + GoTypes: file_internal_plugin_grpc_controller_proto_goTypes, + DependencyIndexes: file_internal_plugin_grpc_controller_proto_depIdxs, + MessageInfos: file_internal_plugin_grpc_controller_proto_msgTypes, + }.Build() + File_internal_plugin_grpc_controller_proto = out.File + file_internal_plugin_grpc_controller_proto_rawDesc = nil + file_internal_plugin_grpc_controller_proto_goTypes = nil + file_internal_plugin_grpc_controller_proto_depIdxs = nil } diff --git a/internal/plugin/grpc_controller_grpc.pb.go b/internal/plugin/grpc_controller_grpc.pb.go new file mode 100644 index 00000000..510acb49 --- /dev/null +++ b/internal/plugin/grpc_controller_grpc.pb.go @@ -0,0 +1,101 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. + +package plugin + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +// GRPCControllerClient is the client API for GRPCController service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type GRPCControllerClient interface { + Shutdown(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*Empty, error) +} + +type gRPCControllerClient struct { + cc grpc.ClientConnInterface +} + +func NewGRPCControllerClient(cc grpc.ClientConnInterface) GRPCControllerClient { + return &gRPCControllerClient{cc} +} + +func (c *gRPCControllerClient) Shutdown(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*Empty, error) { + out := new(Empty) + err := c.cc.Invoke(ctx, "/plugin.GRPCController/Shutdown", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// GRPCControllerServer is the server API for GRPCController service. +// All implementations must embed UnimplementedGRPCControllerServer +// for forward compatibility +type GRPCControllerServer interface { + Shutdown(context.Context, *Empty) (*Empty, error) + mustEmbedUnimplementedGRPCControllerServer() +} + +// UnimplementedGRPCControllerServer must be embedded to have forward compatible implementations. +type UnimplementedGRPCControllerServer struct { +} + +func (UnimplementedGRPCControllerServer) Shutdown(context.Context, *Empty) (*Empty, error) { + return nil, status.Errorf(codes.Unimplemented, "method Shutdown not implemented") +} +func (UnimplementedGRPCControllerServer) mustEmbedUnimplementedGRPCControllerServer() {} + +// UnsafeGRPCControllerServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to GRPCControllerServer will +// result in compilation errors. +type UnsafeGRPCControllerServer interface { + mustEmbedUnimplementedGRPCControllerServer() +} + +func RegisterGRPCControllerServer(s grpc.ServiceRegistrar, srv GRPCControllerServer) { + s.RegisterService(&GRPCController_ServiceDesc, srv) +} + +func _GRPCController_Shutdown_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(Empty) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(GRPCControllerServer).Shutdown(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/plugin.GRPCController/Shutdown", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(GRPCControllerServer).Shutdown(ctx, req.(*Empty)) + } + return interceptor(ctx, in, info, handler) +} + +// GRPCController_ServiceDesc is the grpc.ServiceDesc for GRPCController service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var GRPCController_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "plugin.GRPCController", + HandlerType: (*GRPCControllerServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Shutdown", + Handler: _GRPCController_Shutdown_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "internal/plugin/grpc_controller.proto", +} diff --git a/internal/plugin/grpc_stdio.pb.go b/internal/plugin/grpc_stdio.pb.go index bdef71b8..a4ed0525 100644 --- a/internal/plugin/grpc_stdio.pb.go +++ b/internal/plugin/grpc_stdio.pb.go @@ -1,28 +1,28 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + // Code generated by protoc-gen-go. DO NOT EDIT. -// source: grpc_stdio.proto +// versions: +// protoc-gen-go v1.28.1 +// protoc (unknown) +// source: internal/plugin/grpc_stdio.proto package plugin -import proto "github.com/golang/protobuf/proto" -import fmt "fmt" -import math "math" -import empty "github.com/golang/protobuf/ptypes/empty" - import ( - context "context" - grpc "google.golang.org/grpc" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + emptypb "google.golang.org/protobuf/types/known/emptypb" + reflect "reflect" + sync "sync" ) -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) type StdioData_Channel int32 @@ -32,202 +32,194 @@ const ( StdioData_STDERR StdioData_Channel = 2 ) -var StdioData_Channel_name = map[int32]string{ - 0: "INVALID", - 1: "STDOUT", - 2: "STDERR", -} -var StdioData_Channel_value = map[string]int32{ - "INVALID": 0, - "STDOUT": 1, - "STDERR": 2, -} - -func (x StdioData_Channel) String() string { - return proto.EnumName(StdioData_Channel_name, int32(x)) -} -func (StdioData_Channel) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_grpc_stdio_db2934322ca63bd5, []int{0, 0} -} +// Enum value maps for StdioData_Channel. +var ( + StdioData_Channel_name = map[int32]string{ + 0: "INVALID", + 1: "STDOUT", + 2: "STDERR", + } + StdioData_Channel_value = map[string]int32{ + "INVALID": 0, + "STDOUT": 1, + "STDERR": 2, + } +) -// StdioData is a single chunk of stdout or stderr data that is streamed -// from GRPCStdio. -type StdioData struct { - Channel StdioData_Channel `protobuf:"varint,1,opt,name=channel,proto3,enum=plugin.StdioData_Channel" json:"channel,omitempty"` - Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` +func (x StdioData_Channel) Enum() *StdioData_Channel { + p := new(StdioData_Channel) + *p = x + return p } -func (m *StdioData) Reset() { *m = StdioData{} } -func (m *StdioData) String() string { return proto.CompactTextString(m) } -func (*StdioData) ProtoMessage() {} -func (*StdioData) Descriptor() ([]byte, []int) { - return fileDescriptor_grpc_stdio_db2934322ca63bd5, []int{0} -} -func (m *StdioData) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_StdioData.Unmarshal(m, b) -} -func (m *StdioData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_StdioData.Marshal(b, m, deterministic) -} -func (dst *StdioData) XXX_Merge(src proto.Message) { - xxx_messageInfo_StdioData.Merge(dst, src) -} -func (m *StdioData) XXX_Size() int { - return xxx_messageInfo_StdioData.Size(m) -} -func (m *StdioData) XXX_DiscardUnknown() { - xxx_messageInfo_StdioData.DiscardUnknown(m) +func (x StdioData_Channel) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } -var xxx_messageInfo_StdioData proto.InternalMessageInfo - -func (m *StdioData) GetChannel() StdioData_Channel { - if m != nil { - return m.Channel - } - return StdioData_INVALID +func (StdioData_Channel) Descriptor() protoreflect.EnumDescriptor { + return file_internal_plugin_grpc_stdio_proto_enumTypes[0].Descriptor() } -func (m *StdioData) GetData() []byte { - if m != nil { - return m.Data - } - return nil +func (StdioData_Channel) Type() protoreflect.EnumType { + return &file_internal_plugin_grpc_stdio_proto_enumTypes[0] } -func init() { - proto.RegisterType((*StdioData)(nil), "plugin.StdioData") - proto.RegisterEnum("plugin.StdioData_Channel", StdioData_Channel_name, StdioData_Channel_value) +func (x StdioData_Channel) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) } -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 - -// GRPCStdioClient is the client API for GRPCStdio service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type GRPCStdioClient interface { - // StreamStdio returns a stream that contains all the stdout/stderr. - // This RPC endpoint must only be called ONCE. Once stdio data is consumed - // it is not sent again. - // - // Callers should connect early to prevent blocking on the plugin process. - StreamStdio(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (GRPCStdio_StreamStdioClient, error) +// Deprecated: Use StdioData_Channel.Descriptor instead. +func (StdioData_Channel) EnumDescriptor() ([]byte, []int) { + return file_internal_plugin_grpc_stdio_proto_rawDescGZIP(), []int{0, 0} } -type gRPCStdioClient struct { - cc *grpc.ClientConn -} +// StdioData is a single chunk of stdout or stderr data that is streamed +// from GRPCStdio. +type StdioData struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func NewGRPCStdioClient(cc *grpc.ClientConn) GRPCStdioClient { - return &gRPCStdioClient{cc} + Channel StdioData_Channel `protobuf:"varint,1,opt,name=channel,proto3,enum=plugin.StdioData_Channel" json:"channel,omitempty"` + Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` } -func (c *gRPCStdioClient) StreamStdio(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (GRPCStdio_StreamStdioClient, error) { - stream, err := c.cc.NewStream(ctx, &_GRPCStdio_serviceDesc.Streams[0], "/plugin.GRPCStdio/StreamStdio", opts...) - if err != nil { - return nil, err - } - x := &gRPCStdioStreamStdioClient{stream} - if err := x.ClientStream.SendMsg(in); err != nil { - return nil, err - } - if err := x.ClientStream.CloseSend(); err != nil { - return nil, err +func (x *StdioData) Reset() { + *x = StdioData{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_plugin_grpc_stdio_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } - return x, nil } -type GRPCStdio_StreamStdioClient interface { - Recv() (*StdioData, error) - grpc.ClientStream +func (x *StdioData) String() string { + return protoimpl.X.MessageStringOf(x) } -type gRPCStdioStreamStdioClient struct { - grpc.ClientStream -} +func (*StdioData) ProtoMessage() {} -func (x *gRPCStdioStreamStdioClient) Recv() (*StdioData, error) { - m := new(StdioData) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err +func (x *StdioData) ProtoReflect() protoreflect.Message { + mi := &file_internal_plugin_grpc_stdio_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms } - return m, nil -} - -// GRPCStdioServer is the server API for GRPCStdio service. -type GRPCStdioServer interface { - // StreamStdio returns a stream that contains all the stdout/stderr. - // This RPC endpoint must only be called ONCE. Once stdio data is consumed - // it is not sent again. - // - // Callers should connect early to prevent blocking on the plugin process. - StreamStdio(*empty.Empty, GRPCStdio_StreamStdioServer) error + return mi.MessageOf(x) } -func RegisterGRPCStdioServer(s *grpc.Server, srv GRPCStdioServer) { - s.RegisterService(&_GRPCStdio_serviceDesc, srv) +// Deprecated: Use StdioData.ProtoReflect.Descriptor instead. +func (*StdioData) Descriptor() ([]byte, []int) { + return file_internal_plugin_grpc_stdio_proto_rawDescGZIP(), []int{0} } -func _GRPCStdio_StreamStdio_Handler(srv interface{}, stream grpc.ServerStream) error { - m := new(empty.Empty) - if err := stream.RecvMsg(m); err != nil { - return err +func (x *StdioData) GetChannel() StdioData_Channel { + if x != nil { + return x.Channel } - return srv.(GRPCStdioServer).StreamStdio(m, &gRPCStdioStreamStdioServer{stream}) -} - -type GRPCStdio_StreamStdioServer interface { - Send(*StdioData) error - grpc.ServerStream + return StdioData_INVALID } -type gRPCStdioStreamStdioServer struct { - grpc.ServerStream +func (x *StdioData) GetData() []byte { + if x != nil { + return x.Data + } + return nil } -func (x *gRPCStdioStreamStdioServer) Send(m *StdioData) error { - return x.ServerStream.SendMsg(m) -} +var File_internal_plugin_grpc_stdio_proto protoreflect.FileDescriptor + +var file_internal_plugin_grpc_stdio_proto_rawDesc = []byte{ + 0x0a, 0x20, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x70, 0x6c, 0x75, 0x67, 0x69, + 0x6e, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x5f, 0x73, 0x74, 0x64, 0x69, 0x6f, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x12, 0x06, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 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, 0x84, 0x01, 0x0a, 0x09, 0x53, 0x74, 0x64, 0x69, + 0x6f, 0x44, 0x61, 0x74, 0x61, 0x12, 0x33, 0x0a, 0x07, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x19, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, + 0x53, 0x74, 0x64, 0x69, 0x6f, 0x44, 0x61, 0x74, 0x61, 0x2e, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, + 0x6c, 0x52, 0x07, 0x63, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, + 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x2e, + 0x0a, 0x07, 0x43, 0x68, 0x61, 0x6e, 0x6e, 0x65, 0x6c, 0x12, 0x0b, 0x0a, 0x07, 0x49, 0x4e, 0x56, + 0x41, 0x4c, 0x49, 0x44, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x53, 0x54, 0x44, 0x4f, 0x55, 0x54, + 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x53, 0x54, 0x44, 0x45, 0x52, 0x52, 0x10, 0x02, 0x32, 0x47, + 0x0a, 0x09, 0x47, 0x52, 0x50, 0x43, 0x53, 0x74, 0x64, 0x69, 0x6f, 0x12, 0x3a, 0x0a, 0x0b, 0x53, + 0x74, 0x72, 0x65, 0x61, 0x6d, 0x53, 0x74, 0x64, 0x69, 0x6f, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, + 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, + 0x74, 0x79, 0x1a, 0x11, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x53, 0x74, 0x64, 0x69, + 0x6f, 0x44, 0x61, 0x74, 0x61, 0x30, 0x01, 0x42, 0x0a, 0x5a, 0x08, 0x2e, 0x2f, 0x70, 0x6c, 0x75, + 0x67, 0x69, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_internal_plugin_grpc_stdio_proto_rawDescOnce sync.Once + file_internal_plugin_grpc_stdio_proto_rawDescData = file_internal_plugin_grpc_stdio_proto_rawDesc +) -var _GRPCStdio_serviceDesc = grpc.ServiceDesc{ - ServiceName: "plugin.GRPCStdio", - HandlerType: (*GRPCStdioServer)(nil), - Methods: []grpc.MethodDesc{}, - Streams: []grpc.StreamDesc{ - { - StreamName: "StreamStdio", - Handler: _GRPCStdio_StreamStdio_Handler, - ServerStreams: true, +func file_internal_plugin_grpc_stdio_proto_rawDescGZIP() []byte { + file_internal_plugin_grpc_stdio_proto_rawDescOnce.Do(func() { + file_internal_plugin_grpc_stdio_proto_rawDescData = protoimpl.X.CompressGZIP(file_internal_plugin_grpc_stdio_proto_rawDescData) + }) + return file_internal_plugin_grpc_stdio_proto_rawDescData +} + +var file_internal_plugin_grpc_stdio_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_internal_plugin_grpc_stdio_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_internal_plugin_grpc_stdio_proto_goTypes = []interface{}{ + (StdioData_Channel)(0), // 0: plugin.StdioData.Channel + (*StdioData)(nil), // 1: plugin.StdioData + (*emptypb.Empty)(nil), // 2: google.protobuf.Empty +} +var file_internal_plugin_grpc_stdio_proto_depIdxs = []int32{ + 0, // 0: plugin.StdioData.channel:type_name -> plugin.StdioData.Channel + 2, // 1: plugin.GRPCStdio.StreamStdio:input_type -> google.protobuf.Empty + 1, // 2: plugin.GRPCStdio.StreamStdio:output_type -> plugin.StdioData + 2, // [2:3] is the sub-list for method output_type + 1, // [1:2] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name +} + +func init() { file_internal_plugin_grpc_stdio_proto_init() } +func file_internal_plugin_grpc_stdio_proto_init() { + if File_internal_plugin_grpc_stdio_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_internal_plugin_grpc_stdio_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*StdioData); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_internal_plugin_grpc_stdio_proto_rawDesc, + NumEnums: 1, + NumMessages: 1, + NumExtensions: 0, + NumServices: 1, }, - }, - Metadata: "grpc_stdio.proto", -} - -func init() { proto.RegisterFile("grpc_stdio.proto", fileDescriptor_grpc_stdio_db2934322ca63bd5) } - -var fileDescriptor_grpc_stdio_db2934322ca63bd5 = []byte{ - // 221 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x48, 0x2f, 0x2a, 0x48, - 0x8e, 0x2f, 0x2e, 0x49, 0xc9, 0xcc, 0xd7, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x2b, 0xc8, - 0x29, 0x4d, 0xcf, 0xcc, 0x93, 0x92, 0x4e, 0xcf, 0xcf, 0x4f, 0xcf, 0x49, 0xd5, 0x07, 0x8b, 0x26, - 0x95, 0xa6, 0xe9, 0xa7, 0xe6, 0x16, 0x94, 0x54, 0x42, 0x14, 0x29, 0xb5, 0x30, 0x72, 0x71, 0x06, - 0x83, 0x34, 0xb9, 0x24, 0x96, 0x24, 0x0a, 0x19, 0x73, 0xb1, 0x27, 0x67, 0x24, 0xe6, 0xe5, 0xa5, - 0xe6, 0x48, 0x30, 0x2a, 0x30, 0x6a, 0xf0, 0x19, 0x49, 0xea, 0x41, 0x0c, 0xd1, 0x83, 0xab, 0xd1, - 0x73, 0x86, 0x28, 0x08, 0x82, 0xa9, 0x14, 0x12, 0xe2, 0x62, 0x49, 0x49, 0x2c, 0x49, 0x94, 0x60, - 0x52, 0x60, 0xd4, 0xe0, 0x09, 0x02, 0xb3, 0x95, 0xf4, 0xb8, 0xd8, 0xa1, 0xea, 0x84, 0xb8, 0xb9, - 0xd8, 0x3d, 0xfd, 0xc2, 0x1c, 0x7d, 0x3c, 0x5d, 0x04, 0x18, 0x84, 0xb8, 0xb8, 0xd8, 0x82, 0x43, - 0x5c, 0xfc, 0x43, 0x43, 0x04, 0x18, 0xa1, 0x6c, 0xd7, 0xa0, 0x20, 0x01, 0x26, 0x23, 0x77, 0x2e, - 0x4e, 0xf7, 0xa0, 0x00, 0x67, 0xb0, 0x2d, 0x42, 0x56, 0x5c, 0xdc, 0xc1, 0x25, 0x45, 0xa9, 0x89, - 0xb9, 0x10, 0xae, 0x98, 0x1e, 0xc4, 0x03, 0x7a, 0x30, 0x0f, 0xe8, 0xb9, 0x82, 0x3c, 0x20, 0x25, - 0x88, 0xe1, 0x36, 0x03, 0x46, 0x27, 0x8e, 0x28, 0xa8, 0xb7, 0x93, 0xd8, 0xc0, 0xca, 0x8d, 0x01, - 0x01, 0x00, 0x00, 0xff, 0xff, 0x5d, 0xbb, 0xe0, 0x69, 0x19, 0x01, 0x00, 0x00, + GoTypes: file_internal_plugin_grpc_stdio_proto_goTypes, + DependencyIndexes: file_internal_plugin_grpc_stdio_proto_depIdxs, + EnumInfos: file_internal_plugin_grpc_stdio_proto_enumTypes, + MessageInfos: file_internal_plugin_grpc_stdio_proto_msgTypes, + }.Build() + File_internal_plugin_grpc_stdio_proto = out.File + file_internal_plugin_grpc_stdio_proto_rawDesc = nil + file_internal_plugin_grpc_stdio_proto_goTypes = nil + file_internal_plugin_grpc_stdio_proto_depIdxs = nil } diff --git a/internal/plugin/grpc_stdio_grpc.pb.go b/internal/plugin/grpc_stdio_grpc.pb.go new file mode 100644 index 00000000..37ad1e25 --- /dev/null +++ b/internal/plugin/grpc_stdio_grpc.pb.go @@ -0,0 +1,139 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. + +package plugin + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + emptypb "google.golang.org/protobuf/types/known/emptypb" +) + +// 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 + +// GRPCStdioClient is the client API for GRPCStdio service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type GRPCStdioClient interface { + // StreamStdio returns a stream that contains all the stdout/stderr. + // This RPC endpoint must only be called ONCE. Once stdio data is consumed + // it is not sent again. + // + // Callers should connect early to prevent blocking on the plugin process. + StreamStdio(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (GRPCStdio_StreamStdioClient, error) +} + +type gRPCStdioClient struct { + cc grpc.ClientConnInterface +} + +func NewGRPCStdioClient(cc grpc.ClientConnInterface) GRPCStdioClient { + return &gRPCStdioClient{cc} +} + +func (c *gRPCStdioClient) StreamStdio(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (GRPCStdio_StreamStdioClient, error) { + stream, err := c.cc.NewStream(ctx, &GRPCStdio_ServiceDesc.Streams[0], "/plugin.GRPCStdio/StreamStdio", opts...) + if err != nil { + return nil, err + } + x := &gRPCStdioStreamStdioClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +type GRPCStdio_StreamStdioClient interface { + Recv() (*StdioData, error) + grpc.ClientStream +} + +type gRPCStdioStreamStdioClient struct { + grpc.ClientStream +} + +func (x *gRPCStdioStreamStdioClient) Recv() (*StdioData, error) { + m := new(StdioData) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +// GRPCStdioServer is the server API for GRPCStdio service. +// All implementations must embed UnimplementedGRPCStdioServer +// for forward compatibility +type GRPCStdioServer interface { + // StreamStdio returns a stream that contains all the stdout/stderr. + // This RPC endpoint must only be called ONCE. Once stdio data is consumed + // it is not sent again. + // + // Callers should connect early to prevent blocking on the plugin process. + StreamStdio(*emptypb.Empty, GRPCStdio_StreamStdioServer) error + mustEmbedUnimplementedGRPCStdioServer() +} + +// UnimplementedGRPCStdioServer must be embedded to have forward compatible implementations. +type UnimplementedGRPCStdioServer struct { +} + +func (UnimplementedGRPCStdioServer) StreamStdio(*emptypb.Empty, GRPCStdio_StreamStdioServer) error { + return status.Errorf(codes.Unimplemented, "method StreamStdio not implemented") +} +func (UnimplementedGRPCStdioServer) mustEmbedUnimplementedGRPCStdioServer() {} + +// UnsafeGRPCStdioServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to GRPCStdioServer will +// result in compilation errors. +type UnsafeGRPCStdioServer interface { + mustEmbedUnimplementedGRPCStdioServer() +} + +func RegisterGRPCStdioServer(s grpc.ServiceRegistrar, srv GRPCStdioServer) { + s.RegisterService(&GRPCStdio_ServiceDesc, srv) +} + +func _GRPCStdio_StreamStdio_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(emptypb.Empty) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(GRPCStdioServer).StreamStdio(m, &gRPCStdioStreamStdioServer{stream}) +} + +type GRPCStdio_StreamStdioServer interface { + Send(*StdioData) error + grpc.ServerStream +} + +type gRPCStdioStreamStdioServer struct { + grpc.ServerStream +} + +func (x *gRPCStdioStreamStdioServer) Send(m *StdioData) error { + return x.ServerStream.SendMsg(m) +} + +// GRPCStdio_ServiceDesc is the grpc.ServiceDesc for GRPCStdio service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var GRPCStdio_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "plugin.GRPCStdio", + HandlerType: (*GRPCStdioServer)(nil), + Methods: []grpc.MethodDesc{}, + Streams: []grpc.StreamDesc{ + { + StreamName: "StreamStdio", + Handler: _GRPCStdio_StreamStdio_Handler, + ServerStreams: true, + }, + }, + Metadata: "internal/plugin/grpc_stdio.proto", +} diff --git a/test/grpc/test.pb.go b/test/grpc/test.pb.go index 559fb7d0..53c31956 100644 --- a/test/grpc/test.pb.go +++ b/test/grpc/test.pb.go @@ -1,163 +1,175 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + // Code generated by protoc-gen-go. DO NOT EDIT. -// source: test.proto +// versions: +// protoc-gen-go v1.28.1 +// protoc (unknown) +// source: test/grpc/test.proto package grpctest -import proto "github.com/golang/protobuf/proto" -import fmt "fmt" -import math "math" -import empty "github.com/golang/protobuf/ptypes/empty" - import ( - context "context" - grpc "google.golang.org/grpc" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + emptypb "google.golang.org/protobuf/types/known/emptypb" + reflect "reflect" + sync "sync" ) -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) type TestRequest struct { - Input int32 `protobuf:"varint,1,opt,name=Input,proto3" json:"Input,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func (m *TestRequest) Reset() { *m = TestRequest{} } -func (m *TestRequest) String() string { return proto.CompactTextString(m) } -func (*TestRequest) ProtoMessage() {} -func (*TestRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_test_ed149f2304c9fa82, []int{0} -} -func (m *TestRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_TestRequest.Unmarshal(m, b) + Input int32 `protobuf:"varint,1,opt,name=Input,proto3" json:"Input,omitempty"` } -func (m *TestRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_TestRequest.Marshal(b, m, deterministic) -} -func (dst *TestRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_TestRequest.Merge(dst, src) + +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) + } } -func (m *TestRequest) XXX_Size() int { - return xxx_messageInfo_TestRequest.Size(m) + +func (x *TestRequest) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *TestRequest) XXX_DiscardUnknown() { - xxx_messageInfo_TestRequest.DiscardUnknown(m) + +func (*TestRequest) ProtoMessage() {} + +func (x *TestRequest) ProtoReflect() protoreflect.Message { + mi := &file_test_grpc_test_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_TestRequest proto.InternalMessageInfo +// Deprecated: Use TestRequest.ProtoReflect.Descriptor instead. +func (*TestRequest) Descriptor() ([]byte, []int) { + return file_test_grpc_test_proto_rawDescGZIP(), []int{0} +} -func (m *TestRequest) GetInput() int32 { - if m != nil { - return m.Input +func (x *TestRequest) GetInput() int32 { + if x != nil { + return x.Input } return 0 } type TestResponse struct { - Output int32 `protobuf:"varint,2,opt,name=Output,proto3" json:"Output,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func (m *TestResponse) Reset() { *m = TestResponse{} } -func (m *TestResponse) String() string { return proto.CompactTextString(m) } -func (*TestResponse) ProtoMessage() {} -func (*TestResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_test_ed149f2304c9fa82, []int{1} -} -func (m *TestResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_TestResponse.Unmarshal(m, b) + Output int32 `protobuf:"varint,2,opt,name=Output,proto3" json:"Output,omitempty"` } -func (m *TestResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_TestResponse.Marshal(b, m, deterministic) -} -func (dst *TestResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_TestResponse.Merge(dst, src) + +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) + } } -func (m *TestResponse) XXX_Size() int { - return xxx_messageInfo_TestResponse.Size(m) + +func (x *TestResponse) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *TestResponse) XXX_DiscardUnknown() { - xxx_messageInfo_TestResponse.DiscardUnknown(m) + +func (*TestResponse) ProtoMessage() {} + +func (x *TestResponse) ProtoReflect() protoreflect.Message { + mi := &file_test_grpc_test_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -var xxx_messageInfo_TestResponse proto.InternalMessageInfo +// Deprecated: Use TestResponse.ProtoReflect.Descriptor instead. +func (*TestResponse) Descriptor() ([]byte, []int) { + return file_test_grpc_test_proto_rawDescGZIP(), []int{1} +} -func (m *TestResponse) GetOutput() int32 { - if m != nil { - return m.Output +func (x *TestResponse) GetOutput() int32 { + if x != nil { + return x.Output } return 0 } 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 valid to be assigned to Value: + // Types that are assignable to Value: + // // *PrintKVRequest_ValueString // *PrintKVRequest_ValueInt - Value isPrintKVRequest_Value `protobuf_oneof:"Value"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + Value isPrintKVRequest_Value `protobuf_oneof:"Value"` } -func (m *PrintKVRequest) Reset() { *m = PrintKVRequest{} } -func (m *PrintKVRequest) String() string { return proto.CompactTextString(m) } -func (*PrintKVRequest) ProtoMessage() {} -func (*PrintKVRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_test_ed149f2304c9fa82, []int{2} -} -func (m *PrintKVRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_PrintKVRequest.Unmarshal(m, b) -} -func (m *PrintKVRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_PrintKVRequest.Marshal(b, m, deterministic) -} -func (dst *PrintKVRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_PrintKVRequest.Merge(dst, src) -} -func (m *PrintKVRequest) XXX_Size() int { - return xxx_messageInfo_PrintKVRequest.Size(m) +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) + } } -func (m *PrintKVRequest) XXX_DiscardUnknown() { - xxx_messageInfo_PrintKVRequest.DiscardUnknown(m) + +func (x *PrintKVRequest) String() string { + return protoimpl.X.MessageStringOf(x) } -var xxx_messageInfo_PrintKVRequest proto.InternalMessageInfo +func (*PrintKVRequest) ProtoMessage() {} -func (m *PrintKVRequest) GetKey() string { - if m != nil { - return m.Key +func (x *PrintKVRequest) ProtoReflect() protoreflect.Message { + mi := &file_test_grpc_test_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms } - return "" + return mi.MessageOf(x) } -type isPrintKVRequest_Value interface { - isPrintKVRequest_Value() -} - -type PrintKVRequest_ValueString struct { - ValueString string `protobuf:"bytes,2,opt,name=ValueString,proto3,oneof"` +// Deprecated: Use PrintKVRequest.ProtoReflect.Descriptor instead. +func (*PrintKVRequest) Descriptor() ([]byte, []int) { + return file_test_grpc_test_proto_rawDescGZIP(), []int{2} } -type PrintKVRequest_ValueInt struct { - ValueInt int32 `protobuf:"varint,3,opt,name=ValueInt,proto3,oneof"` +func (x *PrintKVRequest) GetKey() string { + if x != nil { + return x.Key + } + return "" } -func (*PrintKVRequest_ValueString) isPrintKVRequest_Value() {} - -func (*PrintKVRequest_ValueInt) isPrintKVRequest_Value() {} - func (m *PrintKVRequest) GetValue() isPrintKVRequest_Value { if m != nil { return m.Value @@ -165,647 +177,550 @@ func (m *PrintKVRequest) GetValue() isPrintKVRequest_Value { return nil } -func (m *PrintKVRequest) GetValueString() string { - if x, ok := m.GetValue().(*PrintKVRequest_ValueString); ok { +func (x *PrintKVRequest) GetValueString() string { + if x, ok := x.GetValue().(*PrintKVRequest_ValueString); ok { return x.ValueString } return "" } -func (m *PrintKVRequest) GetValueInt() int32 { - if x, ok := m.GetValue().(*PrintKVRequest_ValueInt); ok { +func (x *PrintKVRequest) GetValueInt() int32 { + if x, ok := x.GetValue().(*PrintKVRequest_ValueInt); ok { return x.ValueInt } return 0 } -// XXX_OneofFuncs is for the internal use of the proto package. -func (*PrintKVRequest) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) { - return _PrintKVRequest_OneofMarshaler, _PrintKVRequest_OneofUnmarshaler, _PrintKVRequest_OneofSizer, []interface{}{ - (*PrintKVRequest_ValueString)(nil), - (*PrintKVRequest_ValueInt)(nil), - } -} - -func _PrintKVRequest_OneofMarshaler(msg proto.Message, b *proto.Buffer) error { - m := msg.(*PrintKVRequest) - // Value - switch x := m.Value.(type) { - case *PrintKVRequest_ValueString: - b.EncodeVarint(2<<3 | proto.WireBytes) - b.EncodeStringBytes(x.ValueString) - case *PrintKVRequest_ValueInt: - b.EncodeVarint(3<<3 | proto.WireVarint) - b.EncodeVarint(uint64(x.ValueInt)) - case nil: - default: - return fmt.Errorf("PrintKVRequest.Value has unexpected type %T", x) - } - return nil -} - -func _PrintKVRequest_OneofUnmarshaler(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error) { - m := msg.(*PrintKVRequest) - switch tag { - case 2: // Value.ValueString - if wire != proto.WireBytes { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeStringBytes() - m.Value = &PrintKVRequest_ValueString{x} - return true, err - case 3: // Value.ValueInt - if wire != proto.WireVarint { - return true, proto.ErrInternalBadWireType - } - x, err := b.DecodeVarint() - m.Value = &PrintKVRequest_ValueInt{int32(x)} - return true, err - default: - return false, nil - } -} - -func _PrintKVRequest_OneofSizer(msg proto.Message) (n int) { - m := msg.(*PrintKVRequest) - // Value - switch x := m.Value.(type) { - case *PrintKVRequest_ValueString: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(len(x.ValueString))) - n += len(x.ValueString) - case *PrintKVRequest_ValueInt: - n += 1 // tag and wire - n += proto.SizeVarint(uint64(x.ValueInt)) - case nil: - default: - panic(fmt.Sprintf("proto: unexpected type %T in oneof", x)) - } - return n +type isPrintKVRequest_Value interface { + isPrintKVRequest_Value() } -type PrintKVResponse struct { - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` +type PrintKVRequest_ValueString struct { + ValueString string `protobuf:"bytes,2,opt,name=ValueString,proto3,oneof"` } -func (m *PrintKVResponse) Reset() { *m = PrintKVResponse{} } -func (m *PrintKVResponse) String() string { return proto.CompactTextString(m) } -func (*PrintKVResponse) ProtoMessage() {} -func (*PrintKVResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_test_ed149f2304c9fa82, []int{3} -} -func (m *PrintKVResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_PrintKVResponse.Unmarshal(m, b) -} -func (m *PrintKVResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_PrintKVResponse.Marshal(b, m, deterministic) -} -func (dst *PrintKVResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_PrintKVResponse.Merge(dst, src) -} -func (m *PrintKVResponse) XXX_Size() int { - return xxx_messageInfo_PrintKVResponse.Size(m) -} -func (m *PrintKVResponse) XXX_DiscardUnknown() { - xxx_messageInfo_PrintKVResponse.DiscardUnknown(m) +type PrintKVRequest_ValueInt struct { + ValueInt int32 `protobuf:"varint,3,opt,name=ValueInt,proto3,oneof"` } -var xxx_messageInfo_PrintKVResponse proto.InternalMessageInfo +func (*PrintKVRequest_ValueString) isPrintKVRequest_Value() {} -type BidirectionalRequest struct { - Id uint32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} +func (*PrintKVRequest_ValueInt) isPrintKVRequest_Value() {} -func (m *BidirectionalRequest) Reset() { *m = BidirectionalRequest{} } -func (m *BidirectionalRequest) String() string { return proto.CompactTextString(m) } -func (*BidirectionalRequest) ProtoMessage() {} -func (*BidirectionalRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_test_ed149f2304c9fa82, []int{4} -} -func (m *BidirectionalRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_BidirectionalRequest.Unmarshal(m, b) -} -func (m *BidirectionalRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_BidirectionalRequest.Marshal(b, m, deterministic) -} -func (dst *BidirectionalRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_BidirectionalRequest.Merge(dst, src) -} -func (m *BidirectionalRequest) XXX_Size() int { - return xxx_messageInfo_BidirectionalRequest.Size(m) -} -func (m *BidirectionalRequest) XXX_DiscardUnknown() { - xxx_messageInfo_BidirectionalRequest.DiscardUnknown(m) +type PrintKVResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields } -var xxx_messageInfo_BidirectionalRequest proto.InternalMessageInfo - -func (m *BidirectionalRequest) GetId() uint32 { - if m != nil { - return m.Id +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) } - return 0 } -type BidirectionalResponse struct { - Id uint32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` +func (x *PrintKVResponse) String() string { + return protoimpl.X.MessageStringOf(x) } -func (m *BidirectionalResponse) Reset() { *m = BidirectionalResponse{} } -func (m *BidirectionalResponse) String() string { return proto.CompactTextString(m) } -func (*BidirectionalResponse) ProtoMessage() {} -func (*BidirectionalResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_test_ed149f2304c9fa82, []int{5} -} -func (m *BidirectionalResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_BidirectionalResponse.Unmarshal(m, b) -} -func (m *BidirectionalResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_BidirectionalResponse.Marshal(b, m, deterministic) -} -func (dst *BidirectionalResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_BidirectionalResponse.Merge(dst, src) -} -func (m *BidirectionalResponse) XXX_Size() int { - return xxx_messageInfo_BidirectionalResponse.Size(m) -} -func (m *BidirectionalResponse) XXX_DiscardUnknown() { - xxx_messageInfo_BidirectionalResponse.DiscardUnknown(m) -} +func (*PrintKVResponse) ProtoMessage() {} -var xxx_messageInfo_BidirectionalResponse proto.InternalMessageInfo - -func (m *BidirectionalResponse) GetId() uint32 { - if m != nil { - return m.Id +func (x *PrintKVResponse) ProtoReflect() protoreflect.Message { + mi := &file_test_grpc_test_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms } - return 0 -} - -type PrintStdioRequest struct { - Stdout []byte `protobuf:"bytes,1,opt,name=stdout,proto3" json:"stdout,omitempty"` - Stderr []byte `protobuf:"bytes,2,opt,name=stderr,proto3" json:"stderr,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + return mi.MessageOf(x) } -func (m *PrintStdioRequest) Reset() { *m = PrintStdioRequest{} } -func (m *PrintStdioRequest) String() string { return proto.CompactTextString(m) } -func (*PrintStdioRequest) ProtoMessage() {} -func (*PrintStdioRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_test_ed149f2304c9fa82, []int{6} -} -func (m *PrintStdioRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_PrintStdioRequest.Unmarshal(m, b) -} -func (m *PrintStdioRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_PrintStdioRequest.Marshal(b, m, deterministic) -} -func (dst *PrintStdioRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_PrintStdioRequest.Merge(dst, src) -} -func (m *PrintStdioRequest) XXX_Size() int { - return xxx_messageInfo_PrintStdioRequest.Size(m) -} -func (m *PrintStdioRequest) XXX_DiscardUnknown() { - xxx_messageInfo_PrintStdioRequest.DiscardUnknown(m) +// Deprecated: Use PrintKVResponse.ProtoReflect.Descriptor instead. +func (*PrintKVResponse) Descriptor() ([]byte, []int) { + return file_test_grpc_test_proto_rawDescGZIP(), []int{3} } -var xxx_messageInfo_PrintStdioRequest proto.InternalMessageInfo +type BidirectionalRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func (m *PrintStdioRequest) GetStdout() []byte { - if m != nil { - return m.Stdout - } - return nil + Id uint32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` } -func (m *PrintStdioRequest) GetStderr() []byte { - if m != nil { - return m.Stderr +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) } - return nil } -type PingRequest struct { - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *PingRequest) Reset() { *m = PingRequest{} } -func (m *PingRequest) String() string { return proto.CompactTextString(m) } -func (*PingRequest) ProtoMessage() {} -func (*PingRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_test_ed149f2304c9fa82, []int{7} -} -func (m *PingRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_PingRequest.Unmarshal(m, b) -} -func (m *PingRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_PingRequest.Marshal(b, m, deterministic) -} -func (dst *PingRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_PingRequest.Merge(dst, src) -} -func (m *PingRequest) XXX_Size() int { - return xxx_messageInfo_PingRequest.Size(m) -} -func (m *PingRequest) XXX_DiscardUnknown() { - xxx_messageInfo_PingRequest.DiscardUnknown(m) +func (x *BidirectionalRequest) String() string { + return protoimpl.X.MessageStringOf(x) } -var xxx_messageInfo_PingRequest proto.InternalMessageInfo +func (*BidirectionalRequest) ProtoMessage() {} -type PongResponse struct { - Msg string `protobuf:"bytes,1,opt,name=msg,proto3" json:"msg,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` +func (x *BidirectionalRequest) ProtoReflect() protoreflect.Message { + mi := &file_test_grpc_test_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -func (m *PongResponse) Reset() { *m = PongResponse{} } -func (m *PongResponse) String() string { return proto.CompactTextString(m) } -func (*PongResponse) ProtoMessage() {} -func (*PongResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_test_ed149f2304c9fa82, []int{8} -} -func (m *PongResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_PongResponse.Unmarshal(m, b) -} -func (m *PongResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_PongResponse.Marshal(b, m, deterministic) -} -func (dst *PongResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_PongResponse.Merge(dst, src) -} -func (m *PongResponse) XXX_Size() int { - return xxx_messageInfo_PongResponse.Size(m) -} -func (m *PongResponse) XXX_DiscardUnknown() { - xxx_messageInfo_PongResponse.DiscardUnknown(m) +// Deprecated: Use BidirectionalRequest.ProtoReflect.Descriptor instead. +func (*BidirectionalRequest) Descriptor() ([]byte, []int) { + return file_test_grpc_test_proto_rawDescGZIP(), []int{4} } -var xxx_messageInfo_PongResponse proto.InternalMessageInfo - -func (m *PongResponse) GetMsg() string { - if m != nil { - return m.Msg +func (x *BidirectionalRequest) GetId() uint32 { + if x != nil { + return x.Id } - return "" -} - -func init() { - proto.RegisterType((*TestRequest)(nil), "grpctest.TestRequest") - proto.RegisterType((*TestResponse)(nil), "grpctest.TestResponse") - proto.RegisterType((*PrintKVRequest)(nil), "grpctest.PrintKVRequest") - proto.RegisterType((*PrintKVResponse)(nil), "grpctest.PrintKVResponse") - proto.RegisterType((*BidirectionalRequest)(nil), "grpctest.BidirectionalRequest") - proto.RegisterType((*BidirectionalResponse)(nil), "grpctest.BidirectionalResponse") - proto.RegisterType((*PrintStdioRequest)(nil), "grpctest.PrintStdioRequest") - proto.RegisterType((*PingRequest)(nil), "grpctest.PingRequest") - proto.RegisterType((*PongResponse)(nil), "grpctest.PongResponse") + return 0 } -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 +type BidirectionalResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -// TestClient is the client API for Test service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type TestClient interface { - Double(ctx context.Context, in *TestRequest, opts ...grpc.CallOption) (*TestResponse, error) - PrintKV(ctx context.Context, in *PrintKVRequest, opts ...grpc.CallOption) (*PrintKVResponse, error) - 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) (*empty.Empty, error) + Id uint32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` } -type testClient struct { - cc *grpc.ClientConn +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) + } } -func NewTestClient(cc *grpc.ClientConn) TestClient { - return &testClient{cc} +func (x *BidirectionalResponse) String() string { + return protoimpl.X.MessageStringOf(x) } -func (c *testClient) Double(ctx context.Context, in *TestRequest, opts ...grpc.CallOption) (*TestResponse, error) { - out := new(TestResponse) - err := c.cc.Invoke(ctx, "/grpctest.Test/Double", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} +func (*BidirectionalResponse) ProtoMessage() {} -func (c *testClient) PrintKV(ctx context.Context, in *PrintKVRequest, opts ...grpc.CallOption) (*PrintKVResponse, error) { - out := new(PrintKVResponse) - err := c.cc.Invoke(ctx, "/grpctest.Test/PrintKV", in, out, opts...) - if err != nil { - return nil, err +func (x *BidirectionalResponse) ProtoReflect() protoreflect.Message { + mi := &file_test_grpc_test_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms } - return out, nil + return mi.MessageOf(x) } -func (c *testClient) Bidirectional(ctx context.Context, in *BidirectionalRequest, opts ...grpc.CallOption) (*BidirectionalResponse, error) { - out := new(BidirectionalResponse) - err := c.cc.Invoke(ctx, "/grpctest.Test/Bidirectional", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil +// Deprecated: Use BidirectionalResponse.ProtoReflect.Descriptor instead. +func (*BidirectionalResponse) Descriptor() ([]byte, []int) { + return file_test_grpc_test_proto_rawDescGZIP(), []int{5} } -func (c *testClient) Stream(ctx context.Context, opts ...grpc.CallOption) (Test_StreamClient, error) { - stream, err := c.cc.NewStream(ctx, &_Test_serviceDesc.Streams[0], "/grpctest.Test/Stream", opts...) - if err != nil { - return nil, err +func (x *BidirectionalResponse) GetId() uint32 { + if x != nil { + return x.Id } - x := &testStreamClient{stream} - return x, nil -} - -type Test_StreamClient interface { - Send(*TestRequest) error - Recv() (*TestResponse, error) - grpc.ClientStream + return 0 } -type testStreamClient struct { - grpc.ClientStream -} +type PrintStdioRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -func (x *testStreamClient) Send(m *TestRequest) error { - return x.ClientStream.SendMsg(m) + Stdout []byte `protobuf:"bytes,1,opt,name=stdout,proto3" json:"stdout,omitempty"` + Stderr []byte `protobuf:"bytes,2,opt,name=stderr,proto3" json:"stderr,omitempty"` } -func (x *testStreamClient) Recv() (*TestResponse, error) { - m := new(TestResponse) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err +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) } - return m, nil } -func (c *testClient) PrintStdio(ctx context.Context, in *PrintStdioRequest, opts ...grpc.CallOption) (*empty.Empty, error) { - out := new(empty.Empty) - err := c.cc.Invoke(ctx, "/grpctest.Test/PrintStdio", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil +func (x *PrintStdioRequest) String() string { + return protoimpl.X.MessageStringOf(x) } -// TestServer is the server API for Test service. -type TestServer interface { - Double(context.Context, *TestRequest) (*TestResponse, error) - PrintKV(context.Context, *PrintKVRequest) (*PrintKVResponse, error) - Bidirectional(context.Context, *BidirectionalRequest) (*BidirectionalResponse, error) - Stream(Test_StreamServer) error - PrintStdio(context.Context, *PrintStdioRequest) (*empty.Empty, error) -} +func (*PrintStdioRequest) ProtoMessage() {} -func RegisterTestServer(s *grpc.Server, srv TestServer) { - s.RegisterService(&_Test_serviceDesc, srv) +func (x *PrintStdioRequest) ProtoReflect() protoreflect.Message { + mi := &file_test_grpc_test_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) } -func _Test_Double_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(TestRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(TestServer).Double(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/grpctest.Test/Double", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(TestServer).Double(ctx, req.(*TestRequest)) - } - return interceptor(ctx, in, info, handler) +// Deprecated: Use PrintStdioRequest.ProtoReflect.Descriptor instead. +func (*PrintStdioRequest) Descriptor() ([]byte, []int) { + return file_test_grpc_test_proto_rawDescGZIP(), []int{6} } -func _Test_PrintKV_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(PrintKVRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(TestServer).PrintKV(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/grpctest.Test/PrintKV", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(TestServer).PrintKV(ctx, req.(*PrintKVRequest)) +func (x *PrintStdioRequest) GetStdout() []byte { + if x != nil { + return x.Stdout } - return interceptor(ctx, in, info, handler) + return nil } -func _Test_Bidirectional_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(BidirectionalRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(TestServer).Bidirectional(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/grpctest.Test/Bidirectional", +func (x *PrintStdioRequest) GetStderr() []byte { + if x != nil { + return x.Stderr } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(TestServer).Bidirectional(ctx, req.(*BidirectionalRequest)) - } - return interceptor(ctx, in, info, handler) + return nil } -func _Test_Stream_Handler(srv interface{}, stream grpc.ServerStream) error { - return srv.(TestServer).Stream(&testStreamServer{stream}) +type PingRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields } -type Test_StreamServer interface { - Send(*TestResponse) error - Recv() (*TestRequest, error) - grpc.ServerStream +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) + } } -type testStreamServer struct { - grpc.ServerStream +func (x *PingRequest) String() string { + return protoimpl.X.MessageStringOf(x) } -func (x *testStreamServer) Send(m *TestResponse) error { - return x.ServerStream.SendMsg(m) -} +func (*PingRequest) ProtoMessage() {} -func (x *testStreamServer) Recv() (*TestRequest, error) { - m := new(TestRequest) - if err := x.ServerStream.RecvMsg(m); err != nil { - return nil, err +func (x *PingRequest) ProtoReflect() protoreflect.Message { + mi := &file_test_grpc_test_proto_msgTypes[7] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms } - return m, nil + return mi.MessageOf(x) } -func _Test_PrintStdio_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(PrintStdioRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(TestServer).PrintStdio(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/grpctest.Test/PrintStdio", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(TestServer).PrintStdio(ctx, req.(*PrintStdioRequest)) - } - return interceptor(ctx, in, info, handler) +// Deprecated: Use PingRequest.ProtoReflect.Descriptor instead. +func (*PingRequest) Descriptor() ([]byte, []int) { + return file_test_grpc_test_proto_rawDescGZIP(), []int{7} } -var _Test_serviceDesc = grpc.ServiceDesc{ - ServiceName: "grpctest.Test", - HandlerType: (*TestServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Double", - Handler: _Test_Double_Handler, - }, - { - MethodName: "PrintKV", - Handler: _Test_PrintKV_Handler, - }, - { - MethodName: "Bidirectional", - Handler: _Test_Bidirectional_Handler, - }, - { - MethodName: "PrintStdio", - Handler: _Test_PrintStdio_Handler, - }, - }, - Streams: []grpc.StreamDesc{ - { - StreamName: "Stream", - Handler: _Test_Stream_Handler, - ServerStreams: true, - ClientStreams: true, - }, - }, - Metadata: "test.proto", -} +type PongResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -// PingPongClient is the client API for PingPong service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type PingPongClient interface { - Ping(ctx context.Context, in *PingRequest, opts ...grpc.CallOption) (*PongResponse, error) + Msg string `protobuf:"bytes,1,opt,name=msg,proto3" json:"msg,omitempty"` } -type pingPongClient struct { - cc *grpc.ClientConn +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) + } } -func NewPingPongClient(cc *grpc.ClientConn) PingPongClient { - return &pingPongClient{cc} +func (x *PongResponse) String() string { + return protoimpl.X.MessageStringOf(x) } -func (c *pingPongClient) Ping(ctx context.Context, in *PingRequest, opts ...grpc.CallOption) (*PongResponse, error) { - out := new(PongResponse) - err := c.cc.Invoke(ctx, "/grpctest.PingPong/Ping", in, out, opts...) - if err != nil { - return nil, err +func (*PongResponse) ProtoMessage() {} + +func (x *PongResponse) ProtoReflect() protoreflect.Message { + mi := &file_test_grpc_test_proto_msgTypes[8] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms } - return out, nil + return mi.MessageOf(x) } -// PingPongServer is the server API for PingPong service. -type PingPongServer interface { - Ping(context.Context, *PingRequest) (*PongResponse, error) +// Deprecated: Use PongResponse.ProtoReflect.Descriptor instead. +func (*PongResponse) Descriptor() ([]byte, []int) { + return file_test_grpc_test_proto_rawDescGZIP(), []int{8} } -func RegisterPingPongServer(s *grpc.Server, srv PingPongServer) { - s.RegisterService(&_PingPong_serviceDesc, srv) +func (x *PongResponse) GetMsg() string { + if x != nil { + return x.Msg + } + return "" } -func _PingPong_Ping_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(PingRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(PingPongServer).Ping(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/grpctest.PingPong/Ping", +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_grpc_test_proto_rawDescOnce sync.Once + file_test_grpc_test_proto_rawDescData = file_test_grpc_test_proto_rawDesc +) + +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) + }) + return file_test_grpc_test_proto_rawDescData +} + +var file_test_grpc_test_proto_msgTypes = make([]protoimpl.MessageInfo, 9) +var file_test_grpc_test_proto_goTypes = []interface{}{ + (*TestRequest)(nil), // 0: grpctest.TestRequest + (*TestResponse)(nil), // 1: grpctest.TestResponse + (*PrintKVRequest)(nil), // 2: grpctest.PrintKVRequest + (*PrintKVResponse)(nil), // 3: grpctest.PrintKVResponse + (*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 { + 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 + } + } } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(PingPongServer).Ping(ctx, req.(*PingRequest)) + file_test_grpc_test_proto_msgTypes[2].OneofWrappers = []interface{}{ + (*PrintKVRequest_ValueString)(nil), + (*PrintKVRequest_ValueInt)(nil), } - return interceptor(ctx, in, info, handler) -} - -var _PingPong_serviceDesc = grpc.ServiceDesc{ - ServiceName: "grpctest.PingPong", - HandlerType: (*PingPongServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Ping", - Handler: _PingPong_Ping_Handler, + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_test_grpc_test_proto_rawDesc, + NumEnums: 0, + NumMessages: 9, + NumExtensions: 0, + NumServices: 2, }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "test.proto", -} - -func init() { proto.RegisterFile("test.proto", fileDescriptor_test_ed149f2304c9fa82) } - -var fileDescriptor_test_ed149f2304c9fa82 = []byte{ - // 431 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x52, 0x41, 0x6f, 0xda, 0x30, - 0x18, 0x4d, 0x42, 0x49, 0xe9, 0x07, 0x74, 0xad, 0xd5, 0x22, 0x96, 0x4e, 0x5b, 0xe5, 0x49, 0x5d, - 0x4f, 0xe9, 0xd4, 0x1d, 0xa6, 0x1d, 0x26, 0x4d, 0xb0, 0x49, 0x20, 0x0e, 0x43, 0x66, 0xe2, 0x0e, - 0xc4, 0x8b, 0x2c, 0x25, 0x71, 0x66, 0x3b, 0x07, 0x7e, 0xeb, 0xfe, 0xcc, 0x64, 0xc7, 0x09, 0x21, - 0x62, 0x87, 0xde, 0xfc, 0xbd, 0xbc, 0xbc, 0xef, 0xf9, 0x3d, 0x03, 0x28, 0x2a, 0x55, 0x98, 0x0b, - 0xae, 0x38, 0xea, 0xc5, 0x22, 0xdf, 0xe9, 0x39, 0xb8, 0x8b, 0x39, 0x8f, 0x13, 0xfa, 0x64, 0xf0, - 0x6d, 0xf1, 0xfb, 0x89, 0xa6, 0xb9, 0xda, 0x97, 0x34, 0xfc, 0x1e, 0xfa, 0xbf, 0xa8, 0x54, 0x84, - 0xfe, 0x29, 0xa8, 0x54, 0xe8, 0x06, 0xba, 0xf3, 0x2c, 0x2f, 0xd4, 0xd8, 0xbd, 0x77, 0x1f, 0xbb, - 0xa4, 0x1c, 0xf0, 0x03, 0x0c, 0x4a, 0x92, 0xcc, 0x79, 0x26, 0x29, 0x1a, 0x81, 0xff, 0xb3, 0x50, - 0x9a, 0xe6, 0x19, 0x9a, 0x9d, 0x70, 0x0a, 0x97, 0x4b, 0xc1, 0x32, 0xb5, 0x58, 0x57, 0x7a, 0x57, - 0xd0, 0x59, 0xd0, 0xbd, 0x51, 0xbb, 0x20, 0xfa, 0x88, 0x30, 0xf4, 0xd7, 0x9b, 0xa4, 0xa0, 0x2b, - 0x25, 0x58, 0x16, 0x1b, 0x81, 0x8b, 0x99, 0x43, 0x9a, 0x20, 0x7a, 0x03, 0x3d, 0x33, 0xce, 0x33, - 0x35, 0xee, 0xe8, 0x0d, 0x33, 0x87, 0xd4, 0xc8, 0xe4, 0x1c, 0xba, 0xe6, 0x8c, 0xaf, 0xe1, 0x55, - 0xbd, 0xae, 0x74, 0x86, 0x1f, 0xe0, 0x66, 0xc2, 0x22, 0x26, 0xe8, 0x4e, 0x31, 0x9e, 0x6d, 0x92, - 0xca, 0xc7, 0x25, 0x78, 0x2c, 0x32, 0x36, 0x86, 0xc4, 0x63, 0x11, 0xfe, 0x00, 0xb7, 0x2d, 0x9e, - 0xbd, 0x5a, 0x9b, 0x38, 0x85, 0x6b, 0xb3, 0x63, 0xa5, 0x22, 0xc6, 0x2b, 0xb5, 0x11, 0xf8, 0x52, - 0x45, 0xdc, 0xc6, 0x34, 0x20, 0x76, 0xb2, 0x38, 0x15, 0xc2, 0x5c, 0xab, 0xc4, 0xa9, 0x10, 0x78, - 0x08, 0xfd, 0x25, 0xcb, 0x62, 0xfb, 0x3b, 0xbe, 0x87, 0xc1, 0x92, 0xeb, 0xd1, 0xee, 0xbc, 0x82, - 0x4e, 0x2a, 0xe3, 0x2a, 0xa4, 0x54, 0xc6, 0xcf, 0x7f, 0x3d, 0x38, 0xd3, 0x89, 0xa3, 0x2f, 0xe0, - 0x7f, 0xe7, 0xc5, 0x36, 0xa1, 0xe8, 0x36, 0xac, 0x0a, 0x0d, 0x1b, 0x85, 0x05, 0xa3, 0x36, 0x6c, - 0x83, 0x70, 0xd0, 0x37, 0x38, 0xb7, 0xe9, 0xa0, 0xf1, 0x81, 0x74, 0xdc, 0x4f, 0xf0, 0xfa, 0xc4, - 0x97, 0x5a, 0x81, 0xc0, 0xf0, 0x28, 0x24, 0xf4, 0xf6, 0xc0, 0x3e, 0x95, 0x72, 0xf0, 0xee, 0xbf, - 0xdf, 0x6b, 0xcd, 0xaf, 0xe0, 0xaf, 0x94, 0xa0, 0x9b, 0xf4, 0xc5, 0x17, 0x7a, 0x74, 0x3f, 0xba, - 0x68, 0x0a, 0x70, 0xa8, 0x03, 0xdd, 0xb5, 0xdc, 0x37, 0x4b, 0xd2, 0x42, 0xe6, 0xdd, 0x87, 0xd5, - 0xbb, 0x0f, 0x7f, 0xe8, 0x77, 0x8f, 0x9d, 0xe7, 0x29, 0xf4, 0x74, 0x1d, 0xba, 0x03, 0xf4, 0x19, - 0xce, 0xf4, 0xb9, 0xe9, 0xa6, 0x51, 0x55, 0xd3, 0x4d, 0xb3, 0x32, 0xec, 0x6c, 0x7d, 0x23, 0xfb, - 0xe9, 0x5f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x11, 0x4b, 0x8c, 0x40, 0x74, 0x03, 0x00, 0x00, + GoTypes: file_test_grpc_test_proto_goTypes, + DependencyIndexes: file_test_grpc_test_proto_depIdxs, + MessageInfos: file_test_grpc_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 } diff --git a/test/grpc/test_grpc.pb.go b/test/grpc/test_grpc.pb.go new file mode 100644 index 00000000..57eafbbe --- /dev/null +++ b/test/grpc/test_grpc.pb.go @@ -0,0 +1,365 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. + +package grpctest + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + emptypb "google.golang.org/protobuf/types/known/emptypb" +) + +// 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 + +// TestClient is the client API for Test service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type TestClient interface { + Double(ctx context.Context, in *TestRequest, opts ...grpc.CallOption) (*TestResponse, error) + PrintKV(ctx context.Context, in *PrintKVRequest, opts ...grpc.CallOption) (*PrintKVResponse, error) + 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) +} + +type testClient struct { + cc grpc.ClientConnInterface +} + +func NewTestClient(cc grpc.ClientConnInterface) TestClient { + return &testClient{cc} +} + +func (c *testClient) Double(ctx context.Context, in *TestRequest, opts ...grpc.CallOption) (*TestResponse, error) { + out := new(TestResponse) + err := c.cc.Invoke(ctx, "/grpctest.Test/Double", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *testClient) PrintKV(ctx context.Context, in *PrintKVRequest, opts ...grpc.CallOption) (*PrintKVResponse, error) { + out := new(PrintKVResponse) + err := c.cc.Invoke(ctx, "/grpctest.Test/PrintKV", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *testClient) Bidirectional(ctx context.Context, in *BidirectionalRequest, opts ...grpc.CallOption) (*BidirectionalResponse, error) { + out := new(BidirectionalResponse) + err := c.cc.Invoke(ctx, "/grpctest.Test/Bidirectional", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *testClient) Stream(ctx context.Context, opts ...grpc.CallOption) (Test_StreamClient, error) { + stream, err := c.cc.NewStream(ctx, &Test_ServiceDesc.Streams[0], "/grpctest.Test/Stream", opts...) + if err != nil { + return nil, err + } + x := &testStreamClient{stream} + return x, nil +} + +type Test_StreamClient interface { + Send(*TestRequest) error + Recv() (*TestResponse, error) + grpc.ClientStream +} + +type testStreamClient struct { + grpc.ClientStream +} + +func (x *testStreamClient) Send(m *TestRequest) error { + return x.ClientStream.SendMsg(m) +} + +func (x *testStreamClient) Recv() (*TestResponse, error) { + m := new(TestResponse) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func (c *testClient) PrintStdio(ctx context.Context, in *PrintStdioRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) { + out := new(emptypb.Empty) + err := c.cc.Invoke(ctx, "/grpctest.Test/PrintStdio", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// TestServer is the server API for Test service. +// All implementations must embed UnimplementedTestServer +// for forward compatibility +type TestServer interface { + Double(context.Context, *TestRequest) (*TestResponse, error) + PrintKV(context.Context, *PrintKVRequest) (*PrintKVResponse, error) + Bidirectional(context.Context, *BidirectionalRequest) (*BidirectionalResponse, error) + Stream(Test_StreamServer) error + PrintStdio(context.Context, *PrintStdioRequest) (*emptypb.Empty, error) + mustEmbedUnimplementedTestServer() +} + +// UnimplementedTestServer must be embedded to have forward compatible implementations. +type UnimplementedTestServer struct { +} + +func (UnimplementedTestServer) Double(context.Context, *TestRequest) (*TestResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Double not implemented") +} +func (UnimplementedTestServer) PrintKV(context.Context, *PrintKVRequest) (*PrintKVResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method PrintKV not implemented") +} +func (UnimplementedTestServer) Bidirectional(context.Context, *BidirectionalRequest) (*BidirectionalResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Bidirectional not implemented") +} +func (UnimplementedTestServer) Stream(Test_StreamServer) error { + return status.Errorf(codes.Unimplemented, "method Stream not implemented") +} +func (UnimplementedTestServer) PrintStdio(context.Context, *PrintStdioRequest) (*emptypb.Empty, error) { + return nil, status.Errorf(codes.Unimplemented, "method PrintStdio not implemented") +} +func (UnimplementedTestServer) mustEmbedUnimplementedTestServer() {} + +// 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 +// result in compilation errors. +type UnsafeTestServer interface { + mustEmbedUnimplementedTestServer() +} + +func RegisterTestServer(s grpc.ServiceRegistrar, srv TestServer) { + s.RegisterService(&Test_ServiceDesc, srv) +} + +func _Test_Double_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(TestRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(TestServer).Double(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/grpctest.Test/Double", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(TestServer).Double(ctx, req.(*TestRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Test_PrintKV_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(PrintKVRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(TestServer).PrintKV(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/grpctest.Test/PrintKV", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(TestServer).PrintKV(ctx, req.(*PrintKVRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Test_Bidirectional_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(BidirectionalRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(TestServer).Bidirectional(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/grpctest.Test/Bidirectional", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(TestServer).Bidirectional(ctx, req.(*BidirectionalRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Test_Stream_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(TestServer).Stream(&testStreamServer{stream}) +} + +type Test_StreamServer interface { + Send(*TestResponse) error + Recv() (*TestRequest, error) + grpc.ServerStream +} + +type testStreamServer struct { + grpc.ServerStream +} + +func (x *testStreamServer) Send(m *TestResponse) error { + return x.ServerStream.SendMsg(m) +} + +func (x *testStreamServer) Recv() (*TestRequest, error) { + m := new(TestRequest) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func _Test_PrintStdio_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(PrintStdioRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(TestServer).PrintStdio(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/grpctest.Test/PrintStdio", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(TestServer).PrintStdio(ctx, req.(*PrintStdioRequest)) + } + 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) +var Test_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "grpctest.Test", + HandlerType: (*TestServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Double", + Handler: _Test_Double_Handler, + }, + { + MethodName: "PrintKV", + Handler: _Test_PrintKV_Handler, + }, + { + MethodName: "Bidirectional", + Handler: _Test_Bidirectional_Handler, + }, + { + MethodName: "PrintStdio", + Handler: _Test_PrintStdio_Handler, + }, + }, + Streams: []grpc.StreamDesc{ + { + StreamName: "Stream", + Handler: _Test_Stream_Handler, + ServerStreams: true, + ClientStreams: true, + }, + }, + Metadata: "test/grpc/test.proto", +} + +// PingPongClient is the client API for PingPong service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type PingPongClient interface { + Ping(ctx context.Context, in *PingRequest, opts ...grpc.CallOption) (*PongResponse, error) +} + +type pingPongClient struct { + cc grpc.ClientConnInterface +} + +func NewPingPongClient(cc grpc.ClientConnInterface) PingPongClient { + return &pingPongClient{cc} +} + +func (c *pingPongClient) Ping(ctx context.Context, in *PingRequest, opts ...grpc.CallOption) (*PongResponse, error) { + out := new(PongResponse) + err := c.cc.Invoke(ctx, "/grpctest.PingPong/Ping", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// PingPongServer is the server API for PingPong service. +// All implementations must embed UnimplementedPingPongServer +// for forward compatibility +type PingPongServer interface { + Ping(context.Context, *PingRequest) (*PongResponse, error) + mustEmbedUnimplementedPingPongServer() +} + +// UnimplementedPingPongServer must be embedded to have forward compatible implementations. +type UnimplementedPingPongServer struct { +} + +func (UnimplementedPingPongServer) Ping(context.Context, *PingRequest) (*PongResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Ping not implemented") +} +func (UnimplementedPingPongServer) mustEmbedUnimplementedPingPongServer() {} + +// UnsafePingPongServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to PingPongServer will +// result in compilation errors. +type UnsafePingPongServer interface { + mustEmbedUnimplementedPingPongServer() +} + +func RegisterPingPongServer(s grpc.ServiceRegistrar, srv PingPongServer) { + s.RegisterService(&PingPong_ServiceDesc, srv) +} + +func _PingPong_Ping_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(PingRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PingPongServer).Ping(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/grpctest.PingPong/Ping", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PingPongServer).Ping(ctx, req.(*PingRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// PingPong_ServiceDesc is the grpc.ServiceDesc for PingPong service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var PingPong_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "grpctest.PingPong", + HandlerType: (*PingPongServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Ping", + Handler: _PingPong_Ping_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "test/grpc/test.proto", +} From 12f868f81df248244f8b973bc30615eb48ee1291 Mon Sep 17 00:00:00 2001 From: Tom Proctor Date: Wed, 11 Oct 2023 14:27:19 +0100 Subject: [PATCH 3/6] Fix build: embed unimplemented servers for forwards compatibility --- examples/bidirectional/shared/grpc.go | 2 ++ examples/grpc/shared/grpc.go | 1 + grpc_broker.go | 2 ++ grpc_controller.go | 1 + grpc_stdio.go | 1 + plugin_test.go | 5 ++++- 6 files changed, 11 insertions(+), 1 deletion(-) diff --git a/examples/bidirectional/shared/grpc.go b/examples/bidirectional/shared/grpc.go index d2c05422..4068c837 100644 --- a/examples/bidirectional/shared/grpc.go +++ b/examples/bidirectional/shared/grpc.go @@ -55,6 +55,7 @@ func (m *GRPCClient) Get(key string) (int64, error) { // Here is the gRPC server that GRPCClient talks to. type GRPCServer struct { + proto.UnimplementedCounterServer // This is the real implementation Impl Counter @@ -94,6 +95,7 @@ func (m *GRPCAddHelperClient) Sum(a, b int64) (int64, error) { // Here is the gRPC server that GRPCClient talks to. type GRPCAddHelperServer struct { + proto.UnimplementedAddHelperServer // This is the real implementation Impl AddHelper } diff --git a/examples/grpc/shared/grpc.go b/examples/grpc/shared/grpc.go index 5846bdf4..c6210431 100644 --- a/examples/grpc/shared/grpc.go +++ b/examples/grpc/shared/grpc.go @@ -33,6 +33,7 @@ func (m *GRPCClient) Get(key string) ([]byte, error) { // Here is the gRPC server that GRPCClient talks to. type GRPCServer struct { + proto.UnimplementedKVServer // This is the real implementation Impl KV } diff --git a/grpc_broker.go b/grpc_broker.go index b86561a0..60bbb0a4 100644 --- a/grpc_broker.go +++ b/grpc_broker.go @@ -40,6 +40,8 @@ type sendErr struct { // connection information to/from the plugin. Implements GRPCBrokerServer and // streamer interfaces. type gRPCBrokerServer struct { + plugin.UnimplementedGRPCBrokerServer + // send is used to send connection info to the gRPC stream. send chan *sendErr diff --git a/grpc_controller.go b/grpc_controller.go index 2085356c..a5ff2c6d 100644 --- a/grpc_controller.go +++ b/grpc_controller.go @@ -12,6 +12,7 @@ import ( // GRPCControllerServer handles shutdown calls to terminate the server when the // plugin client is closed. type grpcControllerServer struct { + plugin.UnimplementedGRPCControllerServer server *GRPCServer } diff --git a/grpc_stdio.go b/grpc_stdio.go index ae06c116..190b73ca 100644 --- a/grpc_stdio.go +++ b/grpc_stdio.go @@ -24,6 +24,7 @@ const grpcStdioBuffer = 1 * 1024 // grpcStdioServer implements the Stdio service and streams stdiout/stderr. type grpcStdioServer struct { + plugin.UnimplementedGRPCStdioServer stdoutCh <-chan []byte stderrCh <-chan []byte } diff --git a/plugin_test.go b/plugin_test.go index 45fdf23c..21b8b179 100644 --- a/plugin_test.go +++ b/plugin_test.go @@ -207,6 +207,7 @@ var testGRPCPluginMap = map[string]Plugin{ // testGRPCServer is the implementation of our GRPC service. type testGRPCServer struct { + grpctest.UnimplementedTestServer Impl testInterface broker *GRPCBroker } @@ -273,7 +274,9 @@ func (s *testGRPCServer) PrintStdio( return &empty.Empty{}, nil } -type pingPongServer struct{} +type pingPongServer struct { + grpctest.UnimplementedPingPongServer +} func (p *pingPongServer) Ping(ctx context.Context, req *grpctest.PingRequest) (*grpctest.PongResponse, error) { return &grpctest.PongResponse{ From 26191943a0999a8211e347033ea2eb5839db0375 Mon Sep 17 00:00:00 2001 From: Tom Proctor Date: Thu, 12 Oct 2023 17:25:38 +0100 Subject: [PATCH 4/6] Revert "Fix build: embed unimplemented servers for forwards compatibility" This reverts commit 12f868f81df248244f8b973bc30615eb48ee1291. --- examples/bidirectional/shared/grpc.go | 2 -- examples/grpc/shared/grpc.go | 1 - grpc_broker.go | 2 -- grpc_controller.go | 1 - grpc_stdio.go | 1 - plugin_test.go | 5 +---- 6 files changed, 1 insertion(+), 11 deletions(-) diff --git a/examples/bidirectional/shared/grpc.go b/examples/bidirectional/shared/grpc.go index 4068c837..d2c05422 100644 --- a/examples/bidirectional/shared/grpc.go +++ b/examples/bidirectional/shared/grpc.go @@ -55,7 +55,6 @@ func (m *GRPCClient) Get(key string) (int64, error) { // Here is the gRPC server that GRPCClient talks to. type GRPCServer struct { - proto.UnimplementedCounterServer // This is the real implementation Impl Counter @@ -95,7 +94,6 @@ func (m *GRPCAddHelperClient) Sum(a, b int64) (int64, error) { // Here is the gRPC server that GRPCClient talks to. type GRPCAddHelperServer struct { - proto.UnimplementedAddHelperServer // This is the real implementation Impl AddHelper } diff --git a/examples/grpc/shared/grpc.go b/examples/grpc/shared/grpc.go index c6210431..5846bdf4 100644 --- a/examples/grpc/shared/grpc.go +++ b/examples/grpc/shared/grpc.go @@ -33,7 +33,6 @@ func (m *GRPCClient) Get(key string) ([]byte, error) { // Here is the gRPC server that GRPCClient talks to. type GRPCServer struct { - proto.UnimplementedKVServer // This is the real implementation Impl KV } diff --git a/grpc_broker.go b/grpc_broker.go index 60bbb0a4..b86561a0 100644 --- a/grpc_broker.go +++ b/grpc_broker.go @@ -40,8 +40,6 @@ type sendErr struct { // connection information to/from the plugin. Implements GRPCBrokerServer and // streamer interfaces. type gRPCBrokerServer struct { - plugin.UnimplementedGRPCBrokerServer - // send is used to send connection info to the gRPC stream. send chan *sendErr diff --git a/grpc_controller.go b/grpc_controller.go index a5ff2c6d..2085356c 100644 --- a/grpc_controller.go +++ b/grpc_controller.go @@ -12,7 +12,6 @@ import ( // GRPCControllerServer handles shutdown calls to terminate the server when the // plugin client is closed. type grpcControllerServer struct { - plugin.UnimplementedGRPCControllerServer server *GRPCServer } diff --git a/grpc_stdio.go b/grpc_stdio.go index 190b73ca..ae06c116 100644 --- a/grpc_stdio.go +++ b/grpc_stdio.go @@ -24,7 +24,6 @@ const grpcStdioBuffer = 1 * 1024 // grpcStdioServer implements the Stdio service and streams stdiout/stderr. type grpcStdioServer struct { - plugin.UnimplementedGRPCStdioServer stdoutCh <-chan []byte stderrCh <-chan []byte } diff --git a/plugin_test.go b/plugin_test.go index 21b8b179..45fdf23c 100644 --- a/plugin_test.go +++ b/plugin_test.go @@ -207,7 +207,6 @@ var testGRPCPluginMap = map[string]Plugin{ // testGRPCServer is the implementation of our GRPC service. type testGRPCServer struct { - grpctest.UnimplementedTestServer Impl testInterface broker *GRPCBroker } @@ -274,9 +273,7 @@ func (s *testGRPCServer) PrintStdio( return &empty.Empty{}, nil } -type pingPongServer struct { - grpctest.UnimplementedPingPongServer -} +type pingPongServer struct{} func (p *pingPongServer) Ping(ctx context.Context, req *grpctest.PingRequest) (*grpctest.PongResponse, error) { return &grpctest.PongResponse{ From 4853f396fff1fc7e250eb507f91bb85cc664c4c3 Mon Sep 17 00:00:00 2001 From: Tom Proctor Date: Thu, 12 Oct 2023 17:35:39 +0100 Subject: [PATCH 5/6] Don't require embedded unimplemented structs --- buf.gen.yaml | 2 +- examples/bidirectional/buf.gen.yaml | 2 +- examples/bidirectional/proto/kv_grpc.pb.go | 12 ++++-------- examples/grpc/buf.gen.yaml | 1 + examples/grpc/proto/kv_grpc.pb.go | 6 ++---- internal/plugin/grpc_broker_grpc.pb.go | 6 ++---- internal/plugin/grpc_controller_grpc.pb.go | 6 ++---- internal/plugin/grpc_stdio_grpc.pb.go | 6 ++---- test/grpc/test_grpc.pb.go | 12 ++++-------- 9 files changed, 19 insertions(+), 34 deletions(-) diff --git a/buf.gen.yaml b/buf.gen.yaml index 26c7d7ea..397a398d 100644 --- a/buf.gen.yaml +++ b/buf.gen.yaml @@ -11,4 +11,4 @@ plugins: out: . opt: - paths=source_relative - + - require_unimplemented_servers=false diff --git a/examples/bidirectional/buf.gen.yaml b/examples/bidirectional/buf.gen.yaml index 26c7d7ea..397a398d 100644 --- a/examples/bidirectional/buf.gen.yaml +++ b/examples/bidirectional/buf.gen.yaml @@ -11,4 +11,4 @@ plugins: out: . opt: - paths=source_relative - + - require_unimplemented_servers=false diff --git a/examples/bidirectional/proto/kv_grpc.pb.go b/examples/bidirectional/proto/kv_grpc.pb.go index 186fec2c..0ecf898b 100644 --- a/examples/bidirectional/proto/kv_grpc.pb.go +++ b/examples/bidirectional/proto/kv_grpc.pb.go @@ -49,15 +49,14 @@ func (c *counterClient) Put(ctx context.Context, in *PutRequest, opts ...grpc.Ca } // CounterServer is the server API for Counter service. -// All implementations must embed UnimplementedCounterServer +// All implementations should embed UnimplementedCounterServer // for forward compatibility type CounterServer interface { Get(context.Context, *GetRequest) (*GetResponse, error) Put(context.Context, *PutRequest) (*Empty, error) - mustEmbedUnimplementedCounterServer() } -// UnimplementedCounterServer must be embedded to have forward compatible implementations. +// UnimplementedCounterServer should be embedded to have forward compatible implementations. type UnimplementedCounterServer struct { } @@ -67,7 +66,6 @@ func (UnimplementedCounterServer) Get(context.Context, *GetRequest) (*GetRespons func (UnimplementedCounterServer) Put(context.Context, *PutRequest) (*Empty, error) { return nil, status.Errorf(codes.Unimplemented, "method Put not implemented") } -func (UnimplementedCounterServer) mustEmbedUnimplementedCounterServer() {} // UnsafeCounterServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to CounterServer will @@ -161,21 +159,19 @@ func (c *addHelperClient) Sum(ctx context.Context, in *SumRequest, opts ...grpc. } // AddHelperServer is the server API for AddHelper service. -// All implementations must embed UnimplementedAddHelperServer +// All implementations should embed UnimplementedAddHelperServer // for forward compatibility type AddHelperServer interface { Sum(context.Context, *SumRequest) (*SumResponse, error) - mustEmbedUnimplementedAddHelperServer() } -// UnimplementedAddHelperServer must be embedded to have forward compatible implementations. +// UnimplementedAddHelperServer should be embedded to have forward compatible implementations. type UnimplementedAddHelperServer struct { } func (UnimplementedAddHelperServer) Sum(context.Context, *SumRequest) (*SumResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Sum not implemented") } -func (UnimplementedAddHelperServer) mustEmbedUnimplementedAddHelperServer() {} // UnsafeAddHelperServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to AddHelperServer will diff --git a/examples/grpc/buf.gen.yaml b/examples/grpc/buf.gen.yaml index 8c945272..49eb8db5 100644 --- a/examples/grpc/buf.gen.yaml +++ b/examples/grpc/buf.gen.yaml @@ -11,6 +11,7 @@ plugins: out: . opt: - paths=source_relative + - require_unimplemented_servers=false - plugin: python out: plugin-python - plugin: buf.build/grpc/python:v1.58.1 diff --git a/examples/grpc/proto/kv_grpc.pb.go b/examples/grpc/proto/kv_grpc.pb.go index 9acfb411..1ef314ff 100644 --- a/examples/grpc/proto/kv_grpc.pb.go +++ b/examples/grpc/proto/kv_grpc.pb.go @@ -49,15 +49,14 @@ func (c *kVClient) Put(ctx context.Context, in *PutRequest, opts ...grpc.CallOpt } // KVServer is the server API for KV service. -// All implementations must embed UnimplementedKVServer +// All implementations should embed UnimplementedKVServer // for forward compatibility type KVServer interface { Get(context.Context, *GetRequest) (*GetResponse, error) Put(context.Context, *PutRequest) (*Empty, error) - mustEmbedUnimplementedKVServer() } -// UnimplementedKVServer must be embedded to have forward compatible implementations. +// UnimplementedKVServer should be embedded to have forward compatible implementations. type UnimplementedKVServer struct { } @@ -67,7 +66,6 @@ func (UnimplementedKVServer) Get(context.Context, *GetRequest) (*GetResponse, er func (UnimplementedKVServer) Put(context.Context, *PutRequest) (*Empty, error) { return nil, status.Errorf(codes.Unimplemented, "method Put not implemented") } -func (UnimplementedKVServer) mustEmbedUnimplementedKVServer() {} // UnsafeKVServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to KVServer will diff --git a/internal/plugin/grpc_broker_grpc.pb.go b/internal/plugin/grpc_broker_grpc.pb.go index b31216cf..3a3f1a0d 100644 --- a/internal/plugin/grpc_broker_grpc.pb.go +++ b/internal/plugin/grpc_broker_grpc.pb.go @@ -61,21 +61,19 @@ func (x *gRPCBrokerStartStreamClient) Recv() (*ConnInfo, error) { } // GRPCBrokerServer is the server API for GRPCBroker service. -// All implementations must embed UnimplementedGRPCBrokerServer +// All implementations should embed UnimplementedGRPCBrokerServer // for forward compatibility type GRPCBrokerServer interface { StartStream(GRPCBroker_StartStreamServer) error - mustEmbedUnimplementedGRPCBrokerServer() } -// UnimplementedGRPCBrokerServer must be embedded to have forward compatible implementations. +// UnimplementedGRPCBrokerServer should be embedded to have forward compatible implementations. type UnimplementedGRPCBrokerServer struct { } func (UnimplementedGRPCBrokerServer) StartStream(GRPCBroker_StartStreamServer) error { return status.Errorf(codes.Unimplemented, "method StartStream not implemented") } -func (UnimplementedGRPCBrokerServer) mustEmbedUnimplementedGRPCBrokerServer() {} // UnsafeGRPCBrokerServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to GRPCBrokerServer will diff --git a/internal/plugin/grpc_controller_grpc.pb.go b/internal/plugin/grpc_controller_grpc.pb.go index 510acb49..dc60f6a7 100644 --- a/internal/plugin/grpc_controller_grpc.pb.go +++ b/internal/plugin/grpc_controller_grpc.pb.go @@ -39,21 +39,19 @@ func (c *gRPCControllerClient) Shutdown(ctx context.Context, in *Empty, opts ... } // GRPCControllerServer is the server API for GRPCController service. -// All implementations must embed UnimplementedGRPCControllerServer +// All implementations should embed UnimplementedGRPCControllerServer // for forward compatibility type GRPCControllerServer interface { Shutdown(context.Context, *Empty) (*Empty, error) - mustEmbedUnimplementedGRPCControllerServer() } -// UnimplementedGRPCControllerServer must be embedded to have forward compatible implementations. +// UnimplementedGRPCControllerServer should be embedded to have forward compatible implementations. type UnimplementedGRPCControllerServer struct { } func (UnimplementedGRPCControllerServer) Shutdown(context.Context, *Empty) (*Empty, error) { return nil, status.Errorf(codes.Unimplemented, "method Shutdown not implemented") } -func (UnimplementedGRPCControllerServer) mustEmbedUnimplementedGRPCControllerServer() {} // UnsafeGRPCControllerServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to GRPCControllerServer will diff --git a/internal/plugin/grpc_stdio_grpc.pb.go b/internal/plugin/grpc_stdio_grpc.pb.go index 37ad1e25..248c60aa 100644 --- a/internal/plugin/grpc_stdio_grpc.pb.go +++ b/internal/plugin/grpc_stdio_grpc.pb.go @@ -68,7 +68,7 @@ func (x *gRPCStdioStreamStdioClient) Recv() (*StdioData, error) { } // GRPCStdioServer is the server API for GRPCStdio service. -// All implementations must embed UnimplementedGRPCStdioServer +// All implementations should embed UnimplementedGRPCStdioServer // for forward compatibility type GRPCStdioServer interface { // StreamStdio returns a stream that contains all the stdout/stderr. @@ -77,17 +77,15 @@ type GRPCStdioServer interface { // // Callers should connect early to prevent blocking on the plugin process. StreamStdio(*emptypb.Empty, GRPCStdio_StreamStdioServer) error - mustEmbedUnimplementedGRPCStdioServer() } -// UnimplementedGRPCStdioServer must be embedded to have forward compatible implementations. +// UnimplementedGRPCStdioServer should be embedded to have forward compatible implementations. type UnimplementedGRPCStdioServer struct { } func (UnimplementedGRPCStdioServer) StreamStdio(*emptypb.Empty, GRPCStdio_StreamStdioServer) error { return status.Errorf(codes.Unimplemented, "method StreamStdio not implemented") } -func (UnimplementedGRPCStdioServer) mustEmbedUnimplementedGRPCStdioServer() {} // UnsafeGRPCStdioServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to GRPCStdioServer will diff --git a/test/grpc/test_grpc.pb.go b/test/grpc/test_grpc.pb.go index 57eafbbe..d071cb6e 100644 --- a/test/grpc/test_grpc.pb.go +++ b/test/grpc/test_grpc.pb.go @@ -102,7 +102,7 @@ func (c *testClient) PrintStdio(ctx context.Context, in *PrintStdioRequest, opts } // TestServer is the server API for Test service. -// All implementations must embed UnimplementedTestServer +// All implementations should embed UnimplementedTestServer // for forward compatibility type TestServer interface { Double(context.Context, *TestRequest) (*TestResponse, error) @@ -110,10 +110,9 @@ type TestServer interface { Bidirectional(context.Context, *BidirectionalRequest) (*BidirectionalResponse, error) Stream(Test_StreamServer) error PrintStdio(context.Context, *PrintStdioRequest) (*emptypb.Empty, error) - mustEmbedUnimplementedTestServer() } -// UnimplementedTestServer must be embedded to have forward compatible implementations. +// UnimplementedTestServer should be embedded to have forward compatible implementations. type UnimplementedTestServer struct { } @@ -132,7 +131,6 @@ 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) mustEmbedUnimplementedTestServer() {} // 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 @@ -303,21 +301,19 @@ func (c *pingPongClient) Ping(ctx context.Context, in *PingRequest, opts ...grpc } // PingPongServer is the server API for PingPong service. -// All implementations must embed UnimplementedPingPongServer +// All implementations should embed UnimplementedPingPongServer // for forward compatibility type PingPongServer interface { Ping(context.Context, *PingRequest) (*PongResponse, error) - mustEmbedUnimplementedPingPongServer() } -// UnimplementedPingPongServer must be embedded to have forward compatible implementations. +// UnimplementedPingPongServer should be embedded to have forward compatible implementations. type UnimplementedPingPongServer struct { } func (UnimplementedPingPongServer) Ping(context.Context, *PingRequest) (*PongResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Ping not implemented") } -func (UnimplementedPingPongServer) mustEmbedUnimplementedPingPongServer() {} // UnsafePingPongServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to PingPongServer will From e340950833b5246278c13bfea5bf9fe6e6808259 Mon Sep 17 00:00:00 2001 From: Tom Proctor Date: Thu, 12 Oct 2023 17:41:19 +0100 Subject: [PATCH 6/6] Use BSR for all proto generation plugins --- buf.gen.yaml | 4 +- examples/bidirectional/buf.gen.yaml | 4 +- examples/bidirectional/proto/kv.pb.go | 2 +- examples/bidirectional/proto/kv_grpc.pb.go | 28 +++++++++++--- examples/grpc/buf.gen.yaml | 6 +-- examples/grpc/plugin-python/proto/kv_pb2.py | 32 ++++++++-------- examples/grpc/proto/kv.pb.go | 2 +- examples/grpc/proto/kv_grpc.pb.go | 20 ++++++++-- internal/plugin/grpc_broker.pb.go | 2 +- internal/plugin/grpc_broker_grpc.pb.go | 13 ++++++- internal/plugin/grpc_controller.pb.go | 2 +- internal/plugin/grpc_controller_grpc.pb.go | 15 +++++++- internal/plugin/grpc_stdio.pb.go | 2 +- internal/plugin/grpc_stdio_grpc.pb.go | 13 ++++++- test/grpc/test.pb.go | 2 +- test/grpc/test_grpc.pb.go | 41 +++++++++++++++------ 16 files changed, 134 insertions(+), 54 deletions(-) diff --git a/buf.gen.yaml b/buf.gen.yaml index 397a398d..033d0153 100644 --- a/buf.gen.yaml +++ b/buf.gen.yaml @@ -3,11 +3,11 @@ version: v1 plugins: - - plugin: go + - plugin: buf.build/protocolbuffers/go out: . opt: - paths=source_relative - - plugin: go-grpc + - plugin: buf.build/grpc/go:v1.3.0 out: . opt: - paths=source_relative diff --git a/examples/bidirectional/buf.gen.yaml b/examples/bidirectional/buf.gen.yaml index 397a398d..033d0153 100644 --- a/examples/bidirectional/buf.gen.yaml +++ b/examples/bidirectional/buf.gen.yaml @@ -3,11 +3,11 @@ version: v1 plugins: - - plugin: go + - plugin: buf.build/protocolbuffers/go out: . opt: - paths=source_relative - - plugin: go-grpc + - plugin: buf.build/grpc/go:v1.3.0 out: . opt: - paths=source_relative diff --git a/examples/bidirectional/proto/kv.pb.go b/examples/bidirectional/proto/kv.pb.go index 04951566..3e7fea15 100644 --- a/examples/bidirectional/proto/kv.pb.go +++ b/examples/bidirectional/proto/kv.pb.go @@ -3,7 +3,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 +// protoc-gen-go v1.31.0 // protoc (unknown) // source: proto/kv.proto diff --git a/examples/bidirectional/proto/kv_grpc.pb.go b/examples/bidirectional/proto/kv_grpc.pb.go index 0ecf898b..20f543d7 100644 --- a/examples/bidirectional/proto/kv_grpc.pb.go +++ b/examples/bidirectional/proto/kv_grpc.pb.go @@ -1,4 +1,11 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + // Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.3.0 +// - protoc (unknown) +// source: proto/kv.proto package proto @@ -14,6 +21,11 @@ import ( // Requires gRPC-Go v1.32.0 or later. const _ = grpc.SupportPackageIsVersion7 +const ( + Counter_Get_FullMethodName = "/proto.Counter/Get" + Counter_Put_FullMethodName = "/proto.Counter/Put" +) + // CounterClient is the client API for Counter service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. @@ -32,7 +44,7 @@ func NewCounterClient(cc grpc.ClientConnInterface) CounterClient { func (c *counterClient) Get(ctx context.Context, in *GetRequest, opts ...grpc.CallOption) (*GetResponse, error) { out := new(GetResponse) - err := c.cc.Invoke(ctx, "/proto.Counter/Get", in, out, opts...) + err := c.cc.Invoke(ctx, Counter_Get_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -41,7 +53,7 @@ func (c *counterClient) Get(ctx context.Context, in *GetRequest, opts ...grpc.Ca func (c *counterClient) Put(ctx context.Context, in *PutRequest, opts ...grpc.CallOption) (*Empty, error) { out := new(Empty) - err := c.cc.Invoke(ctx, "/proto.Counter/Put", in, out, opts...) + err := c.cc.Invoke(ctx, Counter_Put_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -88,7 +100,7 @@ func _Counter_Get_Handler(srv interface{}, ctx context.Context, dec func(interfa } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/proto.Counter/Get", + FullMethod: Counter_Get_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(CounterServer).Get(ctx, req.(*GetRequest)) @@ -106,7 +118,7 @@ func _Counter_Put_Handler(srv interface{}, ctx context.Context, dec func(interfa } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/proto.Counter/Put", + FullMethod: Counter_Put_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(CounterServer).Put(ctx, req.(*PutRequest)) @@ -134,6 +146,10 @@ var Counter_ServiceDesc = grpc.ServiceDesc{ Metadata: "proto/kv.proto", } +const ( + AddHelper_Sum_FullMethodName = "/proto.AddHelper/Sum" +) + // AddHelperClient is the client API for AddHelper service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. @@ -151,7 +167,7 @@ func NewAddHelperClient(cc grpc.ClientConnInterface) AddHelperClient { func (c *addHelperClient) Sum(ctx context.Context, in *SumRequest, opts ...grpc.CallOption) (*SumResponse, error) { out := new(SumResponse) - err := c.cc.Invoke(ctx, "/proto.AddHelper/Sum", in, out, opts...) + err := c.cc.Invoke(ctx, AddHelper_Sum_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -194,7 +210,7 @@ func _AddHelper_Sum_Handler(srv interface{}, ctx context.Context, dec func(inter } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/proto.AddHelper/Sum", + FullMethod: AddHelper_Sum_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(AddHelperServer).Sum(ctx, req.(*SumRequest)) diff --git a/examples/grpc/buf.gen.yaml b/examples/grpc/buf.gen.yaml index 49eb8db5..ff84a91a 100644 --- a/examples/grpc/buf.gen.yaml +++ b/examples/grpc/buf.gen.yaml @@ -3,16 +3,16 @@ version: v1 plugins: - - plugin: go + - plugin: buf.build/protocolbuffers/go out: . opt: - paths=source_relative - - plugin: go-grpc + - plugin: buf.build/grpc/go:v1.3.0 out: . opt: - paths=source_relative - require_unimplemented_servers=false - - plugin: python + - plugin: buf.build/protocolbuffers/python:v24.4 out: plugin-python - plugin: buf.build/grpc/python:v1.58.1 out: plugin-python diff --git a/examples/grpc/plugin-python/proto/kv_pb2.py b/examples/grpc/plugin-python/proto/kv_pb2.py index c44c5b8e..903d0948 100644 --- a/examples/grpc/plugin-python/proto/kv_pb2.py +++ b/examples/grpc/plugin-python/proto/kv_pb2.py @@ -2,10 +2,10 @@ # Generated by the protocol buffer compiler. DO NOT EDIT! # source: proto/kv.proto """Generated protocol buffer code.""" -from google.protobuf.internal import builder as _builder from google.protobuf import descriptor as _descriptor from google.protobuf import descriptor_pool as _descriptor_pool from google.protobuf import symbol_database as _symbol_database +from google.protobuf.internal import builder as _builder # @@protoc_insertion_point(imports) _sym_db = _symbol_database.Default() @@ -15,20 +15,20 @@ DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0eproto/kv.proto\x12\x05proto\"\x1e\n\nGetRequest\x12\x10\n\x03key\x18\x01 \x01(\tR\x03key\"#\n\x0bGetResponse\x12\x14\n\x05value\x18\x01 \x01(\x0cR\x05value\"4\n\nPutRequest\x12\x10\n\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n\x05value\x18\x02 \x01(\x0cR\x05value\"\x07\n\x05\x45mpty2Z\n\x02KV\x12,\n\x03Get\x12\x11.proto.GetRequest\x1a\x12.proto.GetResponse\x12&\n\x03Put\x12\x11.proto.PutRequest\x1a\x0c.proto.EmptyB\tZ\x07./protob\x06proto3') -_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) -_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'proto.kv_pb2', globals()) +_globals = globals() +_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) +_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'proto.kv_pb2', _globals) if _descriptor._USE_C_DESCRIPTORS == False: - - DESCRIPTOR._options = None - DESCRIPTOR._serialized_options = b'Z\007./proto' - _GETREQUEST._serialized_start=25 - _GETREQUEST._serialized_end=55 - _GETRESPONSE._serialized_start=57 - _GETRESPONSE._serialized_end=92 - _PUTREQUEST._serialized_start=94 - _PUTREQUEST._serialized_end=146 - _EMPTY._serialized_start=148 - _EMPTY._serialized_end=155 - _KV._serialized_start=157 - _KV._serialized_end=247 + _globals['DESCRIPTOR']._options = None + _globals['DESCRIPTOR']._serialized_options = b'Z\007./proto' + _globals['_GETREQUEST']._serialized_start=25 + _globals['_GETREQUEST']._serialized_end=55 + _globals['_GETRESPONSE']._serialized_start=57 + _globals['_GETRESPONSE']._serialized_end=92 + _globals['_PUTREQUEST']._serialized_start=94 + _globals['_PUTREQUEST']._serialized_end=146 + _globals['_EMPTY']._serialized_start=148 + _globals['_EMPTY']._serialized_end=155 + _globals['_KV']._serialized_start=157 + _globals['_KV']._serialized_end=247 # @@protoc_insertion_point(module_scope) diff --git a/examples/grpc/proto/kv.pb.go b/examples/grpc/proto/kv.pb.go index 1c805482..21979f57 100644 --- a/examples/grpc/proto/kv.pb.go +++ b/examples/grpc/proto/kv.pb.go @@ -3,7 +3,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 +// protoc-gen-go v1.31.0 // protoc (unknown) // source: proto/kv.proto diff --git a/examples/grpc/proto/kv_grpc.pb.go b/examples/grpc/proto/kv_grpc.pb.go index 1ef314ff..f0c007a7 100644 --- a/examples/grpc/proto/kv_grpc.pb.go +++ b/examples/grpc/proto/kv_grpc.pb.go @@ -1,4 +1,11 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + // Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.3.0 +// - protoc (unknown) +// source: proto/kv.proto package proto @@ -14,6 +21,11 @@ import ( // Requires gRPC-Go v1.32.0 or later. const _ = grpc.SupportPackageIsVersion7 +const ( + KV_Get_FullMethodName = "/proto.KV/Get" + KV_Put_FullMethodName = "/proto.KV/Put" +) + // KVClient is the client API for KV service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. @@ -32,7 +44,7 @@ func NewKVClient(cc grpc.ClientConnInterface) KVClient { func (c *kVClient) Get(ctx context.Context, in *GetRequest, opts ...grpc.CallOption) (*GetResponse, error) { out := new(GetResponse) - err := c.cc.Invoke(ctx, "/proto.KV/Get", in, out, opts...) + err := c.cc.Invoke(ctx, KV_Get_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -41,7 +53,7 @@ func (c *kVClient) Get(ctx context.Context, in *GetRequest, opts ...grpc.CallOpt func (c *kVClient) Put(ctx context.Context, in *PutRequest, opts ...grpc.CallOption) (*Empty, error) { out := new(Empty) - err := c.cc.Invoke(ctx, "/proto.KV/Put", in, out, opts...) + err := c.cc.Invoke(ctx, KV_Put_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -88,7 +100,7 @@ func _KV_Get_Handler(srv interface{}, ctx context.Context, dec func(interface{}) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/proto.KV/Get", + FullMethod: KV_Get_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(KVServer).Get(ctx, req.(*GetRequest)) @@ -106,7 +118,7 @@ func _KV_Put_Handler(srv interface{}, ctx context.Context, dec func(interface{}) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/proto.KV/Put", + FullMethod: KV_Put_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(KVServer).Put(ctx, req.(*PutRequest)) diff --git a/internal/plugin/grpc_broker.pb.go b/internal/plugin/grpc_broker.pb.go index 54e8b3f0..0514012d 100644 --- a/internal/plugin/grpc_broker.pb.go +++ b/internal/plugin/grpc_broker.pb.go @@ -3,7 +3,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 +// protoc-gen-go v1.31.0 // protoc (unknown) // source: internal/plugin/grpc_broker.proto diff --git a/internal/plugin/grpc_broker_grpc.pb.go b/internal/plugin/grpc_broker_grpc.pb.go index 3a3f1a0d..1b0f8070 100644 --- a/internal/plugin/grpc_broker_grpc.pb.go +++ b/internal/plugin/grpc_broker_grpc.pb.go @@ -1,4 +1,11 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + // Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.3.0 +// - protoc (unknown) +// source: internal/plugin/grpc_broker.proto package plugin @@ -14,6 +21,10 @@ import ( // Requires gRPC-Go v1.32.0 or later. const _ = grpc.SupportPackageIsVersion7 +const ( + GRPCBroker_StartStream_FullMethodName = "/plugin.GRPCBroker/StartStream" +) + // GRPCBrokerClient is the client API for GRPCBroker service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. @@ -30,7 +41,7 @@ func NewGRPCBrokerClient(cc grpc.ClientConnInterface) GRPCBrokerClient { } func (c *gRPCBrokerClient) StartStream(ctx context.Context, opts ...grpc.CallOption) (GRPCBroker_StartStreamClient, error) { - stream, err := c.cc.NewStream(ctx, &GRPCBroker_ServiceDesc.Streams[0], "/plugin.GRPCBroker/StartStream", opts...) + stream, err := c.cc.NewStream(ctx, &GRPCBroker_ServiceDesc.Streams[0], GRPCBroker_StartStream_FullMethodName, opts...) if err != nil { return nil, err } diff --git a/internal/plugin/grpc_controller.pb.go b/internal/plugin/grpc_controller.pb.go index 2530a32e..8ca48e0d 100644 --- a/internal/plugin/grpc_controller.pb.go +++ b/internal/plugin/grpc_controller.pb.go @@ -3,7 +3,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 +// protoc-gen-go v1.31.0 // protoc (unknown) // source: internal/plugin/grpc_controller.proto diff --git a/internal/plugin/grpc_controller_grpc.pb.go b/internal/plugin/grpc_controller_grpc.pb.go index dc60f6a7..427611aa 100644 --- a/internal/plugin/grpc_controller_grpc.pb.go +++ b/internal/plugin/grpc_controller_grpc.pb.go @@ -1,4 +1,11 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + // Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.3.0 +// - protoc (unknown) +// source: internal/plugin/grpc_controller.proto package plugin @@ -14,6 +21,10 @@ import ( // Requires gRPC-Go v1.32.0 or later. const _ = grpc.SupportPackageIsVersion7 +const ( + GRPCController_Shutdown_FullMethodName = "/plugin.GRPCController/Shutdown" +) + // GRPCControllerClient is the client API for GRPCController service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. @@ -31,7 +42,7 @@ func NewGRPCControllerClient(cc grpc.ClientConnInterface) GRPCControllerClient { func (c *gRPCControllerClient) Shutdown(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*Empty, error) { out := new(Empty) - err := c.cc.Invoke(ctx, "/plugin.GRPCController/Shutdown", in, out, opts...) + err := c.cc.Invoke(ctx, GRPCController_Shutdown_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -74,7 +85,7 @@ func _GRPCController_Shutdown_Handler(srv interface{}, ctx context.Context, dec } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/plugin.GRPCController/Shutdown", + FullMethod: GRPCController_Shutdown_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(GRPCControllerServer).Shutdown(ctx, req.(*Empty)) diff --git a/internal/plugin/grpc_stdio.pb.go b/internal/plugin/grpc_stdio.pb.go index a4ed0525..139cbb4a 100644 --- a/internal/plugin/grpc_stdio.pb.go +++ b/internal/plugin/grpc_stdio.pb.go @@ -3,7 +3,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 +// protoc-gen-go v1.31.0 // protoc (unknown) // source: internal/plugin/grpc_stdio.proto diff --git a/internal/plugin/grpc_stdio_grpc.pb.go b/internal/plugin/grpc_stdio_grpc.pb.go index 248c60aa..f82b1503 100644 --- a/internal/plugin/grpc_stdio_grpc.pb.go +++ b/internal/plugin/grpc_stdio_grpc.pb.go @@ -1,4 +1,11 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + // Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.3.0 +// - protoc (unknown) +// source: internal/plugin/grpc_stdio.proto package plugin @@ -15,6 +22,10 @@ import ( // Requires gRPC-Go v1.32.0 or later. const _ = grpc.SupportPackageIsVersion7 +const ( + GRPCStdio_StreamStdio_FullMethodName = "/plugin.GRPCStdio/StreamStdio" +) + // GRPCStdioClient is the client API for GRPCStdio service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. @@ -36,7 +47,7 @@ func NewGRPCStdioClient(cc grpc.ClientConnInterface) GRPCStdioClient { } func (c *gRPCStdioClient) StreamStdio(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (GRPCStdio_StreamStdioClient, error) { - stream, err := c.cc.NewStream(ctx, &GRPCStdio_ServiceDesc.Streams[0], "/plugin.GRPCStdio/StreamStdio", opts...) + stream, err := c.cc.NewStream(ctx, &GRPCStdio_ServiceDesc.Streams[0], GRPCStdio_StreamStdio_FullMethodName, opts...) if err != nil { return nil, err } diff --git a/test/grpc/test.pb.go b/test/grpc/test.pb.go index 53c31956..4c740e34 100644 --- a/test/grpc/test.pb.go +++ b/test/grpc/test.pb.go @@ -3,7 +3,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 +// protoc-gen-go v1.31.0 // protoc (unknown) // source: test/grpc/test.proto diff --git a/test/grpc/test_grpc.pb.go b/test/grpc/test_grpc.pb.go index d071cb6e..bd9ecca7 100644 --- a/test/grpc/test_grpc.pb.go +++ b/test/grpc/test_grpc.pb.go @@ -1,4 +1,11 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + // Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.3.0 +// - protoc (unknown) +// source: test/grpc/test.proto package grpctest @@ -15,6 +22,14 @@ import ( // Requires gRPC-Go v1.32.0 or later. const _ = grpc.SupportPackageIsVersion7 +const ( + Test_Double_FullMethodName = "/grpctest.Test/Double" + Test_PrintKV_FullMethodName = "/grpctest.Test/PrintKV" + Test_Bidirectional_FullMethodName = "/grpctest.Test/Bidirectional" + Test_Stream_FullMethodName = "/grpctest.Test/Stream" + Test_PrintStdio_FullMethodName = "/grpctest.Test/PrintStdio" +) + // TestClient is the client API for Test service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. @@ -36,7 +51,7 @@ func NewTestClient(cc grpc.ClientConnInterface) TestClient { func (c *testClient) Double(ctx context.Context, in *TestRequest, opts ...grpc.CallOption) (*TestResponse, error) { out := new(TestResponse) - err := c.cc.Invoke(ctx, "/grpctest.Test/Double", in, out, opts...) + err := c.cc.Invoke(ctx, Test_Double_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -45,7 +60,7 @@ func (c *testClient) Double(ctx context.Context, in *TestRequest, opts ...grpc.C func (c *testClient) PrintKV(ctx context.Context, in *PrintKVRequest, opts ...grpc.CallOption) (*PrintKVResponse, error) { out := new(PrintKVResponse) - err := c.cc.Invoke(ctx, "/grpctest.Test/PrintKV", in, out, opts...) + err := c.cc.Invoke(ctx, Test_PrintKV_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -54,7 +69,7 @@ func (c *testClient) PrintKV(ctx context.Context, in *PrintKVRequest, opts ...gr func (c *testClient) Bidirectional(ctx context.Context, in *BidirectionalRequest, opts ...grpc.CallOption) (*BidirectionalResponse, error) { out := new(BidirectionalResponse) - err := c.cc.Invoke(ctx, "/grpctest.Test/Bidirectional", in, out, opts...) + err := c.cc.Invoke(ctx, Test_Bidirectional_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -62,7 +77,7 @@ func (c *testClient) Bidirectional(ctx context.Context, in *BidirectionalRequest } func (c *testClient) Stream(ctx context.Context, opts ...grpc.CallOption) (Test_StreamClient, error) { - stream, err := c.cc.NewStream(ctx, &Test_ServiceDesc.Streams[0], "/grpctest.Test/Stream", opts...) + stream, err := c.cc.NewStream(ctx, &Test_ServiceDesc.Streams[0], Test_Stream_FullMethodName, opts...) if err != nil { return nil, err } @@ -94,7 +109,7 @@ func (x *testStreamClient) Recv() (*TestResponse, error) { func (c *testClient) PrintStdio(ctx context.Context, in *PrintStdioRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) { out := new(emptypb.Empty) - err := c.cc.Invoke(ctx, "/grpctest.Test/PrintStdio", in, out, opts...) + err := c.cc.Invoke(ctx, Test_PrintStdio_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -153,7 +168,7 @@ func _Test_Double_Handler(srv interface{}, ctx context.Context, dec func(interfa } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/grpctest.Test/Double", + FullMethod: Test_Double_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(TestServer).Double(ctx, req.(*TestRequest)) @@ -171,7 +186,7 @@ func _Test_PrintKV_Handler(srv interface{}, ctx context.Context, dec func(interf } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/grpctest.Test/PrintKV", + FullMethod: Test_PrintKV_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(TestServer).PrintKV(ctx, req.(*PrintKVRequest)) @@ -189,7 +204,7 @@ func _Test_Bidirectional_Handler(srv interface{}, ctx context.Context, dec func( } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/grpctest.Test/Bidirectional", + FullMethod: Test_Bidirectional_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(TestServer).Bidirectional(ctx, req.(*BidirectionalRequest)) @@ -233,7 +248,7 @@ func _Test_PrintStdio_Handler(srv interface{}, ctx context.Context, dec func(int } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/grpctest.Test/PrintStdio", + FullMethod: Test_PrintStdio_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(TestServer).PrintStdio(ctx, req.(*PrintStdioRequest)) @@ -276,6 +291,10 @@ var Test_ServiceDesc = grpc.ServiceDesc{ Metadata: "test/grpc/test.proto", } +const ( + PingPong_Ping_FullMethodName = "/grpctest.PingPong/Ping" +) + // PingPongClient is the client API for PingPong service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. @@ -293,7 +312,7 @@ func NewPingPongClient(cc grpc.ClientConnInterface) PingPongClient { func (c *pingPongClient) Ping(ctx context.Context, in *PingRequest, opts ...grpc.CallOption) (*PongResponse, error) { out := new(PongResponse) - err := c.cc.Invoke(ctx, "/grpctest.PingPong/Ping", in, out, opts...) + err := c.cc.Invoke(ctx, PingPong_Ping_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -336,7 +355,7 @@ func _PingPong_Ping_Handler(srv interface{}, ctx context.Context, dec func(inter } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/grpctest.PingPong/Ping", + FullMethod: PingPong_Ping_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(PingPongServer).Ping(ctx, req.(*PingRequest))