protobuf-go/internal/testprotos/test/test_grpc.pb.go
Joe Tsai 19058431cd internal/cmd/generate-protos: initial commit
Create a single binary for handling generation of protos.
This replaces previous logic spread throughout the repo in:
* regenerate.bash
* cmd/protoc-gen-go/golden_test.go
* cmd/protoc-gen-go-grpc/golden_test.go
* (indirectly) internal/protogen/goldentest

One of the problems with the former approaches is that they relied on
a version of protoc that was specific to a developer's workstation.
This meant that the result of generation was not hermetic.
To address this, we rely on the hard-coded version of protobuf specified
in the test.bash script.

A summary of changes in this CL are:
* The internal_gengo.GenerateFile and internal_gengogrpc.GenerateFile
functions are unified to have consistent signatures. It seems that the
former accepted a *protogen.GeneratedFile to support v1 where gRPC code
was generated into the same file as the base .pb.go file. However, the
same functionality can be achieved by having the function return
the generated file object.
* The test.bash script patches the protobuf toolchain to have properly
specified go_package options in each proto source file.
* The test.bash script accepts a "-regenerate" argument.
* Add generation for the well-known types. Contrary to how these were
laid out in the v1 repo, all the well-known types are placed in the
same Go package.
* Add generation for the conformance proto.
* Remove regenerate.bash
* Remove internal/protogen
* Remove cmd/protoc-gen-go/golden_test.go
* Remove cmd/protoc-gen-go-grpc/golden_test.go
* Add cmd/protoc-gen-go/annotation_test.go

Change-Id: I4a1a97ae6f66e2fabcf4e4d292c95ab2a2db0248
Reviewed-on: https://go-review.googlesource.com/c/164477
Reviewed-by: Damien Neil <dneil@google.com>
2019-03-01 20:47:52 +00:00

218 lines
6.5 KiB
Go

// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
package test
import (
context "context"
grpc "google.golang.org/grpc"
)
// 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
// TestServiceClient is the client API for TestService service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type TestServiceClient interface {
Foo(ctx context.Context, in *FooRequest, opts ...grpc.CallOption) (*FooResponse, error)
TestStream(ctx context.Context, opts ...grpc.CallOption) (TestService_TestStreamClient, error)
}
type testServiceClient struct {
cc *grpc.ClientConn
}
func NewTestServiceClient(cc *grpc.ClientConn) TestServiceClient {
return &testServiceClient{cc}
}
func (c *testServiceClient) Foo(ctx context.Context, in *FooRequest, opts ...grpc.CallOption) (*FooResponse, error) {
out := new(FooResponse)
err := c.cc.Invoke(ctx, "/goproto.proto.test.TestService/Foo", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *testServiceClient) TestStream(ctx context.Context, opts ...grpc.CallOption) (TestService_TestStreamClient, error) {
stream, err := c.cc.NewStream(ctx, &_TestService_serviceDesc.Streams[0], "/goproto.proto.test.TestService/TestStream", opts...)
if err != nil {
return nil, err
}
x := &testServiceTestStreamClient{stream}
return x, nil
}
type TestService_TestStreamClient interface {
Send(*FooRequest) error
Recv() (*FooResponse, error)
grpc.ClientStream
}
type testServiceTestStreamClient struct {
grpc.ClientStream
}
func (x *testServiceTestStreamClient) Send(m *FooRequest) error {
return x.ClientStream.SendMsg(m)
}
func (x *testServiceTestStreamClient) Recv() (*FooResponse, error) {
m := new(FooResponse)
if err := x.ClientStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
// TestServiceServer is the server API for TestService service.
type TestServiceServer interface {
Foo(context.Context, *FooRequest) (*FooResponse, error)
TestStream(TestService_TestStreamServer) error
}
func RegisterTestServiceServer(s *grpc.Server, srv TestServiceServer) {
s.RegisterService(&_TestService_serviceDesc, srv)
}
func _TestService_Foo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(FooRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(TestServiceServer).Foo(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/goproto.proto.test.TestService/Foo",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(TestServiceServer).Foo(ctx, req.(*FooRequest))
}
return interceptor(ctx, in, info, handler)
}
func _TestService_TestStream_Handler(srv interface{}, stream grpc.ServerStream) error {
return srv.(TestServiceServer).TestStream(&testServiceTestStreamServer{stream})
}
type TestService_TestStreamServer interface {
Send(*FooResponse) error
Recv() (*FooRequest, error)
grpc.ServerStream
}
type testServiceTestStreamServer struct {
grpc.ServerStream
}
func (x *testServiceTestStreamServer) Send(m *FooResponse) error {
return x.ServerStream.SendMsg(m)
}
func (x *testServiceTestStreamServer) Recv() (*FooRequest, error) {
m := new(FooRequest)
if err := x.ServerStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
var _TestService_serviceDesc = grpc.ServiceDesc{
ServiceName: "goproto.proto.test.TestService",
HandlerType: (*TestServiceServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Foo",
Handler: _TestService_Foo_Handler,
},
},
Streams: []grpc.StreamDesc{
{
StreamName: "TestStream",
Handler: _TestService_TestStream_Handler,
ServerStreams: true,
ClientStreams: true,
},
},
Metadata: "test/test.proto",
}
// TestDeprecatedServiceClient is the client API for TestDeprecatedService service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
//
// Deprecated: Do not use.
type TestDeprecatedServiceClient interface {
Deprecated(ctx context.Context, in *TestDeprecatedMessage, opts ...grpc.CallOption) (*TestDeprecatedMessage, error)
}
type testDeprecatedServiceClient struct {
cc *grpc.ClientConn
}
// Deprecated: Do not use.
func NewTestDeprecatedServiceClient(cc *grpc.ClientConn) TestDeprecatedServiceClient {
return &testDeprecatedServiceClient{cc}
}
// Deprecated: Do not use.
func (c *testDeprecatedServiceClient) Deprecated(ctx context.Context, in *TestDeprecatedMessage, opts ...grpc.CallOption) (*TestDeprecatedMessage, error) {
out := new(TestDeprecatedMessage)
err := c.cc.Invoke(ctx, "/goproto.proto.test.TestDeprecatedService/Deprecated", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// TestDeprecatedServiceServer is the server API for TestDeprecatedService service.
//
// Deprecated: Do not use.
type TestDeprecatedServiceServer interface {
Deprecated(context.Context, *TestDeprecatedMessage) (*TestDeprecatedMessage, error)
}
// Deprecated: Do not use.
func RegisterTestDeprecatedServiceServer(s *grpc.Server, srv TestDeprecatedServiceServer) {
s.RegisterService(&_TestDeprecatedService_serviceDesc, srv)
}
func _TestDeprecatedService_Deprecated_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(TestDeprecatedMessage)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(TestDeprecatedServiceServer).Deprecated(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/goproto.proto.test.TestDeprecatedService/Deprecated",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(TestDeprecatedServiceServer).Deprecated(ctx, req.(*TestDeprecatedMessage))
}
return interceptor(ctx, in, info, handler)
}
var _TestDeprecatedService_serviceDesc = grpc.ServiceDesc{
ServiceName: "goproto.proto.test.TestDeprecatedService",
HandlerType: (*TestDeprecatedServiceServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Deprecated",
Handler: _TestDeprecatedService_Deprecated_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "test/test.proto",
}