mirror of https://github.com/grpc/grpc-go.git
cmd/protoc-gen-go-grpc: call interceptor even if handler is unset (#3849)
This commit is contained in:
parent
cc8e63cae1
commit
d31b671000
|
@ -22,21 +22,24 @@ type LoadBalancerService struct {
|
|||
}
|
||||
|
||||
func (s *LoadBalancerService) balanceLoad(_ interface{}, stream grpc.ServerStream) error {
|
||||
if s.BalanceLoad == nil {
|
||||
return status.Errorf(codes.Unimplemented, "method BalanceLoad not implemented")
|
||||
}
|
||||
return s.BalanceLoad(&loadBalancerBalanceLoadServer{stream})
|
||||
}
|
||||
|
||||
// RegisterLoadBalancerService registers a service implementation with a gRPC server.
|
||||
func RegisterLoadBalancerService(s grpc.ServiceRegistrar, srv *LoadBalancerService) {
|
||||
srvCopy := *srv
|
||||
if srvCopy.BalanceLoad == nil {
|
||||
srvCopy.BalanceLoad = func(LoadBalancer_BalanceLoadServer) error {
|
||||
return status.Errorf(codes.Unimplemented, "method BalanceLoad not implemented")
|
||||
}
|
||||
}
|
||||
sd := grpc.ServiceDesc{
|
||||
ServiceName: "grpc.lb.v1.LoadBalancer",
|
||||
Methods: []grpc.MethodDesc{},
|
||||
Streams: []grpc.StreamDesc{
|
||||
{
|
||||
StreamName: "BalanceLoad",
|
||||
Handler: srv.balanceLoad,
|
||||
Handler: srvCopy.balanceLoad,
|
||||
ServerStreams: true,
|
||||
ClientStreams: true,
|
||||
},
|
||||
|
|
|
@ -23,9 +23,6 @@ type RouteLookupServiceService struct {
|
|||
}
|
||||
|
||||
func (s *RouteLookupServiceService) routeLookup(_ interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
if s.RouteLookup == nil {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method RouteLookup not implemented")
|
||||
}
|
||||
in := new(RouteLookupRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
|
@ -45,12 +42,18 @@ func (s *RouteLookupServiceService) routeLookup(_ interface{}, ctx context.Conte
|
|||
|
||||
// RegisterRouteLookupServiceService registers a service implementation with a gRPC server.
|
||||
func RegisterRouteLookupServiceService(s grpc.ServiceRegistrar, srv *RouteLookupServiceService) {
|
||||
srvCopy := *srv
|
||||
if srvCopy.RouteLookup == nil {
|
||||
srvCopy.RouteLookup = func(context.Context, *RouteLookupRequest) (*RouteLookupResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method RouteLookup not implemented")
|
||||
}
|
||||
}
|
||||
sd := grpc.ServiceDesc{
|
||||
ServiceName: "grpc.lookup.v1.RouteLookupService",
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "RouteLookup",
|
||||
Handler: srv.routeLookup,
|
||||
Handler: srvCopy.routeLookup,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
|
|
|
@ -140,9 +140,6 @@ type BenchmarkServiceService struct {
|
|||
}
|
||||
|
||||
func (s *BenchmarkServiceService) unaryCall(_ interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
if s.UnaryCall == nil {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method UnaryCall not implemented")
|
||||
}
|
||||
in := new(SimpleRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
|
@ -160,15 +157,9 @@ func (s *BenchmarkServiceService) unaryCall(_ interface{}, ctx context.Context,
|
|||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
func (s *BenchmarkServiceService) streamingCall(_ interface{}, stream grpc.ServerStream) error {
|
||||
if s.StreamingCall == nil {
|
||||
return status.Errorf(codes.Unimplemented, "method StreamingCall not implemented")
|
||||
}
|
||||
return s.StreamingCall(&benchmarkServiceStreamingCallServer{stream})
|
||||
}
|
||||
func (s *BenchmarkServiceService) unconstrainedStreamingCall(_ interface{}, stream grpc.ServerStream) error {
|
||||
if s.UnconstrainedStreamingCall == nil {
|
||||
return status.Errorf(codes.Unimplemented, "method UnconstrainedStreamingCall not implemented")
|
||||
}
|
||||
return s.UnconstrainedStreamingCall(&benchmarkServiceUnconstrainedStreamingCallServer{stream})
|
||||
}
|
||||
|
||||
|
@ -218,24 +209,40 @@ func (x *benchmarkServiceUnconstrainedStreamingCallServer) Recv() (*SimpleReques
|
|||
|
||||
// RegisterBenchmarkServiceService registers a service implementation with a gRPC server.
|
||||
func RegisterBenchmarkServiceService(s grpc.ServiceRegistrar, srv *BenchmarkServiceService) {
|
||||
srvCopy := *srv
|
||||
if srvCopy.UnaryCall == nil {
|
||||
srvCopy.UnaryCall = func(context.Context, *SimpleRequest) (*SimpleResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method UnaryCall not implemented")
|
||||
}
|
||||
}
|
||||
if srvCopy.StreamingCall == nil {
|
||||
srvCopy.StreamingCall = func(BenchmarkService_StreamingCallServer) error {
|
||||
return status.Errorf(codes.Unimplemented, "method StreamingCall not implemented")
|
||||
}
|
||||
}
|
||||
if srvCopy.UnconstrainedStreamingCall == nil {
|
||||
srvCopy.UnconstrainedStreamingCall = func(BenchmarkService_UnconstrainedStreamingCallServer) error {
|
||||
return status.Errorf(codes.Unimplemented, "method UnconstrainedStreamingCall not implemented")
|
||||
}
|
||||
}
|
||||
sd := grpc.ServiceDesc{
|
||||
ServiceName: "grpc.testing.BenchmarkService",
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "UnaryCall",
|
||||
Handler: srv.unaryCall,
|
||||
Handler: srvCopy.unaryCall,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{
|
||||
{
|
||||
StreamName: "StreamingCall",
|
||||
Handler: srv.streamingCall,
|
||||
Handler: srvCopy.streamingCall,
|
||||
ServerStreams: true,
|
||||
ClientStreams: true,
|
||||
},
|
||||
{
|
||||
StreamName: "UnconstrainedStreamingCall",
|
||||
Handler: srv.unconstrainedStreamingCall,
|
||||
Handler: srvCopy.unconstrainedStreamingCall,
|
||||
ServerStreams: true,
|
||||
ClientStreams: true,
|
||||
},
|
||||
|
@ -446,21 +453,12 @@ type WorkerServiceService struct {
|
|||
}
|
||||
|
||||
func (s *WorkerServiceService) runServer(_ interface{}, stream grpc.ServerStream) error {
|
||||
if s.RunServer == nil {
|
||||
return status.Errorf(codes.Unimplemented, "method RunServer not implemented")
|
||||
}
|
||||
return s.RunServer(&workerServiceRunServerServer{stream})
|
||||
}
|
||||
func (s *WorkerServiceService) runClient(_ interface{}, stream grpc.ServerStream) error {
|
||||
if s.RunClient == nil {
|
||||
return status.Errorf(codes.Unimplemented, "method RunClient not implemented")
|
||||
}
|
||||
return s.RunClient(&workerServiceRunClientServer{stream})
|
||||
}
|
||||
func (s *WorkerServiceService) coreCount(_ interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
if s.CoreCount == nil {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method CoreCount not implemented")
|
||||
}
|
||||
in := new(CoreRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
|
@ -478,9 +476,6 @@ func (s *WorkerServiceService) coreCount(_ interface{}, ctx context.Context, dec
|
|||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
func (s *WorkerServiceService) quitWorker(_ interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
if s.QuitWorker == nil {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method QuitWorker not implemented")
|
||||
}
|
||||
in := new(Void)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
|
@ -544,28 +539,49 @@ func (x *workerServiceRunClientServer) Recv() (*ClientArgs, error) {
|
|||
|
||||
// RegisterWorkerServiceService registers a service implementation with a gRPC server.
|
||||
func RegisterWorkerServiceService(s grpc.ServiceRegistrar, srv *WorkerServiceService) {
|
||||
srvCopy := *srv
|
||||
if srvCopy.RunServer == nil {
|
||||
srvCopy.RunServer = func(WorkerService_RunServerServer) error {
|
||||
return status.Errorf(codes.Unimplemented, "method RunServer not implemented")
|
||||
}
|
||||
}
|
||||
if srvCopy.RunClient == nil {
|
||||
srvCopy.RunClient = func(WorkerService_RunClientServer) error {
|
||||
return status.Errorf(codes.Unimplemented, "method RunClient not implemented")
|
||||
}
|
||||
}
|
||||
if srvCopy.CoreCount == nil {
|
||||
srvCopy.CoreCount = func(context.Context, *CoreRequest) (*CoreResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method CoreCount not implemented")
|
||||
}
|
||||
}
|
||||
if srvCopy.QuitWorker == nil {
|
||||
srvCopy.QuitWorker = func(context.Context, *Void) (*Void, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method QuitWorker not implemented")
|
||||
}
|
||||
}
|
||||
sd := grpc.ServiceDesc{
|
||||
ServiceName: "grpc.testing.WorkerService",
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "CoreCount",
|
||||
Handler: srv.coreCount,
|
||||
Handler: srvCopy.coreCount,
|
||||
},
|
||||
{
|
||||
MethodName: "QuitWorker",
|
||||
Handler: srv.quitWorker,
|
||||
Handler: srvCopy.quitWorker,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{
|
||||
{
|
||||
StreamName: "RunServer",
|
||||
Handler: srv.runServer,
|
||||
Handler: srvCopy.runServer,
|
||||
ServerStreams: true,
|
||||
ClientStreams: true,
|
||||
},
|
||||
{
|
||||
StreamName: "RunClient",
|
||||
Handler: srv.runClient,
|
||||
Handler: srvCopy.runClient,
|
||||
ServerStreams: true,
|
||||
ClientStreams: true,
|
||||
},
|
||||
|
|
|
@ -36,9 +36,6 @@ type ChannelzService struct {
|
|||
}
|
||||
|
||||
func (s *ChannelzService) getTopChannels(_ interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
if s.GetTopChannels == nil {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetTopChannels not implemented")
|
||||
}
|
||||
in := new(GetTopChannelsRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
|
@ -56,9 +53,6 @@ func (s *ChannelzService) getTopChannels(_ interface{}, ctx context.Context, dec
|
|||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
func (s *ChannelzService) getServers(_ interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
if s.GetServers == nil {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetServers not implemented")
|
||||
}
|
||||
in := new(GetServersRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
|
@ -76,9 +70,6 @@ func (s *ChannelzService) getServers(_ interface{}, ctx context.Context, dec fun
|
|||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
func (s *ChannelzService) getServer(_ interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
if s.GetServer == nil {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetServer not implemented")
|
||||
}
|
||||
in := new(GetServerRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
|
@ -96,9 +87,6 @@ func (s *ChannelzService) getServer(_ interface{}, ctx context.Context, dec func
|
|||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
func (s *ChannelzService) getServerSockets(_ interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
if s.GetServerSockets == nil {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetServerSockets not implemented")
|
||||
}
|
||||
in := new(GetServerSocketsRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
|
@ -116,9 +104,6 @@ func (s *ChannelzService) getServerSockets(_ interface{}, ctx context.Context, d
|
|||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
func (s *ChannelzService) getChannel(_ interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
if s.GetChannel == nil {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetChannel not implemented")
|
||||
}
|
||||
in := new(GetChannelRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
|
@ -136,9 +121,6 @@ func (s *ChannelzService) getChannel(_ interface{}, ctx context.Context, dec fun
|
|||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
func (s *ChannelzService) getSubchannel(_ interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
if s.GetSubchannel == nil {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetSubchannel not implemented")
|
||||
}
|
||||
in := new(GetSubchannelRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
|
@ -156,9 +138,6 @@ func (s *ChannelzService) getSubchannel(_ interface{}, ctx context.Context, dec
|
|||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
func (s *ChannelzService) getSocket(_ interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
if s.GetSocket == nil {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetSocket not implemented")
|
||||
}
|
||||
in := new(GetSocketRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
|
@ -178,36 +157,72 @@ func (s *ChannelzService) getSocket(_ interface{}, ctx context.Context, dec func
|
|||
|
||||
// RegisterChannelzService registers a service implementation with a gRPC server.
|
||||
func RegisterChannelzService(s grpc.ServiceRegistrar, srv *ChannelzService) {
|
||||
srvCopy := *srv
|
||||
if srvCopy.GetTopChannels == nil {
|
||||
srvCopy.GetTopChannels = func(context.Context, *GetTopChannelsRequest) (*GetTopChannelsResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetTopChannels not implemented")
|
||||
}
|
||||
}
|
||||
if srvCopy.GetServers == nil {
|
||||
srvCopy.GetServers = func(context.Context, *GetServersRequest) (*GetServersResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetServers not implemented")
|
||||
}
|
||||
}
|
||||
if srvCopy.GetServer == nil {
|
||||
srvCopy.GetServer = func(context.Context, *GetServerRequest) (*GetServerResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetServer not implemented")
|
||||
}
|
||||
}
|
||||
if srvCopy.GetServerSockets == nil {
|
||||
srvCopy.GetServerSockets = func(context.Context, *GetServerSocketsRequest) (*GetServerSocketsResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetServerSockets not implemented")
|
||||
}
|
||||
}
|
||||
if srvCopy.GetChannel == nil {
|
||||
srvCopy.GetChannel = func(context.Context, *GetChannelRequest) (*GetChannelResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetChannel not implemented")
|
||||
}
|
||||
}
|
||||
if srvCopy.GetSubchannel == nil {
|
||||
srvCopy.GetSubchannel = func(context.Context, *GetSubchannelRequest) (*GetSubchannelResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetSubchannel not implemented")
|
||||
}
|
||||
}
|
||||
if srvCopy.GetSocket == nil {
|
||||
srvCopy.GetSocket = func(context.Context, *GetSocketRequest) (*GetSocketResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetSocket not implemented")
|
||||
}
|
||||
}
|
||||
sd := grpc.ServiceDesc{
|
||||
ServiceName: "grpc.channelz.v1.Channelz",
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "GetTopChannels",
|
||||
Handler: srv.getTopChannels,
|
||||
Handler: srvCopy.getTopChannels,
|
||||
},
|
||||
{
|
||||
MethodName: "GetServers",
|
||||
Handler: srv.getServers,
|
||||
Handler: srvCopy.getServers,
|
||||
},
|
||||
{
|
||||
MethodName: "GetServer",
|
||||
Handler: srv.getServer,
|
||||
Handler: srvCopy.getServer,
|
||||
},
|
||||
{
|
||||
MethodName: "GetServerSockets",
|
||||
Handler: srv.getServerSockets,
|
||||
Handler: srvCopy.getServerSockets,
|
||||
},
|
||||
{
|
||||
MethodName: "GetChannel",
|
||||
Handler: srv.getChannel,
|
||||
Handler: srvCopy.getChannel,
|
||||
},
|
||||
{
|
||||
MethodName: "GetSubchannel",
|
||||
Handler: srv.getSubchannel,
|
||||
Handler: srvCopy.getSubchannel,
|
||||
},
|
||||
{
|
||||
MethodName: "GetSocket",
|
||||
Handler: srv.getSocket,
|
||||
Handler: srvCopy.getSocket,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
|
|
|
@ -241,7 +241,7 @@ func genService(gen *protogen.Plugin, file *protogen.File, g *protogen.Generated
|
|||
}
|
||||
g.Annotate(serviceType+"."+method.GoName, method.Location)
|
||||
g.P(method.Comments.Leading,
|
||||
handlerSignature(g, method))
|
||||
method.GoName, " func", handlerSignature(g, method))
|
||||
}
|
||||
g.P("}")
|
||||
g.P()
|
||||
|
@ -270,6 +270,19 @@ func genRegisterFunction(gen *protogen.Plugin, file *protogen.File, g *protogen.
|
|||
g.P(deprecationComment)
|
||||
}
|
||||
g.P("func Register", service.GoName, "Service(s ", grpcPackage.Ident("ServiceRegistrar"), ", srv *", service.GoName, "Service) {")
|
||||
g.P("srvCopy := *srv")
|
||||
// Add Unimplemented defaults for unset handlers
|
||||
for _, method := range service.Methods {
|
||||
g.P("if srvCopy.", method.GoName, " == nil {")
|
||||
g.P("srvCopy.", method.GoName, " = func", handlerSignature(g, method), "{")
|
||||
nilArg := ""
|
||||
if !method.Desc.IsStreamingClient() && !method.Desc.IsStreamingServer() {
|
||||
nilArg = "nil, "
|
||||
}
|
||||
g.P("return ", nilArg, statusPackage.Ident("Errorf"), "(", codesPackage.Ident("Unimplemented"), `, "method `, method.GoName, ` not implemented")`)
|
||||
g.P("}")
|
||||
g.P("}")
|
||||
}
|
||||
|
||||
// Service descriptor.
|
||||
g.P("sd := ", grpcPackage.Ident("ServiceDesc"), " {")
|
||||
|
@ -281,7 +294,7 @@ func genRegisterFunction(gen *protogen.Plugin, file *protogen.File, g *protogen.
|
|||
}
|
||||
g.P("{")
|
||||
g.P("MethodName: ", strconv.Quote(string(method.Desc.Name())), ",")
|
||||
g.P("Handler: srv.", unexport(method.GoName), ",")
|
||||
g.P("Handler: srvCopy.", unexport(method.GoName), ",")
|
||||
g.P("},")
|
||||
}
|
||||
g.P("},")
|
||||
|
@ -292,7 +305,7 @@ func genRegisterFunction(gen *protogen.Plugin, file *protogen.File, g *protogen.
|
|||
}
|
||||
g.P("{")
|
||||
g.P("StreamName: ", strconv.Quote(string(method.Desc.Name())), ",")
|
||||
g.P("Handler: srv.", unexport(method.GoName), ",")
|
||||
g.P("Handler: srvCopy.", unexport(method.GoName), ",")
|
||||
if method.Desc.IsStreamingServer() {
|
||||
g.P("ServerStreams: true,")
|
||||
}
|
||||
|
@ -384,43 +397,34 @@ func handlerSignature(g *protogen.GeneratedFile, method *protogen.Method) string
|
|||
if method.Desc.IsStreamingClient() || method.Desc.IsStreamingServer() {
|
||||
reqArgs = append(reqArgs, method.Parent.GoName+"_"+method.GoName+"Server")
|
||||
}
|
||||
return method.GoName + " func(" + strings.Join(reqArgs, ", ") + ") " + ret
|
||||
return "(" + strings.Join(reqArgs, ", ") + ") " + ret
|
||||
}
|
||||
|
||||
func unaryHandlerSignature(g *protogen.GeneratedFile) string {
|
||||
return "(_ interface{}, ctx " + g.QualifiedGoIdent(contextPackage.Ident("Context")) +
|
||||
", dec func(interface{}) error, interceptor " + g.QualifiedGoIdent(grpcPackage.Ident("UnaryServerInterceptor")) + ") (interface{}, error)"
|
||||
}
|
||||
|
||||
func streamHandlerSignature(g *protogen.GeneratedFile) string {
|
||||
func genericHandlerSignature(g *protogen.GeneratedFile, method *protogen.Method) string {
|
||||
if !method.Desc.IsStreamingClient() && !method.Desc.IsStreamingServer() {
|
||||
// Unary
|
||||
return "(_ interface{}, ctx " + g.QualifiedGoIdent(contextPackage.Ident("Context")) +
|
||||
", dec func(interface{}) error, interceptor " +
|
||||
g.QualifiedGoIdent(grpcPackage.Ident("UnaryServerInterceptor")) + ") (interface{}, error)"
|
||||
}
|
||||
// Streaming
|
||||
return "(_ interface{}, stream " + g.QualifiedGoIdent(grpcPackage.Ident("ServerStream")) + ") error"
|
||||
}
|
||||
|
||||
func genMethodHandler(gen *protogen.Plugin, g *protogen.GeneratedFile, method *protogen.Method) {
|
||||
service := method.Parent
|
||||
|
||||
nilArg := ""
|
||||
signature := streamHandlerSignature(g)
|
||||
if !method.Desc.IsStreamingClient() && !method.Desc.IsStreamingServer() {
|
||||
nilArg = "nil,"
|
||||
signature = unaryHandlerSignature(g)
|
||||
}
|
||||
g.P("func (s *", service.GoName, "Service) ", unexport(method.GoName), signature, " {")
|
||||
g.P("func (s *", service.GoName, "Service) ", unexport(method.GoName), genericHandlerSignature(g, method), " {")
|
||||
|
||||
g.P("if s.", method.GoName, " == nil {")
|
||||
g.P("return ", nilArg, statusPackage.Ident("Errorf"), "(", codesPackage.Ident("Unimplemented"), `, "method `, method.GoName, ` not implemented")`)
|
||||
g.P("}")
|
||||
genHandlerBody(gen, g, method)
|
||||
|
||||
g.P("}")
|
||||
}
|
||||
|
||||
func genHandlerBody(gen *protogen.Plugin, g *protogen.GeneratedFile, method *protogen.Method) {
|
||||
service := method.Parent
|
||||
// Unary
|
||||
if !method.Desc.IsStreamingClient() && !method.Desc.IsStreamingServer() {
|
||||
g.P("in := new(", method.Input.GoIdent, ")")
|
||||
g.P("if err := dec(in); err != nil { return nil, err }")
|
||||
g.P("if interceptor == nil { return s.", method.GoName, "(ctx, in) }")
|
||||
|
||||
g.P("if interceptor == nil {")
|
||||
g.P("return s.", method.GoName, "(ctx, in)")
|
||||
g.P("}")
|
||||
|
||||
g.P("info := &", grpcPackage.Ident("UnaryServerInfo"), "{")
|
||||
g.P("Server: s,")
|
||||
g.P("FullMethod: ", strconv.Quote(fmt.Sprintf("/%s/%s", service.Desc.FullName(), method.GoName)), ",")
|
||||
|
@ -429,8 +433,11 @@ func genHandlerBody(gen *protogen.Plugin, g *protogen.GeneratedFile, method *pro
|
|||
g.P("return s.", method.GoName, "(ctx, req.(*", method.Input.GoIdent, "))")
|
||||
g.P("}")
|
||||
g.P("return interceptor(ctx, in, info, handler)")
|
||||
g.P("}")
|
||||
return
|
||||
}
|
||||
|
||||
// Streaming
|
||||
streamType := unexport(service.GoName) + method.GoName + "Server"
|
||||
if !method.Desc.IsStreamingClient() {
|
||||
// Server-streaming
|
||||
|
@ -441,6 +448,7 @@ func genHandlerBody(gen *protogen.Plugin, g *protogen.GeneratedFile, method *pro
|
|||
// Bidi-streaming
|
||||
g.P("return s.", method.GoName, "(&", streamType, "{stream})")
|
||||
}
|
||||
g.P("}")
|
||||
}
|
||||
|
||||
func genServerStreamTypes(gen *protogen.Plugin, g *protogen.GeneratedFile, method *protogen.Method) {
|
||||
|
|
|
@ -27,21 +27,24 @@ type HandshakerServiceService struct {
|
|||
}
|
||||
|
||||
func (s *HandshakerServiceService) doHandshake(_ interface{}, stream grpc.ServerStream) error {
|
||||
if s.DoHandshake == nil {
|
||||
return status.Errorf(codes.Unimplemented, "method DoHandshake not implemented")
|
||||
}
|
||||
return s.DoHandshake(&handshakerServiceDoHandshakeServer{stream})
|
||||
}
|
||||
|
||||
// RegisterHandshakerServiceService registers a service implementation with a gRPC server.
|
||||
func RegisterHandshakerServiceService(s grpc.ServiceRegistrar, srv *HandshakerServiceService) {
|
||||
srvCopy := *srv
|
||||
if srvCopy.DoHandshake == nil {
|
||||
srvCopy.DoHandshake = func(HandshakerService_DoHandshakeServer) error {
|
||||
return status.Errorf(codes.Unimplemented, "method DoHandshake not implemented")
|
||||
}
|
||||
}
|
||||
sd := grpc.ServiceDesc{
|
||||
ServiceName: "grpc.gcp.HandshakerService",
|
||||
Methods: []grpc.MethodDesc{},
|
||||
Streams: []grpc.StreamDesc{
|
||||
{
|
||||
StreamName: "DoHandshake",
|
||||
Handler: srv.doHandshake,
|
||||
Handler: srvCopy.doHandshake,
|
||||
ServerStreams: true,
|
||||
ClientStreams: true,
|
||||
},
|
||||
|
|
|
@ -24,9 +24,6 @@ type MeshCertificateServiceService struct {
|
|||
}
|
||||
|
||||
func (s *MeshCertificateServiceService) createCertificate(_ interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
if s.CreateCertificate == nil {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method CreateCertificate not implemented")
|
||||
}
|
||||
in := new(MeshCertificateRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
|
@ -46,12 +43,18 @@ func (s *MeshCertificateServiceService) createCertificate(_ interface{}, ctx con
|
|||
|
||||
// RegisterMeshCertificateServiceService registers a service implementation with a gRPC server.
|
||||
func RegisterMeshCertificateServiceService(s grpc.ServiceRegistrar, srv *MeshCertificateServiceService) {
|
||||
srvCopy := *srv
|
||||
if srvCopy.CreateCertificate == nil {
|
||||
srvCopy.CreateCertificate = func(context.Context, *MeshCertificateRequest) (*MeshCertificateResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method CreateCertificate not implemented")
|
||||
}
|
||||
}
|
||||
sd := grpc.ServiceDesc{
|
||||
ServiceName: "google.security.meshca.v1.MeshCertificateService",
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "CreateCertificate",
|
||||
Handler: srv.createCertificate,
|
||||
Handler: srvCopy.createCertificate,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
|
|
|
@ -177,9 +177,6 @@ type EchoService struct {
|
|||
}
|
||||
|
||||
func (s *EchoService) unaryEcho(_ interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
if s.UnaryEcho == nil {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method UnaryEcho not implemented")
|
||||
}
|
||||
in := new(EchoRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
|
@ -197,9 +194,6 @@ func (s *EchoService) unaryEcho(_ interface{}, ctx context.Context, dec func(int
|
|||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
func (s *EchoService) serverStreamingEcho(_ interface{}, stream grpc.ServerStream) error {
|
||||
if s.ServerStreamingEcho == nil {
|
||||
return status.Errorf(codes.Unimplemented, "method ServerStreamingEcho not implemented")
|
||||
}
|
||||
m := new(EchoRequest)
|
||||
if err := stream.RecvMsg(m); err != nil {
|
||||
return err
|
||||
|
@ -207,15 +201,9 @@ func (s *EchoService) serverStreamingEcho(_ interface{}, stream grpc.ServerStrea
|
|||
return s.ServerStreamingEcho(m, &echoServerStreamingEchoServer{stream})
|
||||
}
|
||||
func (s *EchoService) clientStreamingEcho(_ interface{}, stream grpc.ServerStream) error {
|
||||
if s.ClientStreamingEcho == nil {
|
||||
return status.Errorf(codes.Unimplemented, "method ClientStreamingEcho not implemented")
|
||||
}
|
||||
return s.ClientStreamingEcho(&echoClientStreamingEchoServer{stream})
|
||||
}
|
||||
func (s *EchoService) bidirectionalStreamingEcho(_ interface{}, stream grpc.ServerStream) error {
|
||||
if s.BidirectionalStreamingEcho == nil {
|
||||
return status.Errorf(codes.Unimplemented, "method BidirectionalStreamingEcho not implemented")
|
||||
}
|
||||
return s.BidirectionalStreamingEcho(&echoBidirectionalStreamingEchoServer{stream})
|
||||
}
|
||||
|
||||
|
@ -278,28 +266,49 @@ func (x *echoBidirectionalStreamingEchoServer) Recv() (*EchoRequest, error) {
|
|||
|
||||
// RegisterEchoService registers a service implementation with a gRPC server.
|
||||
func RegisterEchoService(s grpc.ServiceRegistrar, srv *EchoService) {
|
||||
srvCopy := *srv
|
||||
if srvCopy.UnaryEcho == nil {
|
||||
srvCopy.UnaryEcho = func(context.Context, *EchoRequest) (*EchoResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method UnaryEcho not implemented")
|
||||
}
|
||||
}
|
||||
if srvCopy.ServerStreamingEcho == nil {
|
||||
srvCopy.ServerStreamingEcho = func(*EchoRequest, Echo_ServerStreamingEchoServer) error {
|
||||
return status.Errorf(codes.Unimplemented, "method ServerStreamingEcho not implemented")
|
||||
}
|
||||
}
|
||||
if srvCopy.ClientStreamingEcho == nil {
|
||||
srvCopy.ClientStreamingEcho = func(Echo_ClientStreamingEchoServer) error {
|
||||
return status.Errorf(codes.Unimplemented, "method ClientStreamingEcho not implemented")
|
||||
}
|
||||
}
|
||||
if srvCopy.BidirectionalStreamingEcho == nil {
|
||||
srvCopy.BidirectionalStreamingEcho = func(Echo_BidirectionalStreamingEchoServer) error {
|
||||
return status.Errorf(codes.Unimplemented, "method BidirectionalStreamingEcho not implemented")
|
||||
}
|
||||
}
|
||||
sd := grpc.ServiceDesc{
|
||||
ServiceName: "grpc.examples.echo.Echo",
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "UnaryEcho",
|
||||
Handler: srv.unaryEcho,
|
||||
Handler: srvCopy.unaryEcho,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{
|
||||
{
|
||||
StreamName: "ServerStreamingEcho",
|
||||
Handler: srv.serverStreamingEcho,
|
||||
Handler: srvCopy.serverStreamingEcho,
|
||||
ServerStreams: true,
|
||||
},
|
||||
{
|
||||
StreamName: "ClientStreamingEcho",
|
||||
Handler: srv.clientStreamingEcho,
|
||||
Handler: srvCopy.clientStreamingEcho,
|
||||
ClientStreams: true,
|
||||
},
|
||||
{
|
||||
StreamName: "BidirectionalStreamingEcho",
|
||||
Handler: srv.bidirectionalStreamingEcho,
|
||||
Handler: srvCopy.bidirectionalStreamingEcho,
|
||||
ServerStreams: true,
|
||||
ClientStreams: true,
|
||||
},
|
||||
|
|
|
@ -52,9 +52,6 @@ type GreeterService struct {
|
|||
}
|
||||
|
||||
func (s *GreeterService) sayHello(_ interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
if s.SayHello == nil {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method SayHello not implemented")
|
||||
}
|
||||
in := new(HelloRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
|
@ -74,12 +71,18 @@ func (s *GreeterService) sayHello(_ interface{}, ctx context.Context, dec func(i
|
|||
|
||||
// RegisterGreeterService registers a service implementation with a gRPC server.
|
||||
func RegisterGreeterService(s grpc.ServiceRegistrar, srv *GreeterService) {
|
||||
srvCopy := *srv
|
||||
if srvCopy.SayHello == nil {
|
||||
srvCopy.SayHello = func(context.Context, *HelloRequest) (*HelloReply, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method SayHello not implemented")
|
||||
}
|
||||
}
|
||||
sd := grpc.ServiceDesc{
|
||||
ServiceName: "helloworld.Greeter",
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "SayHello",
|
||||
Handler: srv.sayHello,
|
||||
Handler: srvCopy.sayHello,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
|
|
|
@ -209,9 +209,6 @@ type RouteGuideService struct {
|
|||
}
|
||||
|
||||
func (s *RouteGuideService) getFeature(_ interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
if s.GetFeature == nil {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetFeature not implemented")
|
||||
}
|
||||
in := new(Point)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
|
@ -229,9 +226,6 @@ func (s *RouteGuideService) getFeature(_ interface{}, ctx context.Context, dec f
|
|||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
func (s *RouteGuideService) listFeatures(_ interface{}, stream grpc.ServerStream) error {
|
||||
if s.ListFeatures == nil {
|
||||
return status.Errorf(codes.Unimplemented, "method ListFeatures not implemented")
|
||||
}
|
||||
m := new(Rectangle)
|
||||
if err := stream.RecvMsg(m); err != nil {
|
||||
return err
|
||||
|
@ -239,15 +233,9 @@ func (s *RouteGuideService) listFeatures(_ interface{}, stream grpc.ServerStream
|
|||
return s.ListFeatures(m, &routeGuideListFeaturesServer{stream})
|
||||
}
|
||||
func (s *RouteGuideService) recordRoute(_ interface{}, stream grpc.ServerStream) error {
|
||||
if s.RecordRoute == nil {
|
||||
return status.Errorf(codes.Unimplemented, "method RecordRoute not implemented")
|
||||
}
|
||||
return s.RecordRoute(&routeGuideRecordRouteServer{stream})
|
||||
}
|
||||
func (s *RouteGuideService) routeChat(_ interface{}, stream grpc.ServerStream) error {
|
||||
if s.RouteChat == nil {
|
||||
return status.Errorf(codes.Unimplemented, "method RouteChat not implemented")
|
||||
}
|
||||
return s.RouteChat(&routeGuideRouteChatServer{stream})
|
||||
}
|
||||
|
||||
|
@ -310,28 +298,49 @@ func (x *routeGuideRouteChatServer) Recv() (*RouteNote, error) {
|
|||
|
||||
// RegisterRouteGuideService registers a service implementation with a gRPC server.
|
||||
func RegisterRouteGuideService(s grpc.ServiceRegistrar, srv *RouteGuideService) {
|
||||
srvCopy := *srv
|
||||
if srvCopy.GetFeature == nil {
|
||||
srvCopy.GetFeature = func(context.Context, *Point) (*Feature, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetFeature not implemented")
|
||||
}
|
||||
}
|
||||
if srvCopy.ListFeatures == nil {
|
||||
srvCopy.ListFeatures = func(*Rectangle, RouteGuide_ListFeaturesServer) error {
|
||||
return status.Errorf(codes.Unimplemented, "method ListFeatures not implemented")
|
||||
}
|
||||
}
|
||||
if srvCopy.RecordRoute == nil {
|
||||
srvCopy.RecordRoute = func(RouteGuide_RecordRouteServer) error {
|
||||
return status.Errorf(codes.Unimplemented, "method RecordRoute not implemented")
|
||||
}
|
||||
}
|
||||
if srvCopy.RouteChat == nil {
|
||||
srvCopy.RouteChat = func(RouteGuide_RouteChatServer) error {
|
||||
return status.Errorf(codes.Unimplemented, "method RouteChat not implemented")
|
||||
}
|
||||
}
|
||||
sd := grpc.ServiceDesc{
|
||||
ServiceName: "routeguide.RouteGuide",
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "GetFeature",
|
||||
Handler: srv.getFeature,
|
||||
Handler: srvCopy.getFeature,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{
|
||||
{
|
||||
StreamName: "ListFeatures",
|
||||
Handler: srv.listFeatures,
|
||||
Handler: srvCopy.listFeatures,
|
||||
ServerStreams: true,
|
||||
},
|
||||
{
|
||||
StreamName: "RecordRoute",
|
||||
Handler: srv.recordRoute,
|
||||
Handler: srvCopy.recordRoute,
|
||||
ClientStreams: true,
|
||||
},
|
||||
{
|
||||
StreamName: "RouteChat",
|
||||
Handler: srv.routeChat,
|
||||
Handler: srvCopy.routeChat,
|
||||
ServerStreams: true,
|
||||
ClientStreams: true,
|
||||
},
|
||||
|
|
|
@ -40,9 +40,6 @@ type HealthService struct {
|
|||
}
|
||||
|
||||
func (s *HealthService) check(_ interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
if s.Check == nil {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Check not implemented")
|
||||
}
|
||||
in := new(HealthCheckRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
|
@ -60,9 +57,6 @@ func (s *HealthService) check(_ interface{}, ctx context.Context, dec func(inter
|
|||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
func (s *HealthService) watch(_ interface{}, stream grpc.ServerStream) error {
|
||||
if s.Watch == nil {
|
||||
return status.Errorf(codes.Unimplemented, "method Watch not implemented")
|
||||
}
|
||||
m := new(HealthCheckRequest)
|
||||
if err := stream.RecvMsg(m); err != nil {
|
||||
return err
|
||||
|
@ -72,18 +66,29 @@ func (s *HealthService) watch(_ interface{}, stream grpc.ServerStream) error {
|
|||
|
||||
// RegisterHealthService registers a service implementation with a gRPC server.
|
||||
func RegisterHealthService(s grpc.ServiceRegistrar, srv *HealthService) {
|
||||
srvCopy := *srv
|
||||
if srvCopy.Check == nil {
|
||||
srvCopy.Check = func(context.Context, *HealthCheckRequest) (*HealthCheckResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Check not implemented")
|
||||
}
|
||||
}
|
||||
if srvCopy.Watch == nil {
|
||||
srvCopy.Watch = func(*HealthCheckRequest, Health_WatchServer) error {
|
||||
return status.Errorf(codes.Unimplemented, "method Watch not implemented")
|
||||
}
|
||||
}
|
||||
sd := grpc.ServiceDesc{
|
||||
ServiceName: "grpc.health.v1.Health",
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "Check",
|
||||
Handler: srv.check,
|
||||
Handler: srvCopy.check,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{
|
||||
{
|
||||
StreamName: "Watch",
|
||||
Handler: srv.watch,
|
||||
Handler: srvCopy.watch,
|
||||
ServerStreams: true,
|
||||
},
|
||||
},
|
||||
|
|
|
@ -251,9 +251,6 @@ type TestServiceService struct {
|
|||
}
|
||||
|
||||
func (s *TestServiceService) emptyCall(_ interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
if s.EmptyCall == nil {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method EmptyCall not implemented")
|
||||
}
|
||||
in := new(Empty)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
|
@ -271,9 +268,6 @@ func (s *TestServiceService) emptyCall(_ interface{}, ctx context.Context, dec f
|
|||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
func (s *TestServiceService) unaryCall(_ interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
if s.UnaryCall == nil {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method UnaryCall not implemented")
|
||||
}
|
||||
in := new(SimpleRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
|
@ -291,9 +285,6 @@ func (s *TestServiceService) unaryCall(_ interface{}, ctx context.Context, dec f
|
|||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
func (s *TestServiceService) streamingOutputCall(_ interface{}, stream grpc.ServerStream) error {
|
||||
if s.StreamingOutputCall == nil {
|
||||
return status.Errorf(codes.Unimplemented, "method StreamingOutputCall not implemented")
|
||||
}
|
||||
m := new(StreamingOutputCallRequest)
|
||||
if err := stream.RecvMsg(m); err != nil {
|
||||
return err
|
||||
|
@ -301,21 +292,12 @@ func (s *TestServiceService) streamingOutputCall(_ interface{}, stream grpc.Serv
|
|||
return s.StreamingOutputCall(m, &testServiceStreamingOutputCallServer{stream})
|
||||
}
|
||||
func (s *TestServiceService) streamingInputCall(_ interface{}, stream grpc.ServerStream) error {
|
||||
if s.StreamingInputCall == nil {
|
||||
return status.Errorf(codes.Unimplemented, "method StreamingInputCall not implemented")
|
||||
}
|
||||
return s.StreamingInputCall(&testServiceStreamingInputCallServer{stream})
|
||||
}
|
||||
func (s *TestServiceService) fullDuplexCall(_ interface{}, stream grpc.ServerStream) error {
|
||||
if s.FullDuplexCall == nil {
|
||||
return status.Errorf(codes.Unimplemented, "method FullDuplexCall not implemented")
|
||||
}
|
||||
return s.FullDuplexCall(&testServiceFullDuplexCallServer{stream})
|
||||
}
|
||||
func (s *TestServiceService) halfDuplexCall(_ interface{}, stream grpc.ServerStream) error {
|
||||
if s.HalfDuplexCall == nil {
|
||||
return status.Errorf(codes.Unimplemented, "method HalfDuplexCall not implemented")
|
||||
}
|
||||
return s.HalfDuplexCall(&testServiceHalfDuplexCallServer{stream})
|
||||
}
|
||||
|
||||
|
@ -400,38 +382,69 @@ func (x *testServiceHalfDuplexCallServer) Recv() (*StreamingOutputCallRequest, e
|
|||
|
||||
// RegisterTestServiceService registers a service implementation with a gRPC server.
|
||||
func RegisterTestServiceService(s grpc.ServiceRegistrar, srv *TestServiceService) {
|
||||
srvCopy := *srv
|
||||
if srvCopy.EmptyCall == nil {
|
||||
srvCopy.EmptyCall = func(context.Context, *Empty) (*Empty, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method EmptyCall not implemented")
|
||||
}
|
||||
}
|
||||
if srvCopy.UnaryCall == nil {
|
||||
srvCopy.UnaryCall = func(context.Context, *SimpleRequest) (*SimpleResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method UnaryCall not implemented")
|
||||
}
|
||||
}
|
||||
if srvCopy.StreamingOutputCall == nil {
|
||||
srvCopy.StreamingOutputCall = func(*StreamingOutputCallRequest, TestService_StreamingOutputCallServer) error {
|
||||
return status.Errorf(codes.Unimplemented, "method StreamingOutputCall not implemented")
|
||||
}
|
||||
}
|
||||
if srvCopy.StreamingInputCall == nil {
|
||||
srvCopy.StreamingInputCall = func(TestService_StreamingInputCallServer) error {
|
||||
return status.Errorf(codes.Unimplemented, "method StreamingInputCall not implemented")
|
||||
}
|
||||
}
|
||||
if srvCopy.FullDuplexCall == nil {
|
||||
srvCopy.FullDuplexCall = func(TestService_FullDuplexCallServer) error {
|
||||
return status.Errorf(codes.Unimplemented, "method FullDuplexCall not implemented")
|
||||
}
|
||||
}
|
||||
if srvCopy.HalfDuplexCall == nil {
|
||||
srvCopy.HalfDuplexCall = func(TestService_HalfDuplexCallServer) error {
|
||||
return status.Errorf(codes.Unimplemented, "method HalfDuplexCall not implemented")
|
||||
}
|
||||
}
|
||||
sd := grpc.ServiceDesc{
|
||||
ServiceName: "grpc.testing.TestService",
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "EmptyCall",
|
||||
Handler: srv.emptyCall,
|
||||
Handler: srvCopy.emptyCall,
|
||||
},
|
||||
{
|
||||
MethodName: "UnaryCall",
|
||||
Handler: srv.unaryCall,
|
||||
Handler: srvCopy.unaryCall,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{
|
||||
{
|
||||
StreamName: "StreamingOutputCall",
|
||||
Handler: srv.streamingOutputCall,
|
||||
Handler: srvCopy.streamingOutputCall,
|
||||
ServerStreams: true,
|
||||
},
|
||||
{
|
||||
StreamName: "StreamingInputCall",
|
||||
Handler: srv.streamingInputCall,
|
||||
Handler: srvCopy.streamingInputCall,
|
||||
ClientStreams: true,
|
||||
},
|
||||
{
|
||||
StreamName: "FullDuplexCall",
|
||||
Handler: srv.fullDuplexCall,
|
||||
Handler: srvCopy.fullDuplexCall,
|
||||
ServerStreams: true,
|
||||
ClientStreams: true,
|
||||
},
|
||||
{
|
||||
StreamName: "HalfDuplexCall",
|
||||
Handler: srv.halfDuplexCall,
|
||||
Handler: srvCopy.halfDuplexCall,
|
||||
ServerStreams: true,
|
||||
ClientStreams: true,
|
||||
},
|
||||
|
@ -549,9 +562,6 @@ type UnimplementedServiceService struct {
|
|||
}
|
||||
|
||||
func (s *UnimplementedServiceService) unimplementedCall(_ interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
if s.UnimplementedCall == nil {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method UnimplementedCall not implemented")
|
||||
}
|
||||
in := new(Empty)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
|
@ -571,12 +581,18 @@ func (s *UnimplementedServiceService) unimplementedCall(_ interface{}, ctx conte
|
|||
|
||||
// RegisterUnimplementedServiceService registers a service implementation with a gRPC server.
|
||||
func RegisterUnimplementedServiceService(s grpc.ServiceRegistrar, srv *UnimplementedServiceService) {
|
||||
srvCopy := *srv
|
||||
if srvCopy.UnimplementedCall == nil {
|
||||
srvCopy.UnimplementedCall = func(context.Context, *Empty) (*Empty, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method UnimplementedCall not implemented")
|
||||
}
|
||||
}
|
||||
sd := grpc.ServiceDesc{
|
||||
ServiceName: "grpc.testing.UnimplementedService",
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "UnimplementedCall",
|
||||
Handler: srv.unimplementedCall,
|
||||
Handler: srvCopy.unimplementedCall,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
|
@ -650,9 +666,6 @@ type LoadBalancerStatsServiceService struct {
|
|||
}
|
||||
|
||||
func (s *LoadBalancerStatsServiceService) getClientStats(_ interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
if s.GetClientStats == nil {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetClientStats not implemented")
|
||||
}
|
||||
in := new(LoadBalancerStatsRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
|
@ -672,12 +685,18 @@ func (s *LoadBalancerStatsServiceService) getClientStats(_ interface{}, ctx cont
|
|||
|
||||
// RegisterLoadBalancerStatsServiceService registers a service implementation with a gRPC server.
|
||||
func RegisterLoadBalancerStatsServiceService(s grpc.ServiceRegistrar, srv *LoadBalancerStatsServiceService) {
|
||||
srvCopy := *srv
|
||||
if srvCopy.GetClientStats == nil {
|
||||
srvCopy.GetClientStats = func(context.Context, *LoadBalancerStatsRequest) (*LoadBalancerStatsResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetClientStats not implemented")
|
||||
}
|
||||
}
|
||||
sd := grpc.ServiceDesc{
|
||||
ServiceName: "grpc.testing.LoadBalancerStatsService",
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "GetClientStats",
|
||||
Handler: srv.getClientStats,
|
||||
Handler: srvCopy.getClientStats,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
|
|
|
@ -26,9 +26,6 @@ type ProfilingService struct {
|
|||
}
|
||||
|
||||
func (s *ProfilingService) enable(_ interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
if s.Enable == nil {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Enable not implemented")
|
||||
}
|
||||
in := new(EnableRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
|
@ -46,9 +43,6 @@ func (s *ProfilingService) enable(_ interface{}, ctx context.Context, dec func(i
|
|||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
func (s *ProfilingService) getStreamStats(_ interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
if s.GetStreamStats == nil {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetStreamStats not implemented")
|
||||
}
|
||||
in := new(GetStreamStatsRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
|
@ -68,16 +62,27 @@ func (s *ProfilingService) getStreamStats(_ interface{}, ctx context.Context, de
|
|||
|
||||
// RegisterProfilingService registers a service implementation with a gRPC server.
|
||||
func RegisterProfilingService(s grpc.ServiceRegistrar, srv *ProfilingService) {
|
||||
srvCopy := *srv
|
||||
if srvCopy.Enable == nil {
|
||||
srvCopy.Enable = func(context.Context, *EnableRequest) (*EnableResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Enable not implemented")
|
||||
}
|
||||
}
|
||||
if srvCopy.GetStreamStats == nil {
|
||||
srvCopy.GetStreamStats = func(context.Context, *GetStreamStatsRequest) (*GetStreamStatsResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetStreamStats not implemented")
|
||||
}
|
||||
}
|
||||
sd := grpc.ServiceDesc{
|
||||
ServiceName: "grpc.go.profiling.v1alpha.Profiling",
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "Enable",
|
||||
Handler: srv.enable,
|
||||
Handler: srvCopy.enable,
|
||||
},
|
||||
{
|
||||
MethodName: "GetStreamStats",
|
||||
Handler: srv.getStreamStats,
|
||||
Handler: srvCopy.getStreamStats,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
|
|
|
@ -23,21 +23,24 @@ type ServerReflectionService struct {
|
|||
}
|
||||
|
||||
func (s *ServerReflectionService) serverReflectionInfo(_ interface{}, stream grpc.ServerStream) error {
|
||||
if s.ServerReflectionInfo == nil {
|
||||
return status.Errorf(codes.Unimplemented, "method ServerReflectionInfo not implemented")
|
||||
}
|
||||
return s.ServerReflectionInfo(&serverReflectionServerReflectionInfoServer{stream})
|
||||
}
|
||||
|
||||
// RegisterServerReflectionService registers a service implementation with a gRPC server.
|
||||
func RegisterServerReflectionService(s grpc.ServiceRegistrar, srv *ServerReflectionService) {
|
||||
srvCopy := *srv
|
||||
if srvCopy.ServerReflectionInfo == nil {
|
||||
srvCopy.ServerReflectionInfo = func(ServerReflection_ServerReflectionInfoServer) error {
|
||||
return status.Errorf(codes.Unimplemented, "method ServerReflectionInfo not implemented")
|
||||
}
|
||||
}
|
||||
sd := grpc.ServiceDesc{
|
||||
ServiceName: "grpc.reflection.v1alpha.ServerReflection",
|
||||
Methods: []grpc.MethodDesc{},
|
||||
Streams: []grpc.StreamDesc{
|
||||
{
|
||||
StreamName: "ServerReflectionInfo",
|
||||
Handler: srv.serverReflectionInfo,
|
||||
Handler: srvCopy.serverReflectionInfo,
|
||||
ServerStreams: true,
|
||||
ClientStreams: true,
|
||||
},
|
||||
|
|
|
@ -89,9 +89,6 @@ type SearchServiceService struct {
|
|||
}
|
||||
|
||||
func (s *SearchServiceService) search(_ interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
if s.Search == nil {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Search not implemented")
|
||||
}
|
||||
in := new(SearchRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
|
@ -109,9 +106,6 @@ func (s *SearchServiceService) search(_ interface{}, ctx context.Context, dec fu
|
|||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
func (s *SearchServiceService) streamingSearch(_ interface{}, stream grpc.ServerStream) error {
|
||||
if s.StreamingSearch == nil {
|
||||
return status.Errorf(codes.Unimplemented, "method StreamingSearch not implemented")
|
||||
}
|
||||
return s.StreamingSearch(&searchServiceStreamingSearchServer{stream})
|
||||
}
|
||||
|
||||
|
@ -139,18 +133,29 @@ func (x *searchServiceStreamingSearchServer) Recv() (*SearchRequest, error) {
|
|||
|
||||
// RegisterSearchServiceService registers a service implementation with a gRPC server.
|
||||
func RegisterSearchServiceService(s grpc.ServiceRegistrar, srv *SearchServiceService) {
|
||||
srvCopy := *srv
|
||||
if srvCopy.Search == nil {
|
||||
srvCopy.Search = func(context.Context, *SearchRequest) (*SearchResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Search not implemented")
|
||||
}
|
||||
}
|
||||
if srvCopy.StreamingSearch == nil {
|
||||
srvCopy.StreamingSearch = func(SearchService_StreamingSearchServer) error {
|
||||
return status.Errorf(codes.Unimplemented, "method StreamingSearch not implemented")
|
||||
}
|
||||
}
|
||||
sd := grpc.ServiceDesc{
|
||||
ServiceName: "grpc.testing.SearchService",
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "Search",
|
||||
Handler: srv.search,
|
||||
Handler: srvCopy.search,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{
|
||||
{
|
||||
StreamName: "StreamingSearch",
|
||||
Handler: srv.streamingSearch,
|
||||
Handler: srvCopy.streamingSearch,
|
||||
ServerStreams: true,
|
||||
ClientStreams: true,
|
||||
},
|
||||
|
|
|
@ -183,9 +183,6 @@ type TestServiceService struct {
|
|||
}
|
||||
|
||||
func (s *TestServiceService) unaryCall(_ interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
if s.UnaryCall == nil {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method UnaryCall not implemented")
|
||||
}
|
||||
in := new(SimpleRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
|
@ -203,21 +200,12 @@ func (s *TestServiceService) unaryCall(_ interface{}, ctx context.Context, dec f
|
|||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
func (s *TestServiceService) fullDuplexCall(_ interface{}, stream grpc.ServerStream) error {
|
||||
if s.FullDuplexCall == nil {
|
||||
return status.Errorf(codes.Unimplemented, "method FullDuplexCall not implemented")
|
||||
}
|
||||
return s.FullDuplexCall(&testServiceFullDuplexCallServer{stream})
|
||||
}
|
||||
func (s *TestServiceService) clientStreamCall(_ interface{}, stream grpc.ServerStream) error {
|
||||
if s.ClientStreamCall == nil {
|
||||
return status.Errorf(codes.Unimplemented, "method ClientStreamCall not implemented")
|
||||
}
|
||||
return s.ClientStreamCall(&testServiceClientStreamCallServer{stream})
|
||||
}
|
||||
func (s *TestServiceService) serverStreamCall(_ interface{}, stream grpc.ServerStream) error {
|
||||
if s.ServerStreamCall == nil {
|
||||
return status.Errorf(codes.Unimplemented, "method ServerStreamCall not implemented")
|
||||
}
|
||||
m := new(SimpleRequest)
|
||||
if err := stream.RecvMsg(m); err != nil {
|
||||
return err
|
||||
|
@ -284,29 +272,50 @@ func (x *testServiceServerStreamCallServer) Send(m *SimpleResponse) error {
|
|||
|
||||
// RegisterTestServiceService registers a service implementation with a gRPC server.
|
||||
func RegisterTestServiceService(s grpc.ServiceRegistrar, srv *TestServiceService) {
|
||||
srvCopy := *srv
|
||||
if srvCopy.UnaryCall == nil {
|
||||
srvCopy.UnaryCall = func(context.Context, *SimpleRequest) (*SimpleResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method UnaryCall not implemented")
|
||||
}
|
||||
}
|
||||
if srvCopy.FullDuplexCall == nil {
|
||||
srvCopy.FullDuplexCall = func(TestService_FullDuplexCallServer) error {
|
||||
return status.Errorf(codes.Unimplemented, "method FullDuplexCall not implemented")
|
||||
}
|
||||
}
|
||||
if srvCopy.ClientStreamCall == nil {
|
||||
srvCopy.ClientStreamCall = func(TestService_ClientStreamCallServer) error {
|
||||
return status.Errorf(codes.Unimplemented, "method ClientStreamCall not implemented")
|
||||
}
|
||||
}
|
||||
if srvCopy.ServerStreamCall == nil {
|
||||
srvCopy.ServerStreamCall = func(*SimpleRequest, TestService_ServerStreamCallServer) error {
|
||||
return status.Errorf(codes.Unimplemented, "method ServerStreamCall not implemented")
|
||||
}
|
||||
}
|
||||
sd := grpc.ServiceDesc{
|
||||
ServiceName: "grpc.testing.TestService",
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "UnaryCall",
|
||||
Handler: srv.unaryCall,
|
||||
Handler: srvCopy.unaryCall,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{
|
||||
{
|
||||
StreamName: "FullDuplexCall",
|
||||
Handler: srv.fullDuplexCall,
|
||||
Handler: srvCopy.fullDuplexCall,
|
||||
ServerStreams: true,
|
||||
ClientStreams: true,
|
||||
},
|
||||
{
|
||||
StreamName: "ClientStreamCall",
|
||||
Handler: srv.clientStreamCall,
|
||||
Handler: srvCopy.clientStreamCall,
|
||||
ClientStreams: true,
|
||||
},
|
||||
{
|
||||
StreamName: "ServerStreamCall",
|
||||
Handler: srv.serverStreamCall,
|
||||
Handler: srvCopy.serverStreamCall,
|
||||
ServerStreams: true,
|
||||
},
|
||||
},
|
||||
|
|
|
@ -95,9 +95,6 @@ type MetricsServiceService struct {
|
|||
}
|
||||
|
||||
func (s *MetricsServiceService) getAllGauges(_ interface{}, stream grpc.ServerStream) error {
|
||||
if s.GetAllGauges == nil {
|
||||
return status.Errorf(codes.Unimplemented, "method GetAllGauges not implemented")
|
||||
}
|
||||
m := new(EmptyMessage)
|
||||
if err := stream.RecvMsg(m); err != nil {
|
||||
return err
|
||||
|
@ -105,9 +102,6 @@ func (s *MetricsServiceService) getAllGauges(_ interface{}, stream grpc.ServerSt
|
|||
return s.GetAllGauges(m, &metricsServiceGetAllGaugesServer{stream})
|
||||
}
|
||||
func (s *MetricsServiceService) getGauge(_ interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
if s.GetGauge == nil {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetGauge not implemented")
|
||||
}
|
||||
in := new(GaugeRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
|
@ -140,18 +134,29 @@ func (x *metricsServiceGetAllGaugesServer) Send(m *GaugeResponse) error {
|
|||
|
||||
// RegisterMetricsServiceService registers a service implementation with a gRPC server.
|
||||
func RegisterMetricsServiceService(s grpc.ServiceRegistrar, srv *MetricsServiceService) {
|
||||
srvCopy := *srv
|
||||
if srvCopy.GetAllGauges == nil {
|
||||
srvCopy.GetAllGauges = func(*EmptyMessage, MetricsService_GetAllGaugesServer) error {
|
||||
return status.Errorf(codes.Unimplemented, "method GetAllGauges not implemented")
|
||||
}
|
||||
}
|
||||
if srvCopy.GetGauge == nil {
|
||||
srvCopy.GetGauge = func(context.Context, *GaugeRequest) (*GaugeResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetGauge not implemented")
|
||||
}
|
||||
}
|
||||
sd := grpc.ServiceDesc{
|
||||
ServiceName: "grpc.testing.MetricsService",
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "GetGauge",
|
||||
Handler: srv.getGauge,
|
||||
Handler: srvCopy.getGauge,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{
|
||||
{
|
||||
StreamName: "GetAllGauges",
|
||||
Handler: srv.getAllGauges,
|
||||
Handler: srvCopy.getAllGauges,
|
||||
ServerStreams: true,
|
||||
},
|
||||
},
|
||||
|
|
|
@ -251,9 +251,6 @@ type TestServiceService struct {
|
|||
}
|
||||
|
||||
func (s *TestServiceService) emptyCall(_ interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
if s.EmptyCall == nil {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method EmptyCall not implemented")
|
||||
}
|
||||
in := new(Empty)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
|
@ -271,9 +268,6 @@ func (s *TestServiceService) emptyCall(_ interface{}, ctx context.Context, dec f
|
|||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
func (s *TestServiceService) unaryCall(_ interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
if s.UnaryCall == nil {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method UnaryCall not implemented")
|
||||
}
|
||||
in := new(SimpleRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
|
@ -291,9 +285,6 @@ func (s *TestServiceService) unaryCall(_ interface{}, ctx context.Context, dec f
|
|||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
func (s *TestServiceService) streamingOutputCall(_ interface{}, stream grpc.ServerStream) error {
|
||||
if s.StreamingOutputCall == nil {
|
||||
return status.Errorf(codes.Unimplemented, "method StreamingOutputCall not implemented")
|
||||
}
|
||||
m := new(StreamingOutputCallRequest)
|
||||
if err := stream.RecvMsg(m); err != nil {
|
||||
return err
|
||||
|
@ -301,21 +292,12 @@ func (s *TestServiceService) streamingOutputCall(_ interface{}, stream grpc.Serv
|
|||
return s.StreamingOutputCall(m, &testServiceStreamingOutputCallServer{stream})
|
||||
}
|
||||
func (s *TestServiceService) streamingInputCall(_ interface{}, stream grpc.ServerStream) error {
|
||||
if s.StreamingInputCall == nil {
|
||||
return status.Errorf(codes.Unimplemented, "method StreamingInputCall not implemented")
|
||||
}
|
||||
return s.StreamingInputCall(&testServiceStreamingInputCallServer{stream})
|
||||
}
|
||||
func (s *TestServiceService) fullDuplexCall(_ interface{}, stream grpc.ServerStream) error {
|
||||
if s.FullDuplexCall == nil {
|
||||
return status.Errorf(codes.Unimplemented, "method FullDuplexCall not implemented")
|
||||
}
|
||||
return s.FullDuplexCall(&testServiceFullDuplexCallServer{stream})
|
||||
}
|
||||
func (s *TestServiceService) halfDuplexCall(_ interface{}, stream grpc.ServerStream) error {
|
||||
if s.HalfDuplexCall == nil {
|
||||
return status.Errorf(codes.Unimplemented, "method HalfDuplexCall not implemented")
|
||||
}
|
||||
return s.HalfDuplexCall(&testServiceHalfDuplexCallServer{stream})
|
||||
}
|
||||
|
||||
|
@ -400,38 +382,69 @@ func (x *testServiceHalfDuplexCallServer) Recv() (*StreamingOutputCallRequest, e
|
|||
|
||||
// RegisterTestServiceService registers a service implementation with a gRPC server.
|
||||
func RegisterTestServiceService(s grpc.ServiceRegistrar, srv *TestServiceService) {
|
||||
srvCopy := *srv
|
||||
if srvCopy.EmptyCall == nil {
|
||||
srvCopy.EmptyCall = func(context.Context, *Empty) (*Empty, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method EmptyCall not implemented")
|
||||
}
|
||||
}
|
||||
if srvCopy.UnaryCall == nil {
|
||||
srvCopy.UnaryCall = func(context.Context, *SimpleRequest) (*SimpleResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method UnaryCall not implemented")
|
||||
}
|
||||
}
|
||||
if srvCopy.StreamingOutputCall == nil {
|
||||
srvCopy.StreamingOutputCall = func(*StreamingOutputCallRequest, TestService_StreamingOutputCallServer) error {
|
||||
return status.Errorf(codes.Unimplemented, "method StreamingOutputCall not implemented")
|
||||
}
|
||||
}
|
||||
if srvCopy.StreamingInputCall == nil {
|
||||
srvCopy.StreamingInputCall = func(TestService_StreamingInputCallServer) error {
|
||||
return status.Errorf(codes.Unimplemented, "method StreamingInputCall not implemented")
|
||||
}
|
||||
}
|
||||
if srvCopy.FullDuplexCall == nil {
|
||||
srvCopy.FullDuplexCall = func(TestService_FullDuplexCallServer) error {
|
||||
return status.Errorf(codes.Unimplemented, "method FullDuplexCall not implemented")
|
||||
}
|
||||
}
|
||||
if srvCopy.HalfDuplexCall == nil {
|
||||
srvCopy.HalfDuplexCall = func(TestService_HalfDuplexCallServer) error {
|
||||
return status.Errorf(codes.Unimplemented, "method HalfDuplexCall not implemented")
|
||||
}
|
||||
}
|
||||
sd := grpc.ServiceDesc{
|
||||
ServiceName: "grpc.testing.TestService",
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "EmptyCall",
|
||||
Handler: srv.emptyCall,
|
||||
Handler: srvCopy.emptyCall,
|
||||
},
|
||||
{
|
||||
MethodName: "UnaryCall",
|
||||
Handler: srv.unaryCall,
|
||||
Handler: srvCopy.unaryCall,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{
|
||||
{
|
||||
StreamName: "StreamingOutputCall",
|
||||
Handler: srv.streamingOutputCall,
|
||||
Handler: srvCopy.streamingOutputCall,
|
||||
ServerStreams: true,
|
||||
},
|
||||
{
|
||||
StreamName: "StreamingInputCall",
|
||||
Handler: srv.streamingInputCall,
|
||||
Handler: srvCopy.streamingInputCall,
|
||||
ClientStreams: true,
|
||||
},
|
||||
{
|
||||
StreamName: "FullDuplexCall",
|
||||
Handler: srv.fullDuplexCall,
|
||||
Handler: srvCopy.fullDuplexCall,
|
||||
ServerStreams: true,
|
||||
ClientStreams: true,
|
||||
},
|
||||
{
|
||||
StreamName: "HalfDuplexCall",
|
||||
Handler: srv.halfDuplexCall,
|
||||
Handler: srvCopy.halfDuplexCall,
|
||||
ServerStreams: true,
|
||||
ClientStreams: true,
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue