From e8a756bddf1a6f4dac923bad92c4dd0389b36e18 Mon Sep 17 00:00:00 2001 From: Oleg Bespalov Date: Wed, 20 Sep 2023 11:23:00 +0200 Subject: [PATCH] Google wrappers support test cases --- js/modules/k6/grpc/client_test.go | 88 ++++++++ .../grpc_wrappers_testing/generate.go | 4 + .../grpc_wrappers_testing/service.go | 58 +++++ .../grpc_wrappers_testing/test.pb.go | 98 ++++++++ .../grpc_wrappers_testing/test.proto | 17 ++ .../grpc_wrappers_testing/test_grpc.pb.go | 210 ++++++++++++++++++ .../protobuf/ptypes/wrappers/wrappers.pb.go | 71 ++++++ vendor/modules.txt | 1 + 8 files changed, 547 insertions(+) create mode 100644 lib/testutils/httpmultibin/grpc_wrappers_testing/generate.go create mode 100644 lib/testutils/httpmultibin/grpc_wrappers_testing/service.go create mode 100644 lib/testutils/httpmultibin/grpc_wrappers_testing/test.pb.go create mode 100644 lib/testutils/httpmultibin/grpc_wrappers_testing/test.proto create mode 100644 lib/testutils/httpmultibin/grpc_wrappers_testing/test_grpc.pb.go create mode 100644 vendor/github.com/golang/protobuf/ptypes/wrappers/wrappers.pb.go diff --git a/js/modules/k6/grpc/client_test.go b/js/modules/k6/grpc/client_test.go index a3c375f3f5ab..0813162bab74 100644 --- a/js/modules/k6/grpc/client_test.go +++ b/js/modules/k6/grpc/client_test.go @@ -17,9 +17,11 @@ import ( "google.golang.org/grpc/reflection" "google.golang.org/protobuf/reflect/protoreflect" "google.golang.org/protobuf/reflect/protoregistry" + "google.golang.org/protobuf/types/known/wrapperspb" "github.com/dop251/goja" "github.com/golang/protobuf/ptypes/any" + "github.com/golang/protobuf/ptypes/wrappers" "github.com/sirupsen/logrus" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -38,6 +40,7 @@ import ( "go.k6.io/k6/lib/testutils/httpmultibin" grpcanytesting "go.k6.io/k6/lib/testutils/httpmultibin/grpc_any_testing" "go.k6.io/k6/lib/testutils/httpmultibin/grpc_testing" + "go.k6.io/k6/lib/testutils/httpmultibin/grpc_wrappers_testing" "go.k6.io/k6/metrics" ) @@ -842,6 +845,91 @@ func TestClient(t *testing.T) { err: "no gRPC connection", }, }, + { + name: "Wrappers", + setup: func(hb *httpmultibin.HTTPMultiBin) { + srv := grpc_wrappers_testing.Register(hb.ServerGRPC) + + srv.TestStringImplementation = func(_ context.Context, sv *wrappers.StringValue) (*wrappers.StringValue, error) { + return &wrapperspb.StringValue{ + Value: "hey " + sv.Value, + }, nil + } + }, + initString: codeBlock{ + code: ` + const client = new grpc.Client(); + client.load([], "../../../../lib/testutils/httpmultibin/grpc_wrappers_testing/test.proto"); + `, + }, + vuString: codeBlock{ + code: ` + client.connect("GRPCBIN_ADDR"); + + let respString = client.invoke("grpc.wrappers.testing.Service/TestString", "John") + if (respString.message !== "hey John") { + throw new Error("expected to get 'hey John', but got a " + respString.message) + } + `, + }, + }, + { + name: "WrappersWithReflection", + setup: func(hb *httpmultibin.HTTPMultiBin) { + reflection.Register(hb.ServerGRPC) + + srv := grpc_wrappers_testing.Register(hb.ServerGRPC) + + srv.TestIntegerImplementation = func(_ context.Context, iv *wrappers.Int64Value) (*wrappers.Int64Value, error) { + return &wrappers.Int64Value{ + Value: 2 * iv.Value, + }, nil + } + + srv.TestStringImplementation = func(_ context.Context, sv *wrappers.StringValue) (*wrappers.StringValue, error) { + return &wrapperspb.StringValue{ + Value: "hey " + sv.Value, + }, nil + } + + srv.TestBooleanImplementation = func(_ context.Context, bv *wrappers.BoolValue) (*wrappers.BoolValue, error) { + return &wrapperspb.BoolValue{ + Value: bv.Value != true, + }, nil + } + + srv.TestDoubleImplementation = func(_ context.Context, bv *wrappers.DoubleValue) (*wrappers.DoubleValue, error) { + return &wrapperspb.DoubleValue{ + Value: bv.Value * 2, + }, nil + } + }, + initString: codeBlock{ + code: ` + const client = new grpc.Client(); + `, + }, + vuString: codeBlock{ + code: ` + client.connect("GRPCBIN_ADDR", {reflect: true}); + + let respString = client.invoke("grpc.wrappers.testing.Service/TestString", "John") + if (respString.message !== "hey John") { + throw new Error("expected to get 'hey John', but got a " + respString.message) + } + + let respInt = client.invoke("grpc.wrappers.testing.Service/TestInteger", "3") + if (respInt.message !== "6") { + throw new Error("expected to get '6', but got a " + respInt.message) + } + + let respDouble = client.invoke("grpc.wrappers.testing.Service/TestDouble", "2.7") + if (respDouble.message !== 5.4) { + throw new Error("expected to get '5.4', but got a " + respDouble.message) + } + `, + }, + }, } assertResponse := func(t *testing.T, cb codeBlock, err error, val goja.Value, ts testState) { diff --git a/lib/testutils/httpmultibin/grpc_wrappers_testing/generate.go b/lib/testutils/httpmultibin/grpc_wrappers_testing/generate.go new file mode 100644 index 000000000000..4d8e3d9df9dd --- /dev/null +++ b/lib/testutils/httpmultibin/grpc_wrappers_testing/generate.go @@ -0,0 +1,4 @@ +// Package grpc_wrappers_testing contains the test service that helps to test gRPC wrappers. +package grpc_wrappers_testing //nolint:revive,stylecheck + +//go:generate protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative test.proto diff --git a/lib/testutils/httpmultibin/grpc_wrappers_testing/service.go b/lib/testutils/httpmultibin/grpc_wrappers_testing/service.go new file mode 100644 index 000000000000..83d3b958dc57 --- /dev/null +++ b/lib/testutils/httpmultibin/grpc_wrappers_testing/service.go @@ -0,0 +1,58 @@ +package grpc_wrappers_testing + +import ( + "context" + + wrappers "github.com/golang/protobuf/ptypes/wrappers" + "google.golang.org/grpc" +) + +// Register registers a test service that could be used for the testing gRPC wrappers +func Register(r grpc.ServiceRegistrar) *service { + s := &service{} + + RegisterServiceServer(r, s) + + return s +} + +type service struct { + UnimplementedServiceServer + + TestStringImplementation func(context.Context, *wrappers.StringValue) (*wrappers.StringValue, error) + TestIntegerImplementation func(context.Context, *wrappers.Int64Value) (*wrappers.Int64Value, error) + TestBooleanImplementation func(context.Context, *wrappers.BoolValue) (*wrappers.BoolValue, error) + TestDoubleImplementation func(context.Context, *wrappers.DoubleValue) (*wrappers.DoubleValue, error) +} + +func (s *service) TestString(ctx context.Context, in *wrappers.StringValue) (*wrappers.StringValue, error) { + if s.TestStringImplementation != nil { + return s.TestStringImplementation(ctx, in) + } + + return s.UnimplementedServiceServer.TestString(ctx, in) +} + +func (s *service) TestInteger(ctx context.Context, in *wrappers.Int64Value) (*wrappers.Int64Value, error) { + if s.TestIntegerImplementation != nil { + return s.TestIntegerImplementation(ctx, in) + } + + return s.UnimplementedServiceServer.TestInteger(ctx, in) +} + +func (s *service) TestBoolean(ctx context.Context, in *wrappers.BoolValue) (*wrappers.BoolValue, error) { + if s.TestBooleanImplementation != nil { + return s.TestBooleanImplementation(ctx, in) + } + + return s.UnimplementedServiceServer.TestBoolean(ctx, in) +} + +func (s *service) TestDouble(ctx context.Context, in *wrappers.DoubleValue) (*wrappers.DoubleValue, error) { + if s.TestDoubleImplementation != nil { + return s.TestDoubleImplementation(ctx, in) + } + + return s.UnimplementedServiceServer.TestDouble(ctx, in) +} diff --git a/lib/testutils/httpmultibin/grpc_wrappers_testing/test.pb.go b/lib/testutils/httpmultibin/grpc_wrappers_testing/test.pb.go new file mode 100644 index 000000000000..3c69d5be8694 --- /dev/null +++ b/lib/testutils/httpmultibin/grpc_wrappers_testing/test.pb.go @@ -0,0 +1,98 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.26.0 +// protoc v3.12.4 +// source: test.proto + +package grpc_wrappers_testing + +import ( + wrappers "github.com/golang/protobuf/ptypes/wrappers" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" +) + +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) +) + +var File_test_proto protoreflect.FileDescriptor + +var file_test_proto_rawDesc = []byte{ + 0x0a, 0x0a, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x15, 0x67, 0x72, + 0x70, 0x63, 0x2e, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x73, 0x2e, 0x74, 0x65, 0x73, 0x74, + 0x69, 0x6e, 0x67, 0x1a, 0x1e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x73, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x32, 0xad, 0x02, 0x0a, 0x07, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, + 0x48, 0x0a, 0x0a, 0x54, 0x65, 0x73, 0x74, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x12, 0x1c, 0x2e, + 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, + 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x1a, 0x1c, 0x2e, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, + 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x47, 0x0a, 0x0b, 0x54, 0x65, 0x73, + 0x74, 0x49, 0x6e, 0x74, 0x65, 0x67, 0x65, 0x72, 0x12, 0x1b, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, + 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x49, 0x6e, 0x74, 0x36, 0x34, + 0x56, 0x61, 0x6c, 0x75, 0x65, 0x1a, 0x1b, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x49, 0x6e, 0x74, 0x36, 0x34, 0x56, 0x61, 0x6c, + 0x75, 0x65, 0x12, 0x45, 0x0a, 0x0b, 0x54, 0x65, 0x73, 0x74, 0x42, 0x6f, 0x6f, 0x6c, 0x65, 0x61, + 0x6e, 0x12, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x62, 0x75, 0x66, 0x2e, 0x42, 0x6f, 0x6f, 0x6c, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x1a, 0x1a, 0x2e, + 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, + 0x42, 0x6f, 0x6f, 0x6c, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x48, 0x0a, 0x0a, 0x54, 0x65, 0x73, + 0x74, 0x44, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x12, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x6f, 0x75, 0x62, 0x6c, 0x65, + 0x56, 0x61, 0x6c, 0x75, 0x65, 0x1a, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x6f, 0x75, 0x62, 0x6c, 0x65, 0x56, 0x61, + 0x6c, 0x75, 0x65, 0x42, 0x19, 0x5a, 0x17, 0x2e, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x5f, 0x77, 0x72, + 0x61, 0x70, 0x70, 0x65, 0x72, 0x73, 0x5f, 0x74, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var file_test_proto_goTypes = []interface{}{ + (*wrappers.StringValue)(nil), // 0: google.protobuf.StringValue + (*wrappers.Int64Value)(nil), // 1: google.protobuf.Int64Value + (*wrappers.BoolValue)(nil), // 2: google.protobuf.BoolValue + (*wrappers.DoubleValue)(nil), // 3: google.protobuf.DoubleValue +} +var file_test_proto_depIdxs = []int32{ + 0, // 0: grpc.wrappers.testing.Service.TestString:input_type -> google.protobuf.StringValue + 1, // 1: grpc.wrappers.testing.Service.TestInteger:input_type -> google.protobuf.Int64Value + 2, // 2: grpc.wrappers.testing.Service.TestBoolean:input_type -> google.protobuf.BoolValue + 3, // 3: grpc.wrappers.testing.Service.TestDouble:input_type -> google.protobuf.DoubleValue + 0, // 4: grpc.wrappers.testing.Service.TestString:output_type -> google.protobuf.StringValue + 1, // 5: grpc.wrappers.testing.Service.TestInteger:output_type -> google.protobuf.Int64Value + 2, // 6: grpc.wrappers.testing.Service.TestBoolean:output_type -> google.protobuf.BoolValue + 3, // 7: grpc.wrappers.testing.Service.TestDouble:output_type -> google.protobuf.DoubleValue + 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_test_proto_init() } +func file_test_proto_init() { + if File_test_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_test_proto_rawDesc, + NumEnums: 0, + NumMessages: 0, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_test_proto_goTypes, + DependencyIndexes: file_test_proto_depIdxs, + }.Build() + File_test_proto = out.File + file_test_proto_rawDesc = nil + file_test_proto_goTypes = nil + file_test_proto_depIdxs = nil +} diff --git a/lib/testutils/httpmultibin/grpc_wrappers_testing/test.proto b/lib/testutils/httpmultibin/grpc_wrappers_testing/test.proto new file mode 100644 index 000000000000..6ba9f925a1b0 --- /dev/null +++ b/lib/testutils/httpmultibin/grpc_wrappers_testing/test.proto @@ -0,0 +1,17 @@ +syntax = "proto3"; + +package grpc.wrappers.testing; + +// this proto contains service that helps tests some of well-known types or wrappers +// https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/wrappers.proto + +import "google/protobuf/wrappers.proto"; + +option go_package ="./grpc_wrappers_testing"; + +service Service { + rpc TestString(google.protobuf.StringValue) returns (google.protobuf.StringValue); + rpc TestInteger(google.protobuf.Int64Value) returns (google.protobuf.Int64Value); + rpc TestBoolean(google.protobuf.BoolValue) returns (google.protobuf.BoolValue); + rpc TestDouble(google.protobuf.DoubleValue) returns (google.protobuf.DoubleValue); +} diff --git a/lib/testutils/httpmultibin/grpc_wrappers_testing/test_grpc.pb.go b/lib/testutils/httpmultibin/grpc_wrappers_testing/test_grpc.pb.go new file mode 100644 index 000000000000..4f7cb02ec5f0 --- /dev/null +++ b/lib/testutils/httpmultibin/grpc_wrappers_testing/test_grpc.pb.go @@ -0,0 +1,210 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. + +package grpc_wrappers_testing + +import ( + context "context" + wrappers "github.com/golang/protobuf/ptypes/wrappers" + 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 + +// ServiceClient is the client API for Service 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 ServiceClient interface { + TestString(ctx context.Context, in *wrappers.StringValue, opts ...grpc.CallOption) (*wrappers.StringValue, error) + TestInteger(ctx context.Context, in *wrappers.Int64Value, opts ...grpc.CallOption) (*wrappers.Int64Value, error) + TestBoolean(ctx context.Context, in *wrappers.BoolValue, opts ...grpc.CallOption) (*wrappers.BoolValue, error) + TestDouble(ctx context.Context, in *wrappers.DoubleValue, opts ...grpc.CallOption) (*wrappers.DoubleValue, error) +} + +type serviceClient struct { + cc grpc.ClientConnInterface +} + +func NewServiceClient(cc grpc.ClientConnInterface) ServiceClient { + return &serviceClient{cc} +} + +func (c *serviceClient) TestString(ctx context.Context, in *wrappers.StringValue, opts ...grpc.CallOption) (*wrappers.StringValue, error) { + out := new(wrappers.StringValue) + err := c.cc.Invoke(ctx, "/grpc.wrappers.testing.Service/TestString", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *serviceClient) TestInteger(ctx context.Context, in *wrappers.Int64Value, opts ...grpc.CallOption) (*wrappers.Int64Value, error) { + out := new(wrappers.Int64Value) + err := c.cc.Invoke(ctx, "/grpc.wrappers.testing.Service/TestInteger", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *serviceClient) TestBoolean(ctx context.Context, in *wrappers.BoolValue, opts ...grpc.CallOption) (*wrappers.BoolValue, error) { + out := new(wrappers.BoolValue) + err := c.cc.Invoke(ctx, "/grpc.wrappers.testing.Service/TestBoolean", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *serviceClient) TestDouble(ctx context.Context, in *wrappers.DoubleValue, opts ...grpc.CallOption) (*wrappers.DoubleValue, error) { + out := new(wrappers.DoubleValue) + err := c.cc.Invoke(ctx, "/grpc.wrappers.testing.Service/TestDouble", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// ServiceServer is the server API for Service service. +// All implementations must embed UnimplementedServiceServer +// for forward compatibility +type ServiceServer interface { + TestString(context.Context, *wrappers.StringValue) (*wrappers.StringValue, error) + TestInteger(context.Context, *wrappers.Int64Value) (*wrappers.Int64Value, error) + TestBoolean(context.Context, *wrappers.BoolValue) (*wrappers.BoolValue, error) + TestDouble(context.Context, *wrappers.DoubleValue) (*wrappers.DoubleValue, error) + mustEmbedUnimplementedServiceServer() +} + +// UnimplementedServiceServer must be embedded to have forward compatible implementations. +type UnimplementedServiceServer struct { +} + +func (UnimplementedServiceServer) TestString(context.Context, *wrappers.StringValue) (*wrappers.StringValue, error) { + return nil, status.Errorf(codes.Unimplemented, "method TestString not implemented") +} +func (UnimplementedServiceServer) TestInteger(context.Context, *wrappers.Int64Value) (*wrappers.Int64Value, error) { + return nil, status.Errorf(codes.Unimplemented, "method TestInteger not implemented") +} +func (UnimplementedServiceServer) TestBoolean(context.Context, *wrappers.BoolValue) (*wrappers.BoolValue, error) { + return nil, status.Errorf(codes.Unimplemented, "method TestBoolean not implemented") +} +func (UnimplementedServiceServer) TestDouble(context.Context, *wrappers.DoubleValue) (*wrappers.DoubleValue, error) { + return nil, status.Errorf(codes.Unimplemented, "method TestDouble not implemented") +} +func (UnimplementedServiceServer) mustEmbedUnimplementedServiceServer() {} + +// UnsafeServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to ServiceServer will +// result in compilation errors. +type UnsafeServiceServer interface { + mustEmbedUnimplementedServiceServer() +} + +func RegisterServiceServer(s grpc.ServiceRegistrar, srv ServiceServer) { + s.RegisterService(&Service_ServiceDesc, srv) +} + +func _Service_TestString_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(wrappers.StringValue) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ServiceServer).TestString(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/grpc.wrappers.testing.Service/TestString", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ServiceServer).TestString(ctx, req.(*wrappers.StringValue)) + } + return interceptor(ctx, in, info, handler) +} + +func _Service_TestInteger_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(wrappers.Int64Value) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ServiceServer).TestInteger(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/grpc.wrappers.testing.Service/TestInteger", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ServiceServer).TestInteger(ctx, req.(*wrappers.Int64Value)) + } + return interceptor(ctx, in, info, handler) +} + +func _Service_TestBoolean_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(wrappers.BoolValue) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ServiceServer).TestBoolean(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/grpc.wrappers.testing.Service/TestBoolean", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ServiceServer).TestBoolean(ctx, req.(*wrappers.BoolValue)) + } + return interceptor(ctx, in, info, handler) +} + +func _Service_TestDouble_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(wrappers.DoubleValue) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ServiceServer).TestDouble(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/grpc.wrappers.testing.Service/TestDouble", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ServiceServer).TestDouble(ctx, req.(*wrappers.DoubleValue)) + } + return interceptor(ctx, in, info, handler) +} + +// Service_ServiceDesc is the grpc.ServiceDesc for Service service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var Service_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "grpc.wrappers.testing.Service", + HandlerType: (*ServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "TestString", + Handler: _Service_TestString_Handler, + }, + { + MethodName: "TestInteger", + Handler: _Service_TestInteger_Handler, + }, + { + MethodName: "TestBoolean", + Handler: _Service_TestBoolean_Handler, + }, + { + MethodName: "TestDouble", + Handler: _Service_TestDouble_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "test.proto", +} diff --git a/vendor/github.com/golang/protobuf/ptypes/wrappers/wrappers.pb.go b/vendor/github.com/golang/protobuf/ptypes/wrappers/wrappers.pb.go new file mode 100644 index 000000000000..cc40f27ad306 --- /dev/null +++ b/vendor/github.com/golang/protobuf/ptypes/wrappers/wrappers.pb.go @@ -0,0 +1,71 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// source: github.com/golang/protobuf/ptypes/wrappers/wrappers.proto + +package wrappers + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + wrapperspb "google.golang.org/protobuf/types/known/wrapperspb" + reflect "reflect" +) + +// Symbols defined in public import of google/protobuf/wrappers.proto. + +type DoubleValue = wrapperspb.DoubleValue +type FloatValue = wrapperspb.FloatValue +type Int64Value = wrapperspb.Int64Value +type UInt64Value = wrapperspb.UInt64Value +type Int32Value = wrapperspb.Int32Value +type UInt32Value = wrapperspb.UInt32Value +type BoolValue = wrapperspb.BoolValue +type StringValue = wrapperspb.StringValue +type BytesValue = wrapperspb.BytesValue + +var File_github_com_golang_protobuf_ptypes_wrappers_wrappers_proto protoreflect.FileDescriptor + +var file_github_com_golang_protobuf_ptypes_wrappers_wrappers_proto_rawDesc = []byte{ + 0x0a, 0x39, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, 0x6c, + 0x61, 0x6e, 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x70, 0x74, 0x79, + 0x70, 0x65, 0x73, 0x2f, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x73, 0x2f, 0x77, 0x72, 0x61, + 0x70, 0x70, 0x65, 0x72, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x67, 0x6f, 0x6f, + 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x77, 0x72, 0x61, + 0x70, 0x70, 0x65, 0x72, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x42, 0x35, 0x5a, 0x33, 0x67, + 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, 0x6c, 0x61, 0x6e, 0x67, + 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x70, 0x74, 0x79, 0x70, 0x65, 0x73, + 0x2f, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x73, 0x3b, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, + 0x72, 0x73, 0x50, 0x00, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var file_github_com_golang_protobuf_ptypes_wrappers_wrappers_proto_goTypes = []interface{}{} +var file_github_com_golang_protobuf_ptypes_wrappers_wrappers_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] 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_github_com_golang_protobuf_ptypes_wrappers_wrappers_proto_init() } +func file_github_com_golang_protobuf_ptypes_wrappers_wrappers_proto_init() { + if File_github_com_golang_protobuf_ptypes_wrappers_wrappers_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_github_com_golang_protobuf_ptypes_wrappers_wrappers_proto_rawDesc, + NumEnums: 0, + NumMessages: 0, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_github_com_golang_protobuf_ptypes_wrappers_wrappers_proto_goTypes, + DependencyIndexes: file_github_com_golang_protobuf_ptypes_wrappers_wrappers_proto_depIdxs, + }.Build() + File_github_com_golang_protobuf_ptypes_wrappers_wrappers_proto = out.File + file_github_com_golang_protobuf_ptypes_wrappers_wrappers_proto_rawDesc = nil + file_github_com_golang_protobuf_ptypes_wrappers_wrappers_proto_goTypes = nil + file_github_com_golang_protobuf_ptypes_wrappers_wrappers_proto_depIdxs = nil +} diff --git a/vendor/modules.txt b/vendor/modules.txt index d78329cf5633..d6d66b0cfa9d 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -138,6 +138,7 @@ github.com/golang/protobuf/ptypes github.com/golang/protobuf/ptypes/any github.com/golang/protobuf/ptypes/duration github.com/golang/protobuf/ptypes/timestamp +github.com/golang/protobuf/ptypes/wrappers # github.com/golang/snappy v0.0.4 ## explicit github.com/golang/snappy