Merge pull request #29 from dsymonds/master

Switch to new package layout and import path.
This commit is contained in:
Qi Zhao 2015-02-08 17:58:09 -08:00
Родитель 2d82d13c3d e267906c22
Коммит dd172600a0
50 изменённых файлов: 160 добавлений и 160 удалений

Просмотреть файл

@ -2,4 +2,4 @@ gRPC-Go: a Go implementation of gRPC, Google's RPC library
To install this package, you need to install Go 1.4 and setup your Go workspace on your computer. The simplest way to install the library is to run:
go get github.com/grpc/grpc-go/rpc
go get google.golang.org/grpc

Просмотреть файл

@ -31,15 +31,15 @@
*
*/
package rpc
package grpc
import (
"io"
"github.com/golang/protobuf/proto"
"github.com/grpc/grpc-go/rpc/codes"
"github.com/grpc/grpc-go/rpc/metadata"
"github.com/grpc/grpc-go/rpc/transport"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/transport"
"golang.org/x/net/context"
)

Просмотреть файл

@ -31,18 +31,15 @@
*
*/
/*
Package rpc implements various components to perform RPC on top of transport package.
*/
package rpc
package grpc
import (
"fmt"
"sync"
"time"
"github.com/grpc/grpc-go/rpc/credentials"
"github.com/grpc/grpc-go/rpc/transport"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/transport"
"golang.org/x/net/context"
)

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -617,7 +617,7 @@ string GetServices(const google::protobuf::FileDescriptor* file,
"\t\"io\"\n");
}
printer.Print(
"\t\"github.com/google/grpc-go/rpc\"\n"
"\t\"google.golang.org/grpc\"\n"
"\tcontext \"golang.org/x/net/context\"\n"
"\tproto \"github.com/golang/protobuf/proto\"\n"
")\n\n");

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

6
doc.go Normal file
Просмотреть файл

@ -0,0 +1,6 @@
/*
Package grpc implements an RPC system called gRPC.
See https://github.com/grpc/grpc for more information about gRPC.
*/
package grpc

Просмотреть файл

