Reimplement unimplemented_method and address gofmt issues

This commit is contained in:
Noah Eisen
2016-11-02 14:53:28 -07:00
parent 5b6bca7d0c
commit 687c958422
4 changed files with 61 additions and 102 deletions

View File

@ -191,7 +191,7 @@ func main() {
interop.DoCustomMetadata(tc)
grpclog.Println("CustomMetadata done")
case "unimplemented_method":
interop.DoUnimplementedMethod(tc)
interop.DoUnimplementedMethod(serverAddr)
grpclog.Println("UnimplementedMethod done")
case "unimplemented_service":
interop.DoUnimplementedService(testpb.NewUnimplementedServiceClient(conn))

View File

@ -432,9 +432,6 @@ type TestServiceClient interface {
// stream of responses are returned to the client when the server starts with
// first request.
HalfDuplexCall(ctx context.Context, opts ...grpc.CallOption) (TestService_HalfDuplexCallClient, error)
// The test server will not implement this method. It will be used
// to test the behavior when clients call unimplemented methods.
UnimplementedCall(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*Empty, error)
}
type testServiceClient struct {
@ -591,15 +588,6 @@ func (x *testServiceHalfDuplexCallClient) Recv() (*StreamingOutputCallResponse,
return m, nil
}
func (c *testServiceClient) UnimplementedCall(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*Empty, error) {
out := new(Empty)
err := grpc.Invoke(ctx, "/grpc.testing.TestService/UnimplementedCall", in, out, c.cc, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// Server API for TestService service
type TestServiceServer interface {
@ -623,9 +611,6 @@ type TestServiceServer interface {
// stream of responses are returned to the client when the server starts with
// first request.
HalfDuplexCall(TestService_HalfDuplexCallServer) error
// The test server will not implement this method. It will be used
// to test the behavior when clients call unimplemented methods.
UnimplementedCall(context.Context, *Empty) (*Empty, error)
}
func RegisterTestServiceServer(s *grpc.Server, srv TestServiceServer) {
@ -767,24 +752,6 @@ func (x *testServiceHalfDuplexCallServer) Recv() (*StreamingOutputCallRequest, e
return m, nil
}
func _TestService_UnimplementedCall_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.(TestServiceServer).UnimplementedCall(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/grpc.testing.TestService/UnimplementedCall",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(TestServiceServer).UnimplementedCall(ctx, req.(*Empty))
}
return interceptor(ctx, in, info, handler)
}
var _TestService_serviceDesc = grpc.ServiceDesc{
ServiceName: "grpc.testing.TestService",
HandlerType: (*TestServiceServer)(nil),
@ -797,10 +764,6 @@ var _TestService_serviceDesc = grpc.ServiceDesc{
MethodName: "UnaryCall",
Handler: _TestService_UnaryCall_Handler,
},
{
MethodName: "UnimplementedCall",
Handler: _TestService_UnimplementedCall_Handler,
},
},
Streams: []grpc.StreamDesc{
{
@ -898,46 +861,46 @@ var _UnimplementedService_serviceDesc = grpc.ServiceDesc{
func init() { proto.RegisterFile("test.proto", fileDescriptor0) }
var fileDescriptor0 = []byte{
// 654 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xbc, 0x54, 0x4f, 0x6f, 0xd3, 0x4e,
0x10, 0xfd, 0x39, 0x4d, 0x7e, 0x69, 0x27, 0xa9, 0x09, 0x53, 0x2a, 0xdc, 0x14, 0x89, 0xc8, 0x1c,
0x30, 0x48, 0x04, 0x14, 0x09, 0x0e, 0x48, 0x80, 0x4a, 0x9b, 0x8a, 0x4a, 0x6d, 0x53, 0xec, 0xe6,
0x1c, 0x2d, 0xc9, 0xd4, 0xb5, 0xe4, 0x7f, 0xd8, 0xeb, 0x8a, 0xf4, 0xc0, 0x97, 0xe1, 0x43, 0xf0,
0xdd, 0x38, 0xa1, 0x5d, 0xdb, 0x89, 0x93, 0xa6, 0xa2, 0xa1, 0xc0, 0x6d, 0x77, 0xf6, 0xcd, 0x9b,
0x79, 0x33, 0xcf, 0x06, 0xe0, 0x14, 0xf3, 0x76, 0x18, 0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 0xff, 0xff, 0x93, 0xfa, 0x94, 0xe8, 0xe1, 0x07, 0x00, 0x00,
// 649 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xbc, 0x54, 0x4d, 0x6f, 0xd3, 0x40,
0x10, 0xc5, 0x69, 0x42, 0xda, 0x49, 0x6a, 0xc2, 0x94, 0x0a, 0x37, 0x45, 0x22, 0x32, 0x07, 0x0c,
0x12, 0x01, 0x45, 0x82, 0x03, 0x12, 0xa0, 0xd2, 0xa6, 0xa2, 0x52, 0xdb, 0x14, 0xbb, 0x39, 0x47,
0x4b, 0x32, 0x75, 0x2d, 0xf9, 0x0b, 0x7b, 0x5d, 0x91, 0x1e, 0xf8, 0x33, 0xfc, 0x08, 0x0e, 0xfc,
0x39, 0xb4, 0x6b, 0x3b, 0x71, 0xd2, 0x54, 0x34, 0x7c, 0xdd, 0x76, 0xdf, 0xbe, 0xf9, 0x78, 0x33,
0xcf, 0x06, 0xe0, 0x14, 0xf3, 0x76, 0x18, 0x05, 0x3c, 0xc0, 0xba, 0x1d, 0x85, 0xc3, 0xb6, 0x00,
0x1c, 0xdf, 0xd6, 0xab, 0x50, 0xe9, 0x7a, 0x21, 0x1f, 0xeb, 0x87, 0x50, 0x3d, 0x61, 0x63, 0x37,
0x60, 0x23, 0x7c, 0x06, 0x65, 0x3e, 0x0e, 0x49, 0x53, 0x5a, 0x8a, 0xa1, 0x76, 0xb6, 0xda, 0xc5,
0x80, 0x76, 0x46, 0x3a, 0x1d, 0x87, 0x64, 0x4a, 0x1a, 0x22, 0x94, 0x3f, 0x05, 0xa3, 0xb1, 0x56,
0x6a, 0x29, 0x46, 0xdd, 0x94, 0x67, 0xfd, 0x35, 0x40, 0x77, 0x78, 0x1e, 0x58, 0x9c, 0xf1, 0x24,
0x16, 0x8c, 0x61, 0x30, 0x4a, 0x13, 0x56, 0x4c, 0x79, 0x46, 0x0d, 0xaa, 0x1e, 0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61, 0xdb, 0xb3,
0x8c, 0x99, 0xdf, 0x57, 0xf3, 0xc1, 0xe2, 0xc7, 0x6c, 0x00, 0x2e, 0x6c, 0x2c, 0x98, 0x0f, 0x1a,
0x73, 0x41, 0xd7, 0xfa, 0xac, 0xf9, 0xe4, 0x06, 0xcc, 0xb4, 0xd6, 0x0b, 0x05, 0x1d, 0xc0, 0xab,
0x1f, 0x15, 0x3e, 0xbe, 0x26, 0xc5, 0xfc, 0x47, 0xdc, 0x34, 0x7e, 0x4d, 0x4c, 0x4b, 0x19, 0xa2,
0x94, 0xba, 0x9f, 0xb8, 0xee, 0x5e, 0x12, 0xba, 0xf4, 0xe5, 0x9f, 0x69, 0x32, 0x14, 0xa9, 0x4a,
0xfd, 0xc0, 0xdc, 0xb3, 0xff, 0x50, 0xaa, 0xd3, 0x87, 0x7b, 0x7d, 0x5f, 0x6e, 0xd0, 0x23, 0x9f,
0xd3, 0x28, 0x77, 0xd1, 0x1b, 0xb8, 0x3b, 0x83, 0x2f, 0xe7, 0xa6, 0x9f, 0x01, 0x00, 0x00, 0xff,
0xff, 0xdd, 0xb5, 0x50, 0x6f, 0xa2, 0x07, 0x00, 0x00,
}

View File

@ -150,10 +150,6 @@ service TestService {
// first request.
rpc HalfDuplexCall(stream StreamingOutputCallRequest)
returns (stream StreamingOutputCallResponse);
// The test server will not implement this method. It will be used
// to test the behavior when clients call unimplemented methods.
rpc UnimplementedCall(grpc.testing.Empty) returns (grpc.testing.Empty);
}
// A simple service NOT implemented at servers so clients can test for

View File

@ -52,11 +52,11 @@ import (
)
var (
reqSizes = []int{27182, 8, 1828, 45904}
respSizes = []int{31415, 9, 2653, 58979}
largeReqSize = 271828
largeRespSize = 314159
initialMetadataKey = "x-grpc-test-echo-initial"
reqSizes = []int{27182, 8, 1828, 45904}
respSizes = []int{31415, 9, 2653, 58979}
largeReqSize = 271828
largeRespSize = 314159
initialMetadataKey = "x-grpc-test-echo-initial"
trailingMetadataKey = "x-grpc-test-echo-trailing-bin"
)
@ -457,9 +457,9 @@ func DoCancelAfterFirstResponse(tc testpb.TestServiceClient) {
}
var (
initialMetadataValue = "test_initial_metadata_value"
initialMetadataValue = "test_initial_metadata_value"
trailingMetadataValue = "\x0a\x0b\x0a\x0b\x0a\x0b"
customMetadata = metadata.Pairs(
customMetadata = metadata.Pairs(
initialMetadataKey, initialMetadataValue,
trailingMetadataKey, trailingMetadataValue,
)
@ -489,7 +489,7 @@ func DoCustomMetadata(tc testpb.TestServiceClient) {
ResponseSize: proto.Int32(int32(1)),
Payload: pl,
}
ctx := metadata.NewContext(context.Background(), customMetadata);
ctx := metadata.NewContext(context.Background(), customMetadata)
var header, trailer metadata.MD
reply, err := tc.UnaryCall(
ctx,
@ -586,12 +586,16 @@ func DoUnimplementedService(tc testpb.UnimplementedServiceClient) {
}
}
func DoUnimplementedMethod(tc testpb.TestServiceClient) {
var code int32 = 12
expectedCode := codes.Code(code)
_, err := tc.UnimplementedCall(context.Background(), &testpb.Empty{})
if grpc.Code(err) != expectedCode {
grpclog.Fatalf("%v.UnimplementedCall() = _, %v, want _, %v", tc, grpc.Code(err), expectedCode)
func DoUnimplementedMethod(serverAddr string) {
cc, err := grpc.Dial(serverAddr, grpc.WithInsecure(), grpc.WithBlock())
if err != nil {
grpclog.Fatalf("Failed to dial to the backend %v", err)
}
var (
req, reply proto.Message
)
if err := grpc.Invoke(context.Background(), "/foo/bar", req, reply, cc); err == nil || grpc.Code(err) != codes.Unimplemented {
grpclog.Fatalf("grpc.Invoke(_, _, _, _, _) = %v, want error code %s", err, codes.Unimplemented)
}
}
@ -603,10 +607,6 @@ func NewTestServer() testpb.TestServiceServer {
return &testServer{}
}
func (s *testServer) UnimplementedCall(ctx context.Context, in *testpb.Empty) (*testpb.Empty, error) {
return nil, grpc.Errorf(codes.Code(12), "") // 12 == UNIMPLEMENTED
}
func (s *testServer) EmptyCall(ctx context.Context, in *testpb.Empty) (*testpb.Empty, error) {
return new(testpb.Empty), nil
}