diff --git a/call.go b/call.go index c8abda7d08e9..4fc3ba1b64b8 100644 --- a/call.go +++ b/call.go @@ -31,7 +31,7 @@ * */ -package rpc +package grpc import ( "io" diff --git a/clientconn.go b/clientconn.go index 358e5df610fd..696f8f8b2a99 100644 --- a/clientconn.go +++ b/clientconn.go @@ -31,10 +31,7 @@ * */ -/* -Package rpc implements various components to perform RPC on top of transport package. -*/ -package rpc +package grpc import ( "fmt" diff --git a/doc.go b/doc.go new file mode 100644 index 000000000000..621b42547b00 --- /dev/null +++ b/doc.go @@ -0,0 +1,4 @@ +/* +Package grpc implements various components to perform RPC on top of transport package. +*/ +package grpc diff --git a/interop/testdata/test_proto_grpc.pb.go b/interop/testdata/test_proto_grpc.pb.go index 9d9a57ac50f6..1ecc25246387 100644 --- a/interop/testdata/test_proto_grpc.pb.go +++ b/interop/testdata/test_proto_grpc.pb.go @@ -35,49 +35,49 @@ package grpc_testing import ( "fmt" - "github.com/grpc/grpc-go/rpc" proto "github.com/golang/protobuf/proto" context "golang.org/x/net/context" + "google.golang.org/grpc" "io" ) type TestServiceClient interface { - EmptyCall(ctx context.Context, in *Empty, opts ...rpc.CallOption) (*Empty, error) - UnaryCall(ctx context.Context, in *SimpleRequest, opts ...rpc.CallOption) (*SimpleResponse, error) - StreamingOutputCall(ctx context.Context, m *StreamingOutputCallRequest, opts ...rpc.CallOption) (TestService_StreamingOutputCallClient, error) - StreamingInputCall(ctx context.Context, opts ...rpc.CallOption) (TestService_StreamingInputCallClient, error) - FullDuplexCall(ctx context.Context, opts ...rpc.CallOption) (TestService_FullDuplexCallClient, error) - HalfDuplexCall(ctx context.Context, opts ...rpc.CallOption) (TestService_HalfDuplexCallClient, error) + EmptyCall(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*Empty, error) + UnaryCall(ctx context.Context, in *SimpleRequest, opts ...grpc.CallOption) (*SimpleResponse, error) + StreamingOutputCall(ctx context.Context, m *StreamingOutputCallRequest, opts ...grpc.CallOption) (TestService_StreamingOutputCallClient, error) + StreamingInputCall(ctx context.Context, opts ...grpc.CallOption) (TestService_StreamingInputCallClient, error) + FullDuplexCall(ctx context.Context, opts ...grpc.CallOption) (TestService_FullDuplexCallClient, error) + HalfDuplexCall(ctx context.Context, opts ...grpc.CallOption) (TestService_HalfDuplexCallClient, error) } type testServiceClient struct { - cc *rpc.ClientConn + cc *grpc.ClientConn } -func NewTestServiceClient(cc *rpc.ClientConn) TestServiceClient { +func NewTestServiceClient(cc *grpc.ClientConn) TestServiceClient { return &testServiceClient{cc} } -func (c *testServiceClient) EmptyCall(ctx context.Context, in *Empty, opts ...rpc.CallOption) (*Empty, error) { +func (c *testServiceClient) EmptyCall(ctx context.Context, in *Empty, opts ...grpc.CallOption) (*Empty, error) { out := new(Empty) - err := rpc.Invoke(ctx, "/grpc.testing.TestService/EmptyCall", in, out, c.cc, opts...) + err := grpc.Invoke(ctx, "/grpc.testing.TestService/EmptyCall", in, out, c.cc, opts...) if err != nil { return nil, err } return out, nil } -func (c *testServiceClient) UnaryCall(ctx context.Context, in *SimpleRequest, opts ...rpc.CallOption) (*SimpleResponse, error) { +func (c *testServiceClient) UnaryCall(ctx context.Context, in *SimpleRequest, opts ...grpc.CallOption) (*SimpleResponse, error) { out := new(SimpleResponse) - err := rpc.Invoke(ctx, "/grpc.testing.TestService/UnaryCall", in, out, c.cc, opts...) + err := grpc.Invoke(ctx, "/grpc.testing.TestService/UnaryCall", in, out, c.cc, opts...) if err != nil { return nil, err } return out, nil } -func (c *testServiceClient) StreamingOutputCall(ctx context.Context, m *StreamingOutputCallRequest, opts ...rpc.CallOption) (TestService_StreamingOutputCallClient, error) { - stream, err := rpc.NewClientStream(ctx, c.cc, "/grpc.testing.TestService/StreamingOutputCall", opts...) +func (c *testServiceClient) StreamingOutputCall(ctx context.Context, m *StreamingOutputCallRequest, opts ...grpc.CallOption) (TestService_StreamingOutputCallClient, error) { + stream, err := grpc.NewClientStream(ctx, c.cc, "/grpc.testing.TestService/StreamingOutputCall", opts...) if err != nil { return nil, err } @@ -93,11 +93,11 @@ func (c *testServiceClient) StreamingOutputCall(ctx context.Context, m *Streamin type TestService_StreamingOutputCallClient interface { Recv() (*StreamingOutputCallResponse, error) - rpc.ClientStream + grpc.ClientStream } type testServiceStreamingOutputCallClient struct { - rpc.ClientStream + grpc.ClientStream } func (x *testServiceStreamingOutputCallClient) Recv() (*StreamingOutputCallResponse, error) { @@ -108,8 +108,8 @@ func (x *testServiceStreamingOutputCallClient) Recv() (*StreamingOutputCallRespo return m, nil } -func (c *testServiceClient) StreamingInputCall(ctx context.Context, opts ...rpc.CallOption) (TestService_StreamingInputCallClient, error) { - stream, err := rpc.NewClientStream(ctx, c.cc, "/grpc.testing.TestService/StreamingInputCall", opts...) +func (c *testServiceClient) StreamingInputCall(ctx context.Context, opts ...grpc.CallOption) (TestService_StreamingInputCallClient, error) { + stream, err := grpc.NewClientStream(ctx, c.cc, "/grpc.testing.TestService/StreamingInputCall", opts...) if err != nil { return nil, err } @@ -119,11 +119,11 @@ func (c *testServiceClient) StreamingInputCall(ctx context.Context, opts ...rpc. type TestService_StreamingInputCallClient interface { Send(*StreamingInputCallRequest) error CloseAndRecv() (*StreamingInputCallResponse, error) - rpc.ClientStream + grpc.ClientStream } type testServiceStreamingInputCallClient struct { - rpc.ClientStream + grpc.ClientStream } func (x *testServiceStreamingInputCallClient) Send(m *StreamingInputCallRequest) error { @@ -146,8 +146,8 @@ func (x *testServiceStreamingInputCallClient) CloseAndRecv() (*StreamingInputCal return m, fmt.Errorf("Violate gRPC client streaming protocol: no EOF after the response.") } -func (c *testServiceClient) FullDuplexCall(ctx context.Context, opts ...rpc.CallOption) (TestService_FullDuplexCallClient, error) { - stream, err := rpc.NewClientStream(ctx, c.cc, "/grpc.testing.TestService/FullDuplexCall", opts...) +func (c *testServiceClient) FullDuplexCall(ctx context.Context, opts ...grpc.CallOption) (TestService_FullDuplexCallClient, error) { + stream, err := grpc.NewClientStream(ctx, c.cc, "/grpc.testing.TestService/FullDuplexCall", opts...) if err != nil { return nil, err } @@ -157,11 +157,11 @@ func (c *testServiceClient) FullDuplexCall(ctx context.Context, opts ...rpc.Call type TestService_FullDuplexCallClient interface { Send(*StreamingOutputCallRequest) error Recv() (*StreamingOutputCallResponse, error) - rpc.ClientStream + grpc.ClientStream } type testServiceFullDuplexCallClient struct { - rpc.ClientStream + grpc.ClientStream } func (x *testServiceFullDuplexCallClient) Send(m *StreamingOutputCallRequest) error { @@ -176,8 +176,8 @@ func (x *testServiceFullDuplexCallClient) Recv() (*StreamingOutputCallResponse, return m, nil } -func (c *testServiceClient) HalfDuplexCall(ctx context.Context, opts ...rpc.CallOption) (TestService_HalfDuplexCallClient, error) { - stream, err := rpc.NewClientStream(ctx, c.cc, "/grpc.testing.TestService/HalfDuplexCall", opts...) +func (c *testServiceClient) HalfDuplexCall(ctx context.Context, opts ...grpc.CallOption) (TestService_HalfDuplexCallClient, error) { + stream, err := grpc.NewClientStream(ctx, c.cc, "/grpc.testing.TestService/HalfDuplexCall", opts...) if err != nil { return nil, err } @@ -187,11 +187,11 @@ func (c *testServiceClient) HalfDuplexCall(ctx context.Context, opts ...rpc.Call type TestService_HalfDuplexCallClient interface { Send(*StreamingOutputCallRequest) error Recv() (*StreamingOutputCallResponse, error) - rpc.ClientStream + grpc.ClientStream } type testServiceHalfDuplexCallClient struct { - rpc.ClientStream + grpc.ClientStream } func (x *testServiceHalfDuplexCallClient) Send(m *StreamingOutputCallRequest) error { @@ -215,7 +215,7 @@ type TestServiceServer interface { HalfDuplexCall(TestService_HalfDuplexCallServer) error } -func RegisterService(s *rpc.Server, srv TestServiceServer) { +func RegisterService(s *grpc.Server, srv TestServiceServer) { s.RegisterService(&_TestService_serviceDesc, srv) } @@ -243,7 +243,7 @@ func _TestService_UnaryCall_Handler(srv interface{}, ctx context.Context, buf [] return out, nil } -func _TestService_StreamingOutputCall_Handler(srv interface{}, stream rpc.ServerStream) error { +func _TestService_StreamingOutputCall_Handler(srv interface{}, stream grpc.ServerStream) error { m := new(StreamingOutputCallRequest) if err := stream.RecvProto(m); err != nil { return err @@ -253,29 +253,29 @@ func _TestService_StreamingOutputCall_Handler(srv interface{}, stream rpc.Server type TestService_StreamingOutputCallServer interface { Send(*StreamingOutputCallResponse) error - rpc.ServerStream + grpc.ServerStream } type testServiceStreamingOutputCallServer struct { - rpc.ServerStream + grpc.ServerStream } func (x *testServiceStreamingOutputCallServer) Send(m *StreamingOutputCallResponse) error { return x.ServerStream.SendProto(m) } -func _TestService_StreamingInputCall_Handler(srv interface{}, stream rpc.ServerStream) error { +func _TestService_StreamingInputCall_Handler(srv interface{}, stream grpc.ServerStream) error { return srv.(TestServiceServer).StreamingInputCall(&testServiceStreamingInputCallServer{stream}) } type TestService_StreamingInputCallServer interface { SendAndClose(*StreamingInputCallResponse) error Recv() (*StreamingInputCallRequest, error) - rpc.ServerStream + grpc.ServerStream } type testServiceStreamingInputCallServer struct { - rpc.ServerStream + grpc.ServerStream } func (x *testServiceStreamingInputCallServer) SendAndClose(m *StreamingInputCallResponse) error { @@ -293,18 +293,18 @@ func (x *testServiceStreamingInputCallServer) Recv() (*StreamingInputCallRequest return m, nil } -func _TestService_FullDuplexCall_Handler(srv interface{}, stream rpc.ServerStream) error { +func _TestService_FullDuplexCall_Handler(srv interface{}, stream grpc.ServerStream) error { return srv.(TestServiceServer).FullDuplexCall(&testServiceFullDuplexCallServer{stream}) } type TestService_FullDuplexCallServer interface { Send(*StreamingOutputCallResponse) error Recv() (*StreamingOutputCallRequest, error) - rpc.ServerStream + grpc.ServerStream } type testServiceFullDuplexCallServer struct { - rpc.ServerStream + grpc.ServerStream } func (x *testServiceFullDuplexCallServer) Send(m *StreamingOutputCallResponse) error { @@ -319,18 +319,18 @@ func (x *testServiceFullDuplexCallServer) Recv() (*StreamingOutputCallRequest, e return m, nil } -func _TestService_HalfDuplexCall_Handler(srv interface{}, stream rpc.ServerStream) error { +func _TestService_HalfDuplexCall_Handler(srv interface{}, stream grpc.ServerStream) error { return srv.(TestServiceServer).HalfDuplexCall(&testServiceHalfDuplexCallServer{stream}) } type TestService_HalfDuplexCallServer interface { Send(*StreamingOutputCallResponse) error Recv() (*StreamingOutputCallRequest, error) - rpc.ServerStream + grpc.ServerStream } type testServiceHalfDuplexCallServer struct { - rpc.ServerStream + grpc.ServerStream } func (x *testServiceHalfDuplexCallServer) Send(m *StreamingOutputCallResponse) error { @@ -345,10 +345,10 @@ func (x *testServiceHalfDuplexCallServer) Recv() (*StreamingOutputCallRequest, e return m, nil } -var _TestService_serviceDesc = rpc.ServiceDesc{ +var _TestService_serviceDesc = grpc.ServiceDesc{ ServiceName: "grpc.testing.TestService", HandlerType: (*TestServiceServer)(nil), - Methods: []rpc.MethodDesc{ + Methods: []grpc.MethodDesc{ { MethodName: "EmptyCall", Handler: _TestService_EmptyCall_Handler, @@ -358,7 +358,7 @@ var _TestService_serviceDesc = rpc.ServiceDesc{ Handler: _TestService_UnaryCall_Handler, }, }, - Streams: []rpc.StreamDesc{ + Streams: []grpc.StreamDesc{ { StreamName: "StreamingOutputCall", Handler: _TestService_StreamingOutputCall_Handler, diff --git a/rpc_util.go b/rpc_util.go index fa72471ef840..e84d55874460 100644 --- a/rpc_util.go +++ b/rpc_util.go @@ -31,7 +31,7 @@ * */ -package rpc +package grpc import ( "bytes" diff --git a/rpc_util_test.go b/rpc_util_test.go index 6b3603a4b774..4814ba816369 100644 --- a/rpc_util_test.go +++ b/rpc_util_test.go @@ -31,7 +31,7 @@ * */ -package rpc +package grpc import ( "bytes" diff --git a/server.go b/server.go index bac59062a848..fcb3205f0069 100644 --- a/server.go +++ b/server.go @@ -31,7 +31,7 @@ * */ -package rpc +package grpc import ( "fmt" diff --git a/stream.go b/stream.go index d86e10f78081..6932280eefd2 100644 --- a/stream.go +++ b/stream.go @@ -31,7 +31,7 @@ * */ -package rpc +package grpc import ( "io" diff --git a/test/testdata/test_grpc.pb.go b/test/testdata/test_grpc.pb.go index 618aea5ae7a7..5192d299c6c2 100644 --- a/test/testdata/test_grpc.pb.go +++ b/test/testdata/test_grpc.pb.go @@ -35,38 +35,38 @@ package test import ( "fmt" - "io" - "github.com/grpc/grpc-go/rpc" - context "golang.org/x/net/context" proto "github.com/golang/protobuf/proto" + context "golang.org/x/net/context" + "google.golang.org/grpc" + "io" ) type MathClient interface { - Div(ctx context.Context, in *DivArgs, opts ...rpc.CallOption) (*DivReply, error) - DivMany(ctx context.Context, opts ...rpc.CallOption) (Math_DivManyClient, error) - Fib(ctx context.Context, m *FibArgs, opts ...rpc.CallOption) (Math_FibClient, error) - Sum(ctx context.Context, opts ...rpc.CallOption) (Math_SumClient, error) + Div(ctx context.Context, in *DivArgs, opts ...grpc.CallOption) (*DivReply, error) + DivMany(ctx context.Context, opts ...grpc.CallOption) (Math_DivManyClient, error) + Fib(ctx context.Context, m *FibArgs, opts ...grpc.CallOption) (Math_FibClient, error) + Sum(ctx context.Context, opts ...grpc.CallOption) (Math_SumClient, error) } type mathClient struct { - cc *rpc.ClientConn + cc *grpc.ClientConn } -func NewMathClient(cc *rpc.ClientConn) MathClient { +func NewMathClient(cc *grpc.ClientConn) MathClient { return &mathClient{cc} } -func (c *mathClient) Div(ctx context.Context, in *DivArgs, opts ...rpc.CallOption) (*DivReply, error) { +func (c *mathClient) Div(ctx context.Context, in *DivArgs, opts ...grpc.CallOption) (*DivReply, error) { out := new(DivReply) - err := rpc.Invoke(ctx, "/test.Math/Div", in, out, c.cc, opts...) + err := grpc.Invoke(ctx, "/test.Math/Div", in, out, c.cc, opts...) if err != nil { return nil, err } return out, nil } -func (c *mathClient) DivMany(ctx context.Context, opts ...rpc.CallOption) (Math_DivManyClient, error) { - stream, err := rpc.NewClientStream(ctx, c.cc, "/test.Math/DivMany", opts...) +func (c *mathClient) DivMany(ctx context.Context, opts ...grpc.CallOption) (Math_DivManyClient, error) { + stream, err := grpc.NewClientStream(ctx, c.cc, "/test.Math/DivMany", opts...) if err != nil { return nil, err } @@ -76,11 +76,11 @@ func (c *mathClient) DivMany(ctx context.Context, opts ...rpc.CallOption) (Math_ type Math_DivManyClient interface { Send(*DivArgs) error Recv() (*DivReply, error) - rpc.ClientStream + grpc.ClientStream } type mathDivManyClient struct { - rpc.ClientStream + grpc.ClientStream } func (x *mathDivManyClient) Send(m *DivArgs) error { @@ -95,8 +95,8 @@ func (x *mathDivManyClient) Recv() (*DivReply, error) { return m, nil } -func (c *mathClient) Fib(ctx context.Context, m *FibArgs, opts ...rpc.CallOption) (Math_FibClient, error) { - stream, err := rpc.NewClientStream(ctx, c.cc, "/test.Math/Fib", opts...) +func (c *mathClient) Fib(ctx context.Context, m *FibArgs, opts ...grpc.CallOption) (Math_FibClient, error) { + stream, err := grpc.NewClientStream(ctx, c.cc, "/test.Math/Fib", opts...) if err != nil { return nil, err } @@ -112,11 +112,11 @@ func (c *mathClient) Fib(ctx context.Context, m *FibArgs, opts ...rpc.CallOption type Math_FibClient interface { Recv() (*Num, error) - rpc.ClientStream + grpc.ClientStream } type mathFibClient struct { - rpc.ClientStream + grpc.ClientStream } func (x *mathFibClient) Recv() (*Num, error) { @@ -127,8 +127,8 @@ func (x *mathFibClient) Recv() (*Num, error) { return m, nil } -func (c *mathClient) Sum(ctx context.Context, opts ...rpc.CallOption) (Math_SumClient, error) { - stream, err := rpc.NewClientStream(ctx, c.cc, "/test.Math/Sum", opts...) +func (c *mathClient) Sum(ctx context.Context, opts ...grpc.CallOption) (Math_SumClient, error) { + stream, err := grpc.NewClientStream(ctx, c.cc, "/test.Math/Sum", opts...) if err != nil { return nil, err } @@ -138,11 +138,11 @@ func (c *mathClient) Sum(ctx context.Context, opts ...rpc.CallOption) (Math_SumC type Math_SumClient interface { Send(*Num) error CloseAndRecv() (*Num, error) - rpc.ClientStream + grpc.ClientStream } type mathSumClient struct { - rpc.ClientStream + grpc.ClientStream } func (x *mathSumClient) Send(m *Num) error { @@ -165,7 +165,6 @@ func (x *mathSumClient) CloseAndRecv() (*Num, error) { return m, fmt.Errorf("Violate gRPC client streaming protocol: no EOF after the response.") } - type MathServer interface { Div(context.Context, *DivArgs) (*DivReply, error) DivMany(Math_DivManyServer) error @@ -173,7 +172,7 @@ type MathServer interface { Sum(Math_SumServer) error } -func RegisterService(s *rpc.Server, srv MathServer) { +func RegisterService(s *grpc.Server, srv MathServer) { s.RegisterService(&_Math_serviceDesc, srv) } @@ -189,18 +188,18 @@ func _Math_Div_Handler(srv interface{}, ctx context.Context, buf []byte) (proto. return out, nil } -func _Math_DivMany_Handler(srv interface{}, stream rpc.ServerStream) error { +func _Math_DivMany_Handler(srv interface{}, stream grpc.ServerStream) error { return srv.(MathServer).DivMany(&mathDivManyServer{stream}) } type Math_DivManyServer interface { Send(*DivReply) error Recv() (*DivArgs, error) - rpc.ServerStream + grpc.ServerStream } type mathDivManyServer struct { - rpc.ServerStream + grpc.ServerStream } func (x *mathDivManyServer) Send(m *DivReply) error { @@ -215,7 +214,7 @@ func (x *mathDivManyServer) Recv() (*DivArgs, error) { return m, nil } -func _Math_Fib_Handler(srv interface{}, stream rpc.ServerStream) error { +func _Math_Fib_Handler(srv interface{}, stream grpc.ServerStream) error { m := new(FibArgs) if err := stream.RecvProto(m); err != nil { return err @@ -225,29 +224,29 @@ func _Math_Fib_Handler(srv interface{}, stream rpc.ServerStream) error { type Math_FibServer interface { Send(*Num) error - rpc.ServerStream + grpc.ServerStream } type mathFibServer struct { - rpc.ServerStream + grpc.ServerStream } func (x *mathFibServer) Send(m *Num) error { return x.ServerStream.SendProto(m) } -func _Math_Sum_Handler(srv interface{}, stream rpc.ServerStream) error { +func _Math_Sum_Handler(srv interface{}, stream grpc.ServerStream) error { return srv.(MathServer).Sum(&mathSumServer{stream}) } type Math_SumServer interface { SendAndClose(*Num) error Recv() (*Num, error) - rpc.ServerStream + grpc.ServerStream } type mathSumServer struct { - rpc.ServerStream + grpc.ServerStream } func (x *mathSumServer) SendAndClose(m *Num) error { @@ -265,29 +264,27 @@ func (x *mathSumServer) Recv() (*Num, error) { return m, nil } -var _Math_serviceDesc = rpc.ServiceDesc{ +var _Math_serviceDesc = grpc.ServiceDesc{ ServiceName: "test.Math", HandlerType: (*MathServer)(nil), - Methods: []rpc.MethodDesc{ + Methods: []grpc.MethodDesc{ { - MethodName: "Div", - Handler: _Math_Div_Handler, + MethodName: "Div", + Handler: _Math_Div_Handler, }, }, - Streams: []rpc.StreamDesc{ + Streams: []grpc.StreamDesc{ { - StreamName: "DivMany", - Handler: _Math_DivMany_Handler, + StreamName: "DivMany", + Handler: _Math_DivMany_Handler, }, { - StreamName: "Fib", - Handler: _Math_Fib_Handler, + StreamName: "Fib", + Handler: _Math_Fib_Handler, }, { - StreamName: "Sum", - Handler: _Math_Sum_Handler, + StreamName: "Sum", + Handler: _Math_Sum_Handler, }, }, } - -