@ -41,10 +41,10 @@ import (
"strconv"
"github.com/golang/protobuf/proto"
"github.com/grpc/grpc-go/rpc"
"github.com/grpc/grpc-go/rpc/credentials"
testpb "github.com/grpc/grpc-go/rpc/interop/testdata"
"golang.org/x/net/context"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
testpb "google.golang.org/grpc/interop/testdata"
)
var (
@ -225,7 +225,7 @@ func doPingPong(tc testpb.TestServiceClient) {
func main() {
flag.Parse()
serverAddr := net.JoinHostPort(*serverHost, strconv.Itoa(*serverPort))
var opts []rpc.DialOption
var opts []grpc.DialOption
if *useTLS {
var sn string
if *tlsServerName != "" {
@ -241,9 +241,9 @@ func main() {
} else {
creds = credentials.NewClientTLSFromCert(nil, sn)
}
opts = append(opts, rpc.WithClientTLS(creds))
opts = append(opts, grpc.WithClientTLS(creds))
}
conn, err := rpc.Dial(serverAddr, opts...)
conn, err := grpc.Dial(serverAddr, opts...)
if err != nil {
log.Fatalf("fail to dial: %v", err)
}

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -42,11 +42,11 @@ import (
"strconv"
"time"
"github.com/grpc/grpc-go/rpc/credentials"
testpb "github.com/grpc/grpc-go/rpc/interop/testdata"
"github.com/grpc/grpc-go/rpc"
"github.com/golang/protobuf/proto"
"golang.org/x/net/context"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
testpb "google.golang.org/grpc/interop/testdata"
)
var (
@ -195,7 +195,7 @@ func main() {
if err != nil {
log.Fatalf("failed to listen: %v", err)
}
server := rpc.NewServer()
server := grpc.NewServer()
testpb.RegisterService(server, &testServer{})
if *useTLS {
creds, err := credentials.NewServerTLSFromFile(*certFile, *keyFile)

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -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,

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -31,7 +31,7 @@
*
*/
package rpc
package grpc
import (
"bytes"
@ -43,9 +43,9 @@ import (
"time"
"github.com/golang/protobuf/proto"
"github.com/grpc/grpc-go/rpc/codes"
"github.com/grpc/grpc-go/rpc/metadata"
"github.com/grpc/grpc-go/rpc/transport"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/transport"
"golang.org/x/net/context"
)

Просмотреть файл

@ -31,7 +31,7 @@
*
*/
package rpc
package grpc
import (
"bytes"
@ -42,8 +42,8 @@ import (
"time"
"github.com/golang/protobuf/proto"
"github.com/grpc/grpc-go/rpc/codes"
"github.com/grpc/grpc-go/rpc/transport"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/transport"
"golang.org/x/net/context"
)

Просмотреть файл

@ -31,7 +31,7 @@
*
*/
package rpc
package grpc
import (
"fmt"
@ -43,9 +43,9 @@ import (
"sync"
"github.com/golang/protobuf/proto"
"github.com/grpc/grpc-go/rpc/codes"
"github.com/grpc/grpc-go/rpc/metadata"
"github.com/grpc/grpc-go/rpc/transport"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/transport"
"golang.org/x/net/context"
)

Просмотреть файл

@ -31,15 +31,15 @@
*
*/
package rpc
package grpc
import (
"io"
"github.com/golang/protobuf/proto"
"github.com/grpc/grpc-go/rpc/codes"
"github.com/grpc/grpc-go/rpc/metadata"
"github.com/grpc/grpc-go/rpc/transport"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/transport"
"golang.org/x/net/context"
)

Просмотреть файл

@ -47,12 +47,12 @@ import (
"time"
"github.com/golang/protobuf/proto"
"github.com/grpc/grpc-go/rpc"
"github.com/grpc/grpc-go/rpc/codes"
"github.com/grpc/grpc-go/rpc/credentials"
"github.com/grpc/grpc-go/rpc/metadata"
testpb "github.com/grpc/grpc-go/rpc/test/testdata"
"golang.org/x/net/context"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/metadata"
testpb "google.golang.org/grpc/test/testdata"
)
var (
@ -68,10 +68,10 @@ type mathServer struct {
func (s *mathServer) Div(ctx context.Context, in *testpb.DivArgs) (*testpb.DivReply, error) {
md, ok := metadata.FromContext(ctx)
if ok {
if err := rpc.SendHeader(ctx, md); err != nil {
log.Fatalf("rpc.SendHeader(%v, %v) = %v, want %v", ctx, md, err, nil)
if err := grpc.SendHeader(ctx, md); err != nil {
log.Fatalf("grpc.SendHeader(%v, %v) = %v, want %v", ctx, md, err, nil)
}
rpc.SetTrailer(ctx, md)
grpc.SetTrailer(ctx, md)
}
n, d := in.GetDividend(), in.GetDivisor()
if d == 0 {
@ -148,7 +148,7 @@ func (s *mathServer) Sum(stream testpb.Math_SumServer) error {
const tlsDir = "testdata/"
func setUp(useTLS bool, maxStream uint32) (s *rpc.Server, mc testpb.MathClient) {
func setUp(useTLS bool, maxStream uint32) (s *grpc.Server, mc testpb.MathClient) {
lis, err := net.Listen("tcp", ":0")
if err != nil {
log.Fatalf("Failed to listen: %v", err)
@ -157,7 +157,7 @@ func setUp(useTLS bool, maxStream uint32) (s *rpc.Server, mc testpb.MathClient)
if err != nil {
log.Fatalf("Failed to parse listener address: %v", err)
}
s = rpc.NewServer(rpc.MaxConcurrentStreams(maxStream))
s = grpc.NewServer(grpc.MaxConcurrentStreams(maxStream))
ms := &mathServer{}
testpb.RegisterService(s, ms)
if useTLS {
@ -170,15 +170,15 @@ func setUp(useTLS bool, maxStream uint32) (s *rpc.Server, mc testpb.MathClient)
go s.Serve(lis)
}
addr := "localhost:" + port
var conn *rpc.ClientConn
var conn *grpc.ClientConn
if useTLS {
creds, err := credentials.NewClientTLSFromFile(tlsDir+"ca.pem", "x.test.youtube.com")
if err != nil {
log.Fatalf("Failed to create credentials %v", err)
}
conn, err = rpc.Dial(addr, rpc.WithClientTLS(creds))
conn, err = grpc.Dial(addr, grpc.WithClientTLS(creds))
} else {
conn, err = rpc.Dial(addr)
conn, err = grpc.Dial(addr)
}
if err != nil {
log.Fatalf("Dial(%q) = %v", addr, err)
@ -194,7 +194,7 @@ func TestFailedRPC(t *testing.T) {
Dividend: proto.Int64(8),
Divisor: proto.Int64(0),
}
expectedErr := rpc.Errorf(codes.Unknown, "math: divide by 0")
expectedErr := grpc.Errorf(codes.Unknown, "math: divide by 0")
reply, rpcErr := mc.Div(context.Background(), args)
if fmt.Sprint(rpcErr) != fmt.Sprint(expectedErr) {
t.Fatalf(`mathClient.Div(_, _) = %v, %v; want <nil>, %v`, reply, rpcErr, expectedErr)
@ -210,7 +210,7 @@ func TestMetadataUnaryRPC(t *testing.T) {
}
ctx := metadata.NewContext(context.Background(), testMetadata)
var header, trailer metadata.MD
_, err := mc.Div(ctx, args, rpc.Header(&header), rpc.Trailer(&trailer))
_, err := mc.Div(ctx, args, grpc.Header(&header), grpc.Trailer(&trailer))
if err != nil {
t.Fatalf("mathClient.Div(%v, _, _, _) = _, %v; want _, <nil>", ctx, err)
}
@ -277,7 +277,7 @@ func TestTimeout(t *testing.T) {
for i := 1; i <= 100; i++ {
ctx, _ := context.WithTimeout(context.Background(), time.Duration(i)*time.Microsecond)
reply, err := mc.Div(ctx, args)
if rpc.Code(err) != codes.DeadlineExceeded {
if grpc.Code(err) != codes.DeadlineExceeded {
t.Fatalf(`mathClient.Div(_, _) = %v, %v; want <nil>, error code: %d`, reply, err, codes.DeadlineExceeded)
}
}
@ -293,7 +293,7 @@ func TestCancel(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
time.AfterFunc(1*time.Millisecond, cancel)
reply, err := mc.Div(ctx, args)
if rpc.Code(err) != codes.Canceled {
if grpc.Code(err) != codes.Canceled {
t.Fatalf(`mathClient.Div(_, _) = %v, %v; want <nil>, error code: %d`, reply, err, codes.Canceled)
}
}
@ -311,7 +311,7 @@ func TestBidiStreaming(t *testing.T) {
status error
}{
{[]string{"1/1", "3/2", "2/3", "1/2"}, io.EOF},
{[]string{"2/5", "2/3", "3/0", "5/4"}, rpc.Errorf(codes.Unknown, "math: divide by 0")},
{[]string{"2/5", "2/3", "3/0", "5/4"}, grpc.Errorf(codes.Unknown, "math: divide by 0")},
} {
stream, err := mc.DivMany(context.Background())
if err != nil {
@ -460,7 +460,7 @@ func TestExceedMaxStreamsLimit(t *testing.T) {
break
}
}
if rpc.Code(err) != codes.Unavailable {
if grpc.Code(err) != codes.Unavailable {
t.Fatalf("got %v, want error code %d", err, codes.Unavailable)
}
}

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -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,
},
},
}

Просмотреть файл

Просмотреть файл

@ -44,9 +44,9 @@ import (
"github.com/bradfitz/http2"
"github.com/bradfitz/http2/hpack"
"github.com/grpc/grpc-go/rpc/codes"
"github.com/grpc/grpc-go/rpc/credentials"
"github.com/grpc/grpc-go/rpc/metadata"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/metadata"
"golang.org/x/net/context"
)

Просмотреть файл

@ -45,8 +45,8 @@ import (
"github.com/bradfitz/http2"
"github.com/bradfitz/http2/hpack"
"github.com/grpc/grpc-go/rpc/codes"
"github.com/grpc/grpc-go/rpc/metadata"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/metadata"
"golang.org/x/net/context"
)

Просмотреть файл

@ -41,8 +41,8 @@ import (
"github.com/bradfitz/http2"
"github.com/bradfitz/http2/hpack"
"github.com/grpc/grpc-go/rpc/codes"
"github.com/grpc/grpc-go/rpc/metadata"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/metadata"
)
const (

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -44,9 +44,9 @@ import (
"net"
"sync"
"github.com/grpc/grpc-go/rpc/codes"
"github.com/grpc/grpc-go/rpc/credentials"
"github.com/grpc/grpc-go/rpc/metadata"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/metadata"
"golang.org/x/net/context"
)

Просмотреть файл

@ -45,8 +45,8 @@ import (
"testing"
"time"
"github.com/grpc/grpc-go/rpc/codes"
"github.com/grpc/grpc-go/rpc/credentials"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/credentials"
"golang.org/x/net/context"
)