cmd/protoc-gen-go-grpc: add change detector test (#7072)

This commit is contained in:
Arvind Bright 2024-04-05 16:39:23 -07:00 committed by GitHub
parent eb4e411540
commit 6fbcd8a889
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 669 additions and 2 deletions

View File

@ -123,3 +123,6 @@ jobs:
interop/interop_test.sh
echo -e "\n-- Running xDS E2E Test --"
xds/internal/test/e2e/run.sh
echo -e "\n-- Running protoc-gen-go-grpc test --"
./scripts/vet-proto.sh -install
cmd/protoc-gen-go-grpc/protoc-gen-go-grpc_test.sh

View File

@ -13,7 +13,7 @@ change from the grpc code generator previously included with `protoc-gen-go`.
To restore this behavior, set the option `require_unimplemented_servers=false`.
E.g.:
```
```sh
protoc --go-grpc_out=. --go-grpc_opt=require_unimplemented_servers=false[,other options...] \
```

View File

@ -0,0 +1,48 @@
#!/bin/bash -e
# Copyright 2024 gRPC authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Uncomment to enable debugging.
# set -x
WORKDIR="$(dirname $0)"
TEMPDIR=$(mktemp -d)
trap "rm -rf ${TEMPDIR}" EXIT
# Build protoc-gen-go-grpc binary and add to $PATH.
pushd "${WORKDIR}"
go build -o "${TEMPDIR}" .
PATH="${TEMPDIR}:${PATH}"
popd
protoc \
--go-grpc_out="${TEMPDIR}" \
--go-grpc_opt=paths=source_relative \
"$WORKDIR/testdata/golden.proto"
GOLDENFILE="${WORKDIR}/testdata/golden_grpc.pb.go"
GENFILE="${TEMPDIR}/cmd/protoc-gen-go-grpc/testdata/golden_grpc.pb.go"
DIFF=$(diff "${GOLDENFILE}" "${GENFILE}")
if [[ -n "${DIFF}" ]]; then
echo -e "ERROR: Generated file golden_grpc.pb.go differs from golden file:\n${DIFF}"
echo -e "If you have made recent changes to protoc-gen-go-grpc," \
"please regenerate the golden files by running:" \
"\n\t go generate google.golang.org/grpc/..." >&2
exit 1
fi
echo SUCCESS

View File

@ -0,0 +1,249 @@
// Copyright 2024 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.33.0
// protoc v4.25.2
// source: cmd/protoc-gen-go-grpc/testdata/golden.proto
package testdata
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type EventRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Content []byte `protobuf:"bytes,1,opt,name=content,proto3" json:"content,omitempty"`
}
func (x *EventRequest) Reset() {
*x = EventRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_cmd_protoc_gen_go_grpc_testdata_golden_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *EventRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*EventRequest) ProtoMessage() {}
func (x *EventRequest) ProtoReflect() protoreflect.Message {
mi := &file_cmd_protoc_gen_go_grpc_testdata_golden_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 EventRequest.ProtoReflect.Descriptor instead.
func (*EventRequest) Descriptor() ([]byte, []int) {
return file_cmd_protoc_gen_go_grpc_testdata_golden_proto_rawDescGZIP(), []int{0}
}
func (x *EventRequest) GetContent() []byte {
if x != nil {
return x.Content
}
return nil
}
type EventResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Content []byte `protobuf:"bytes,1,opt,name=content,proto3" json:"content,omitempty"`
}
func (x *EventResponse) Reset() {
*x = EventResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_cmd_protoc_gen_go_grpc_testdata_golden_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *EventResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*EventResponse) ProtoMessage() {}
func (x *EventResponse) ProtoReflect() protoreflect.Message {
mi := &file_cmd_protoc_gen_go_grpc_testdata_golden_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use EventResponse.ProtoReflect.Descriptor instead.
func (*EventResponse) Descriptor() ([]byte, []int) {
return file_cmd_protoc_gen_go_grpc_testdata_golden_proto_rawDescGZIP(), []int{1}
}
func (x *EventResponse) GetContent() []byte {
if x != nil {
return x.Content
}
return nil
}
var File_cmd_protoc_gen_go_grpc_testdata_golden_proto protoreflect.FileDescriptor
var file_cmd_protoc_gen_go_grpc_testdata_golden_proto_rawDesc = []byte{
0x0a, 0x2c, 0x63, 0x6d, 0x64, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x2d, 0x67, 0x65, 0x6e,
0x2d, 0x67, 0x6f, 0x2d, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x64, 0x61, 0x74,
0x61, 0x2f, 0x67, 0x6f, 0x6c, 0x64, 0x65, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x04,
0x6d, 0x61, 0x69, 0x6e, 0x22, 0x28, 0x0a, 0x0c, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71,
0x75, 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18,
0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x22, 0x29,
0x0a, 0x0d, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12,
0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c,
0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x32, 0x99, 0x02, 0x0a, 0x1d, 0x42, 0x69,
0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x53, 0x74, 0x72, 0x65, 0x61,
0x6d, 0x69, 0x6e, 0x67, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x38, 0x0a, 0x0b, 0x75,
0x6e, 0x61, 0x72, 0x79, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x12, 0x2e, 0x6d, 0x61, 0x69,
0x6e, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13,
0x2e, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f,
0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3b, 0x0a, 0x0c, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x4d,
0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x12, 0x2e, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x45, 0x76, 0x65,
0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x6d, 0x61, 0x69, 0x6e,
0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00,
0x28, 0x01, 0x12, 0x3b, 0x0a, 0x0c, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x4d, 0x65, 0x74, 0x68,
0x6f, 0x64, 0x12, 0x12, 0x2e, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52,
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x45, 0x76,
0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x30, 0x01, 0x12,
0x44, 0x0a, 0x13, 0x62, 0x69, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c,
0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x12, 0x2e, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x45, 0x76,
0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x6d, 0x61, 0x69,
0x6e, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22,
0x00, 0x28, 0x01, 0x30, 0x01, 0x42, 0x38, 0x5a, 0x36, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e,
0x67, 0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f,
0x63, 0x6d, 0x64, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x2d, 0x67, 0x65, 0x6e, 0x2d, 0x67,
0x6f, 0x2d, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x64, 0x61, 0x74, 0x61, 0x62,
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_cmd_protoc_gen_go_grpc_testdata_golden_proto_rawDescOnce sync.Once
file_cmd_protoc_gen_go_grpc_testdata_golden_proto_rawDescData = file_cmd_protoc_gen_go_grpc_testdata_golden_proto_rawDesc
)
func file_cmd_protoc_gen_go_grpc_testdata_golden_proto_rawDescGZIP() []byte {
file_cmd_protoc_gen_go_grpc_testdata_golden_proto_rawDescOnce.Do(func() {
file_cmd_protoc_gen_go_grpc_testdata_golden_proto_rawDescData = protoimpl.X.CompressGZIP(file_cmd_protoc_gen_go_grpc_testdata_golden_proto_rawDescData)
})
return file_cmd_protoc_gen_go_grpc_testdata_golden_proto_rawDescData
}
var file_cmd_protoc_gen_go_grpc_testdata_golden_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
var file_cmd_protoc_gen_go_grpc_testdata_golden_proto_goTypes = []interface{}{
(*EventRequest)(nil), // 0: main.EventRequest
(*EventResponse)(nil), // 1: main.EventResponse
}
var file_cmd_protoc_gen_go_grpc_testdata_golden_proto_depIdxs = []int32{
0, // 0: main.BidirectionalStreamingService.unaryMethod:input_type -> main.EventRequest
0, // 1: main.BidirectionalStreamingService.clientMethod:input_type -> main.EventRequest
0, // 2: main.BidirectionalStreamingService.serverMethod:input_type -> main.EventRequest
0, // 3: main.BidirectionalStreamingService.bidirectionalMethod:input_type -> main.EventRequest
1, // 4: main.BidirectionalStreamingService.unaryMethod:output_type -> main.EventResponse
1, // 5: main.BidirectionalStreamingService.clientMethod:output_type -> main.EventResponse
1, // 6: main.BidirectionalStreamingService.serverMethod:output_type -> main.EventResponse
1, // 7: main.BidirectionalStreamingService.bidirectionalMethod:output_type -> main.EventResponse
4, // [4:8] is the sub-list for method output_type
0, // [0:4] 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_cmd_protoc_gen_go_grpc_testdata_golden_proto_init() }
func file_cmd_protoc_gen_go_grpc_testdata_golden_proto_init() {
if File_cmd_protoc_gen_go_grpc_testdata_golden_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_cmd_protoc_gen_go_grpc_testdata_golden_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*EventRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_cmd_protoc_gen_go_grpc_testdata_golden_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*EventResponse); 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_cmd_protoc_gen_go_grpc_testdata_golden_proto_rawDesc,
NumEnums: 0,
NumMessages: 2,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_cmd_protoc_gen_go_grpc_testdata_golden_proto_goTypes,
DependencyIndexes: file_cmd_protoc_gen_go_grpc_testdata_golden_proto_depIdxs,
MessageInfos: file_cmd_protoc_gen_go_grpc_testdata_golden_proto_msgTypes,
}.Build()
File_cmd_protoc_gen_go_grpc_testdata_golden_proto = out.File
file_cmd_protoc_gen_go_grpc_testdata_golden_proto_rawDesc = nil
file_cmd_protoc_gen_go_grpc_testdata_golden_proto_goTypes = nil
file_cmd_protoc_gen_go_grpc_testdata_golden_proto_depIdxs = nil
}

View File

@ -0,0 +1,34 @@
// Copyright 2024 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
syntax = "proto3";
option go_package = "google.golang.org/grpc/cmd/protoc-gen-go-grpc/testdata";
package main;
message EventRequest {
bytes content = 1;
}
message EventResponse {
bytes content = 1;
}
service BidirectionalStreamingService {
rpc unaryMethod(EventRequest) returns (EventResponse) {}
rpc clientMethod(stream EventRequest) returns (EventResponse) {}
rpc serverMethod(EventRequest) returns (stream EventResponse) {}
rpc bidirectionalMethod(stream EventRequest) returns (stream EventResponse) {}
}

View File

@ -0,0 +1,333 @@
// Copyright 2024 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.3.0
// - protoc v4.25.2
// source: cmd/protoc-gen-go-grpc/testdata/golden.proto
package testdata
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.62.0 or later.
const _ = grpc.SupportPackageIsVersion8
const (
BidirectionalStreamingService_UnaryMethod_FullMethodName = "/main.BidirectionalStreamingService/unaryMethod"
BidirectionalStreamingService_ClientMethod_FullMethodName = "/main.BidirectionalStreamingService/clientMethod"
BidirectionalStreamingService_ServerMethod_FullMethodName = "/main.BidirectionalStreamingService/serverMethod"
BidirectionalStreamingService_BidirectionalMethod_FullMethodName = "/main.BidirectionalStreamingService/bidirectionalMethod"
)
// BidirectionalStreamingServiceClient is the client API for BidirectionalStreamingService 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 BidirectionalStreamingServiceClient interface {
UnaryMethod(ctx context.Context, in *EventRequest, opts ...grpc.CallOption) (*EventResponse, error)
ClientMethod(ctx context.Context, opts ...grpc.CallOption) (BidirectionalStreamingService_ClientMethodClient, error)
ServerMethod(ctx context.Context, in *EventRequest, opts ...grpc.CallOption) (BidirectionalStreamingService_ServerMethodClient, error)
BidirectionalMethod(ctx context.Context, opts ...grpc.CallOption) (BidirectionalStreamingService_BidirectionalMethodClient, error)
}
type bidirectionalStreamingServiceClient struct {
cc grpc.ClientConnInterface
}
func NewBidirectionalStreamingServiceClient(cc grpc.ClientConnInterface) BidirectionalStreamingServiceClient {
return &bidirectionalStreamingServiceClient{cc}
}
func (c *bidirectionalStreamingServiceClient) UnaryMethod(ctx context.Context, in *EventRequest, opts ...grpc.CallOption) (*EventResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(EventResponse)
err := c.cc.Invoke(ctx, BidirectionalStreamingService_UnaryMethod_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *bidirectionalStreamingServiceClient) ClientMethod(ctx context.Context, opts ...grpc.CallOption) (BidirectionalStreamingService_ClientMethodClient, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
stream, err := c.cc.NewStream(ctx, &BidirectionalStreamingService_ServiceDesc.Streams[0], BidirectionalStreamingService_ClientMethod_FullMethodName, cOpts...)
if err != nil {
return nil, err
}
x := &bidirectionalStreamingServiceClientMethodClient{stream}
return x, nil
}
type BidirectionalStreamingService_ClientMethodClient interface {
Send(*EventRequest) error
CloseAndRecv() (*EventResponse, error)
grpc.ClientStream
}
type bidirectionalStreamingServiceClientMethodClient struct {
grpc.ClientStream
}
func (x *bidirectionalStreamingServiceClientMethodClient) Send(m *EventRequest) error {
return x.ClientStream.SendMsg(m)
}
func (x *bidirectionalStreamingServiceClientMethodClient) CloseAndRecv() (*EventResponse, error) {
if err := x.ClientStream.CloseSend(); err != nil {
return nil, err
}
m := new(EventResponse)
if err := x.ClientStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
func (c *bidirectionalStreamingServiceClient) ServerMethod(ctx context.Context, in *EventRequest, opts ...grpc.CallOption) (BidirectionalStreamingService_ServerMethodClient, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
stream, err := c.cc.NewStream(ctx, &BidirectionalStreamingService_ServiceDesc.Streams[1], BidirectionalStreamingService_ServerMethod_FullMethodName, cOpts...)
if err != nil {
return nil, err
}
x := &bidirectionalStreamingServiceServerMethodClient{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 BidirectionalStreamingService_ServerMethodClient interface {
Recv() (*EventResponse, error)
grpc.ClientStream
}
type bidirectionalStreamingServiceServerMethodClient struct {
grpc.ClientStream
}
func (x *bidirectionalStreamingServiceServerMethodClient) Recv() (*EventResponse, error) {
m := new(EventResponse)
if err := x.ClientStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
func (c *bidirectionalStreamingServiceClient) BidirectionalMethod(ctx context.Context, opts ...grpc.CallOption) (BidirectionalStreamingService_BidirectionalMethodClient, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
stream, err := c.cc.NewStream(ctx, &BidirectionalStreamingService_ServiceDesc.Streams[2], BidirectionalStreamingService_BidirectionalMethod_FullMethodName, cOpts...)
if err != nil {
return nil, err
}
x := &bidirectionalStreamingServiceBidirectionalMethodClient{stream}
return x, nil
}
type BidirectionalStreamingService_BidirectionalMethodClient interface {
Send(*EventRequest) error
Recv() (*EventResponse, error)
grpc.ClientStream
}
type bidirectionalStreamingServiceBidirectionalMethodClient struct {
grpc.ClientStream
}
func (x *bidirectionalStreamingServiceBidirectionalMethodClient) Send(m *EventRequest) error {
return x.ClientStream.SendMsg(m)
}
func (x *bidirectionalStreamingServiceBidirectionalMethodClient) Recv() (*EventResponse, error) {
m := new(EventResponse)
if err := x.ClientStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
// BidirectionalStreamingServiceServer is the server API for BidirectionalStreamingService service.
// All implementations must embed UnimplementedBidirectionalStreamingServiceServer
// for forward compatibility
type BidirectionalStreamingServiceServer interface {
UnaryMethod(context.Context, *EventRequest) (*EventResponse, error)
ClientMethod(BidirectionalStreamingService_ClientMethodServer) error
ServerMethod(*EventRequest, BidirectionalStreamingService_ServerMethodServer) error
BidirectionalMethod(BidirectionalStreamingService_BidirectionalMethodServer) error
mustEmbedUnimplementedBidirectionalStreamingServiceServer()
}
// UnimplementedBidirectionalStreamingServiceServer must be embedded to have forward compatible implementations.
type UnimplementedBidirectionalStreamingServiceServer struct {
}
func (UnimplementedBidirectionalStreamingServiceServer) UnaryMethod(context.Context, *EventRequest) (*EventResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method UnaryMethod not implemented")
}
func (UnimplementedBidirectionalStreamingServiceServer) ClientMethod(BidirectionalStreamingService_ClientMethodServer) error {
return status.Errorf(codes.Unimplemented, "method ClientMethod not implemented")
}
func (UnimplementedBidirectionalStreamingServiceServer) ServerMethod(*EventRequest, BidirectionalStreamingService_ServerMethodServer) error {
return status.Errorf(codes.Unimplemented, "method ServerMethod not implemented")
}
func (UnimplementedBidirectionalStreamingServiceServer) BidirectionalMethod(BidirectionalStreamingService_BidirectionalMethodServer) error {
return status.Errorf(codes.Unimplemented, "method BidirectionalMethod not implemented")
}
func (UnimplementedBidirectionalStreamingServiceServer) mustEmbedUnimplementedBidirectionalStreamingServiceServer() {
}
// UnsafeBidirectionalStreamingServiceServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to BidirectionalStreamingServiceServer will
// result in compilation errors.
type UnsafeBidirectionalStreamingServiceServer interface {
mustEmbedUnimplementedBidirectionalStreamingServiceServer()
}
func RegisterBidirectionalStreamingServiceServer(s grpc.ServiceRegistrar, srv BidirectionalStreamingServiceServer) {
s.RegisterService(&BidirectionalStreamingService_ServiceDesc, srv)
}
func _BidirectionalStreamingService_UnaryMethod_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(EventRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(BidirectionalStreamingServiceServer).UnaryMethod(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: BidirectionalStreamingService_UnaryMethod_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(BidirectionalStreamingServiceServer).UnaryMethod(ctx, req.(*EventRequest))
}
return interceptor(ctx, in, info, handler)
}
func _BidirectionalStreamingService_ClientMethod_Handler(srv interface{}, stream grpc.ServerStream) error {
return srv.(BidirectionalStreamingServiceServer).ClientMethod(&bidirectionalStreamingServiceClientMethodServer{stream})
}
type BidirectionalStreamingService_ClientMethodServer interface {
SendAndClose(*EventResponse) error
Recv() (*EventRequest, error)
grpc.ServerStream
}
type bidirectionalStreamingServiceClientMethodServer struct {
grpc.ServerStream
}
func (x *bidirectionalStreamingServiceClientMethodServer) SendAndClose(m *EventResponse) error {
return x.ServerStream.SendMsg(m)
}
func (x *bidirectionalStreamingServiceClientMethodServer) Recv() (*EventRequest, error) {
m := new(EventRequest)
if err := x.ServerStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
func _BidirectionalStreamingService_ServerMethod_Handler(srv interface{}, stream grpc.ServerStream) error {
m := new(EventRequest)
if err := stream.RecvMsg(m); err != nil {
return err
}
return srv.(BidirectionalStreamingServiceServer).ServerMethod(m, &bidirectionalStreamingServiceServerMethodServer{stream})
}
type BidirectionalStreamingService_ServerMethodServer interface {
Send(*EventResponse) error
grpc.ServerStream
}
type bidirectionalStreamingServiceServerMethodServer struct {
grpc.ServerStream
}
func (x *bidirectionalStreamingServiceServerMethodServer) Send(m *EventResponse) error {
return x.ServerStream.SendMsg(m)
}
func _BidirectionalStreamingService_BidirectionalMethod_Handler(srv interface{}, stream grpc.ServerStream) error {
return srv.(BidirectionalStreamingServiceServer).BidirectionalMethod(&bidirectionalStreamingServiceBidirectionalMethodServer{stream})
}
type BidirectionalStreamingService_BidirectionalMethodServer interface {
Send(*EventResponse) error
Recv() (*EventRequest, error)
grpc.ServerStream
}
type bidirectionalStreamingServiceBidirectionalMethodServer struct {
grpc.ServerStream
}
func (x *bidirectionalStreamingServiceBidirectionalMethodServer) Send(m *EventResponse) error {
return x.ServerStream.SendMsg(m)
}
func (x *bidirectionalStreamingServiceBidirectionalMethodServer) Recv() (*EventRequest, error) {
m := new(EventRequest)
if err := x.ServerStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
// BidirectionalStreamingService_ServiceDesc is the grpc.ServiceDesc for BidirectionalStreamingService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var BidirectionalStreamingService_ServiceDesc = grpc.ServiceDesc{
ServiceName: "main.BidirectionalStreamingService",
HandlerType: (*BidirectionalStreamingServiceServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "unaryMethod",
Handler: _BidirectionalStreamingService_UnaryMethod_Handler,
},
},
Streams: []grpc.StreamDesc{
{
StreamName: "clientMethod",
Handler: _BidirectionalStreamingService_ClientMethod_Handler,
ClientStreams: true,
},
{
StreamName: "serverMethod",
Handler: _BidirectionalStreamingService_ServerMethod_Handler,
ServerStreams: true,
},
{
StreamName: "bidirectionalMethod",
Handler: _BidirectionalStreamingService_BidirectionalMethod_Handler,
ServerStreams: true,
ClientStreams: true,
},
},
Metadata: "cmd/protoc-gen-go-grpc/testdata/golden.proto",
}

View File

@ -63,7 +63,7 @@ LEGACY_SOURCES=(
# Generates only the new gRPC Service symbols
SOURCES=(
$(git ls-files --exclude-standard --cached --others "*.proto" | grep -v '^\(profiling/proto/service.proto\|reflection/grpc_reflection_v1alpha/reflection.proto\)$')
$(git ls-files --exclude-standard --cached --others "*.proto" | grep -v '^profiling/proto/service.proto$')
${WORKDIR}/grpc-proto/grpc/gcp/altscontext.proto
${WORKDIR}/grpc-proto/grpc/gcp/handshaker.proto
${WORKDIR}/grpc-proto/grpc/gcp/transport_security_common.proto