|
|
@@ -19,6 +19,11 @@ import proto "github.com/golang/protobuf/proto"
|
|
|
import fmt "fmt"
|
|
|
import math "math"
|
|
|
|
|
|
+import (
|
|
|
+ context "golang.org/x/net/context"
|
|
|
+ grpc "google.golang.org/grpc"
|
|
|
+)
|
|
|
+
|
|
|
// Reference imports to suppress errors if they are not otherwise used.
|
|
|
var _ = proto.Marshal
|
|
|
var _ = fmt.Errorf
|
|
|
@@ -149,6 +154,277 @@ func init() {
|
|
|
proto.RegisterType((*StreamMsg2)(nil), "grpc.testing.StreamMsg2")
|
|
|
}
|
|
|
|
|
|
+// Reference imports to suppress errors if they are not otherwise used.
|
|
|
+var _ context.Context
|
|
|
+var _ grpc.ClientConn
|
|
|
+
|
|
|
+// This is a compile-time assertion to ensure that this generated file
|
|
|
+// is compatible with the grpc package it is being compiled against.
|
|
|
+const _ = grpc.SupportPackageIsVersion4
|
|
|
+
|
|
|
+// Client API for Test service
|
|
|
+
|
|
|
+type TestClient interface {
|
|
|
+ UnaryCall(ctx context.Context, in *SimpleRequest, opts ...grpc.CallOption) (*SimpleResponse, error)
|
|
|
+ // This RPC streams from the server only.
|
|
|
+ Downstream(ctx context.Context, in *SimpleRequest, opts ...grpc.CallOption) (Test_DownstreamClient, error)
|
|
|
+ // This RPC streams from the client.
|
|
|
+ Upstream(ctx context.Context, opts ...grpc.CallOption) (Test_UpstreamClient, error)
|
|
|
+ // This one streams in both directions.
|
|
|
+ Bidi(ctx context.Context, opts ...grpc.CallOption) (Test_BidiClient, error)
|
|
|
+}
|
|
|
+
|
|
|
+type testClient struct {
|
|
|
+ cc *grpc.ClientConn
|
|
|
+}
|
|
|
+
|
|
|
+func NewTestClient(cc *grpc.ClientConn) TestClient {
|
|
|
+ return &testClient{cc}
|
|
|
+}
|
|
|
+
|
|
|
+func (c *testClient) UnaryCall(ctx context.Context, in *SimpleRequest, opts ...grpc.CallOption) (*SimpleResponse, error) {
|
|
|
+ out := new(SimpleResponse)
|
|
|
+ err := grpc.Invoke(ctx, "/grpc.testing.Test/UnaryCall", in, out, c.cc, opts...)
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ return out, nil
|
|
|
+}
|
|
|
+
|
|
|
+func (c *testClient) Downstream(ctx context.Context, in *SimpleRequest, opts ...grpc.CallOption) (Test_DownstreamClient, error) {
|
|
|
+ stream, err := grpc.NewClientStream(ctx, &_Test_serviceDesc.Streams[0], c.cc, "/grpc.testing.Test/Downstream", opts...)
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ x := &testDownstreamClient{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 Test_DownstreamClient interface {
|
|
|
+ Recv() (*StreamMsg, error)
|
|
|
+ grpc.ClientStream
|
|
|
+}
|
|
|
+
|
|
|
+type testDownstreamClient struct {
|
|
|
+ grpc.ClientStream
|
|
|
+}
|
|
|
+
|
|
|
+func (x *testDownstreamClient) Recv() (*StreamMsg, error) {
|
|
|
+ m := new(StreamMsg)
|
|
|
+ if err := x.ClientStream.RecvMsg(m); err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ return m, nil
|
|
|
+}
|
|
|
+
|
|
|
+func (c *testClient) Upstream(ctx context.Context, opts ...grpc.CallOption) (Test_UpstreamClient, error) {
|
|
|
+ stream, err := grpc.NewClientStream(ctx, &_Test_serviceDesc.Streams[1], c.cc, "/grpc.testing.Test/Upstream", opts...)
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ x := &testUpstreamClient{stream}
|
|
|
+ return x, nil
|
|
|
+}
|
|
|
+
|
|
|
+type Test_UpstreamClient interface {
|
|
|
+ Send(*StreamMsg) error
|
|
|
+ CloseAndRecv() (*SimpleResponse, error)
|
|
|
+ grpc.ClientStream
|
|
|
+}
|
|
|
+
|
|
|
+type testUpstreamClient struct {
|
|
|
+ grpc.ClientStream
|
|
|
+}
|
|
|
+
|
|
|
+func (x *testUpstreamClient) Send(m *StreamMsg) error {
|
|
|
+ return x.ClientStream.SendMsg(m)
|
|
|
+}
|
|
|
+
|
|
|
+func (x *testUpstreamClient) CloseAndRecv() (*SimpleResponse, error) {
|
|
|
+ if err := x.ClientStream.CloseSend(); err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ m := new(SimpleResponse)
|
|
|
+ if err := x.ClientStream.RecvMsg(m); err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ return m, nil
|
|
|
+}
|
|
|
+
|
|
|
+func (c *testClient) Bidi(ctx context.Context, opts ...grpc.CallOption) (Test_BidiClient, error) {
|
|
|
+ stream, err := grpc.NewClientStream(ctx, &_Test_serviceDesc.Streams[2], c.cc, "/grpc.testing.Test/Bidi", opts...)
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ x := &testBidiClient{stream}
|
|
|
+ return x, nil
|
|
|
+}
|
|
|
+
|
|
|
+type Test_BidiClient interface {
|
|
|
+ Send(*StreamMsg) error
|
|
|
+ Recv() (*StreamMsg2, error)
|
|
|
+ grpc.ClientStream
|
|
|
+}
|
|
|
+
|
|
|
+type testBidiClient struct {
|
|
|
+ grpc.ClientStream
|
|
|
+}
|
|
|
+
|
|
|
+func (x *testBidiClient) Send(m *StreamMsg) error {
|
|
|
+ return x.ClientStream.SendMsg(m)
|
|
|
+}
|
|
|
+
|
|
|
+func (x *testBidiClient) Recv() (*StreamMsg2, error) {
|
|
|
+ m := new(StreamMsg2)
|
|
|
+ if err := x.ClientStream.RecvMsg(m); err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ return m, nil
|
|
|
+}
|
|
|
+
|
|
|
+// Server API for Test service
|
|
|
+
|
|
|
+type TestServer interface {
|
|
|
+ UnaryCall(context.Context, *SimpleRequest) (*SimpleResponse, error)
|
|
|
+ // This RPC streams from the server only.
|
|
|
+ Downstream(*SimpleRequest, Test_DownstreamServer) error
|
|
|
+ // This RPC streams from the client.
|
|
|
+ Upstream(Test_UpstreamServer) error
|
|
|
+ // This one streams in both directions.
|
|
|
+ Bidi(Test_BidiServer) error
|
|
|
+}
|
|
|
+
|
|
|
+func RegisterTestServer(s *grpc.Server, srv TestServer) {
|
|
|
+ s.RegisterService(&_Test_serviceDesc, srv)
|
|
|
+}
|
|
|
+
|
|
|
+func _Test_UnaryCall_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
|
|
+ in := new(SimpleRequest)
|
|
|
+ if err := dec(in); err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ if interceptor == nil {
|
|
|
+ return srv.(TestServer).UnaryCall(ctx, in)
|
|
|
+ }
|
|
|
+ info := &grpc.UnaryServerInfo{
|
|
|
+ Server: srv,
|
|
|
+ FullMethod: "/grpc.testing.Test/UnaryCall",
|
|
|
+ }
|
|
|
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
|
+ return srv.(TestServer).UnaryCall(ctx, req.(*SimpleRequest))
|
|
|
+ }
|
|
|
+ return interceptor(ctx, in, info, handler)
|
|
|
+}
|
|
|
+
|
|
|
+func _Test_Downstream_Handler(srv interface{}, stream grpc.ServerStream) error {
|
|
|
+ m := new(SimpleRequest)
|
|
|
+ if err := stream.RecvMsg(m); err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ return srv.(TestServer).Downstream(m, &testDownstreamServer{stream})
|
|
|
+}
|
|
|
+
|
|
|
+type Test_DownstreamServer interface {
|
|
|
+ Send(*StreamMsg) error
|
|
|
+ grpc.ServerStream
|
|
|
+}
|
|
|
+
|
|
|
+type testDownstreamServer struct {
|
|
|
+ grpc.ServerStream
|
|
|
+}
|
|
|
+
|
|
|
+func (x *testDownstreamServer) Send(m *StreamMsg) error {
|
|
|
+ return x.ServerStream.SendMsg(m)
|
|
|
+}
|
|
|
+
|
|
|
+func _Test_Upstream_Handler(srv interface{}, stream grpc.ServerStream) error {
|
|
|
+ return srv.(TestServer).Upstream(&testUpstreamServer{stream})
|
|
|
+}
|
|
|
+
|
|
|
+type Test_UpstreamServer interface {
|
|
|
+ SendAndClose(*SimpleResponse) error
|
|
|
+ Recv() (*StreamMsg, error)
|
|
|
+ grpc.ServerStream
|
|
|
+}
|
|
|
+
|
|
|
+type testUpstreamServer struct {
|
|
|
+ grpc.ServerStream
|
|
|
+}
|
|
|
+
|
|
|
+func (x *testUpstreamServer) SendAndClose(m *SimpleResponse) error {
|
|
|
+ return x.ServerStream.SendMsg(m)
|
|
|
+}
|
|
|
+
|
|
|
+func (x *testUpstreamServer) Recv() (*StreamMsg, error) {
|
|
|
+ m := new(StreamMsg)
|
|
|
+ if err := x.ServerStream.RecvMsg(m); err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ return m, nil
|
|
|
+}
|
|
|
+
|
|
|
+func _Test_Bidi_Handler(srv interface{}, stream grpc.ServerStream) error {
|
|
|
+ return srv.(TestServer).Bidi(&testBidiServer{stream})
|
|
|
+}
|
|
|
+
|
|
|
+type Test_BidiServer interface {
|
|
|
+ Send(*StreamMsg2) error
|
|
|
+ Recv() (*StreamMsg, error)
|
|
|
+ grpc.ServerStream
|
|
|
+}
|
|
|
+
|
|
|
+type testBidiServer struct {
|
|
|
+ grpc.ServerStream
|
|
|
+}
|
|
|
+
|
|
|
+func (x *testBidiServer) Send(m *StreamMsg2) error {
|
|
|
+ return x.ServerStream.SendMsg(m)
|
|
|
+}
|
|
|
+
|
|
|
+func (x *testBidiServer) Recv() (*StreamMsg, error) {
|
|
|
+ m := new(StreamMsg)
|
|
|
+ if err := x.ServerStream.RecvMsg(m); err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ return m, nil
|
|
|
+}
|
|
|
+
|
|
|
+var _Test_serviceDesc = grpc.ServiceDesc{
|
|
|
+ ServiceName: "grpc.testing.Test",
|
|
|
+ HandlerType: (*TestServer)(nil),
|
|
|
+ Methods: []grpc.MethodDesc{
|
|
|
+ {
|
|
|
+ MethodName: "UnaryCall",
|
|
|
+ Handler: _Test_UnaryCall_Handler,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ Streams: []grpc.StreamDesc{
|
|
|
+ {
|
|
|
+ StreamName: "Downstream",
|
|
|
+ Handler: _Test_Downstream_Handler,
|
|
|
+ ServerStreams: true,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ StreamName: "Upstream",
|
|
|
+ Handler: _Test_Upstream_Handler,
|
|
|
+ ClientStreams: true,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ StreamName: "Bidi",
|
|
|
+ Handler: _Test_Bidi_Handler,
|
|
|
+ ServerStreams: true,
|
|
|
+ ClientStreams: true,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ Metadata: "grpc/grpc.proto",
|
|
|
+}
|
|
|
+
|
|
|
func init() { proto.RegisterFile("grpc/grpc.proto", fileDescriptor0) }
|
|
|
|
|
|
var fileDescriptor0 = []byte{
|