protoc-gen-go-grpc: generate interfaces optionally; remove NewFooService (#3876)

This commit is contained in:
Doug Fawley 2020-09-16 10:15:56 -07:00 committed by GitHub
parent a3e63e87bd
commit ff9dd65c90
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
43 changed files with 911 additions and 1976 deletions

View File

@ -4,14 +4,10 @@
package grpc_lb_v1
import (
context "context"
fmt "fmt"
proto "github.com/golang/protobuf/proto"
duration "github.com/golang/protobuf/ptypes/duration"
timestamp "github.com/golang/protobuf/ptypes/timestamp"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
math "math"
)
@ -642,117 +638,3 @@ var fileDescriptor_7cd3f6d792743fdf = []byte{
0x6d, 0xe1, 0xbe, 0xfb, 0x2f, 0x00, 0x00, 0xff, 0xff, 0x3f, 0x47, 0x55, 0xac, 0xab, 0x06, 0x00,
0x00,
}
// Reference imports to suppress errors if they are not otherwise used.
var _ context.Context
var _ grpc.ClientConnInterface
// 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.SupportPackageIsVersion6
// LoadBalancerClient is the client API for LoadBalancer service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type LoadBalancerClient interface {
// Bidirectional rpc to get a list of servers.
BalanceLoad(ctx context.Context, opts ...grpc.CallOption) (LoadBalancer_BalanceLoadClient, error)
}
type loadBalancerClient struct {
cc grpc.ClientConnInterface
}
func NewLoadBalancerClient(cc grpc.ClientConnInterface) LoadBalancerClient {
return &loadBalancerClient{cc}
}
func (c *loadBalancerClient) BalanceLoad(ctx context.Context, opts ...grpc.CallOption) (LoadBalancer_BalanceLoadClient, error) {
stream, err := c.cc.NewStream(ctx, &_LoadBalancer_serviceDesc.Streams[0], "/grpc.lb.v1.LoadBalancer/BalanceLoad", opts...)
if err != nil {
return nil, err
}
x := &loadBalancerBalanceLoadClient{stream}
return x, nil
}
type LoadBalancer_BalanceLoadClient interface {
Send(*LoadBalanceRequest) error
Recv() (*LoadBalanceResponse, error)
grpc.ClientStream
}
type loadBalancerBalanceLoadClient struct {
grpc.ClientStream
}
func (x *loadBalancerBalanceLoadClient) Send(m *LoadBalanceRequest) error {
return x.ClientStream.SendMsg(m)
}
func (x *loadBalancerBalanceLoadClient) Recv() (*LoadBalanceResponse, error) {
m := new(LoadBalanceResponse)
if err := x.ClientStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
// LoadBalancerServer is the server API for LoadBalancer service.
type LoadBalancerServer interface {
// Bidirectional rpc to get a list of servers.
BalanceLoad(LoadBalancer_BalanceLoadServer) error
}
// UnimplementedLoadBalancerServer can be embedded to have forward compatible implementations.
type UnimplementedLoadBalancerServer struct {
}
func (*UnimplementedLoadBalancerServer) BalanceLoad(srv LoadBalancer_BalanceLoadServer) error {
return status.Errorf(codes.Unimplemented, "method BalanceLoad not implemented")
}
func RegisterLoadBalancerServer(s *grpc.Server, srv LoadBalancerServer) {
s.RegisterService(&_LoadBalancer_serviceDesc, srv)
}
func _LoadBalancer_BalanceLoad_Handler(srv interface{}, stream grpc.ServerStream) error {
return srv.(LoadBalancerServer).BalanceLoad(&loadBalancerBalanceLoadServer{stream})
}
type LoadBalancer_BalanceLoadServer interface {
Send(*LoadBalanceResponse) error
Recv() (*LoadBalanceRequest, error)
grpc.ServerStream
}
type loadBalancerBalanceLoadServer struct {
grpc.ServerStream
}
func (x *loadBalancerBalanceLoadServer) Send(m *LoadBalanceResponse) error {
return x.ServerStream.SendMsg(m)
}
func (x *loadBalancerBalanceLoadServer) Recv() (*LoadBalanceRequest, error) {
m := new(LoadBalanceRequest)
if err := x.ServerStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
var _LoadBalancer_serviceDesc = grpc.ServiceDesc{
ServiceName: "grpc.lb.v1.LoadBalancer",
HandlerType: (*LoadBalancerServer)(nil),
Methods: []grpc.MethodDesc{},
Streams: []grpc.StreamDesc{
{
StreamName: "BalanceLoad",
Handler: _LoadBalancer_BalanceLoad_Handler,
ServerStreams: true,
ClientStreams: true,
},
},
Metadata: "grpc/lb/v1/load_balancer.proto",
}

View File

@ -3,6 +3,7 @@
package grpc_lb_v1
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
@ -12,6 +13,59 @@ import (
// is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion7
// LoadBalancerClient is the client API for LoadBalancer service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type LoadBalancerClient interface {
// Bidirectional rpc to get a list of servers.
BalanceLoad(ctx context.Context, opts ...grpc.CallOption) (LoadBalancer_BalanceLoadClient, error)
}
type loadBalancerClient struct {
cc grpc.ClientConnInterface
}
func NewLoadBalancerClient(cc grpc.ClientConnInterface) LoadBalancerClient {
return &loadBalancerClient{cc}
}
var loadBalancerBalanceLoadStreamDesc = &grpc.StreamDesc{
StreamName: "BalanceLoad",
ServerStreams: true,
ClientStreams: true,
}
func (c *loadBalancerClient) BalanceLoad(ctx context.Context, opts ...grpc.CallOption) (LoadBalancer_BalanceLoadClient, error) {
stream, err := c.cc.NewStream(ctx, loadBalancerBalanceLoadStreamDesc, "/grpc.lb.v1.LoadBalancer/BalanceLoad", opts...)
if err != nil {
return nil, err
}
x := &loadBalancerBalanceLoadClient{stream}
return x, nil
}
type LoadBalancer_BalanceLoadClient interface {
Send(*LoadBalanceRequest) error
Recv() (*LoadBalanceResponse, error)
grpc.ClientStream
}
type loadBalancerBalanceLoadClient struct {
grpc.ClientStream
}
func (x *loadBalancerBalanceLoadClient) Send(m *LoadBalanceRequest) error {
return x.ClientStream.SendMsg(m)
}
func (x *loadBalancerBalanceLoadClient) Recv() (*LoadBalanceResponse, error) {
m := new(LoadBalanceResponse)
if err := x.ClientStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
// LoadBalancerService is the service API for LoadBalancer service.
// Fields should be assigned to their respective handler implementations only before
// RegisterLoadBalancerService is called. Any unassigned fields will result in the
@ -25,6 +79,28 @@ func (s *LoadBalancerService) balanceLoad(_ interface{}, stream grpc.ServerStrea
return s.BalanceLoad(&loadBalancerBalanceLoadServer{stream})
}
type LoadBalancer_BalanceLoadServer interface {
Send(*LoadBalanceResponse) error
Recv() (*LoadBalanceRequest, error)
grpc.ServerStream
}
type loadBalancerBalanceLoadServer struct {
grpc.ServerStream
}
func (x *loadBalancerBalanceLoadServer) Send(m *LoadBalanceResponse) error {
return x.ServerStream.SendMsg(m)
}
func (x *loadBalancerBalanceLoadServer) Recv() (*LoadBalanceRequest, error) {
m := new(LoadBalanceRequest)
if err := x.ServerStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
// RegisterLoadBalancerService registers a service implementation with a gRPC server.
func RegisterLoadBalancerService(s grpc.ServiceRegistrar, srv *LoadBalancerService) {
srvCopy := *srv
@ -50,27 +126,28 @@ func RegisterLoadBalancerService(s grpc.ServiceRegistrar, srv *LoadBalancerServi
s.RegisterService(&sd, nil)
}
// NewLoadBalancerService creates a new LoadBalancerService containing the
// implemented methods of the LoadBalancer service in s. Any unimplemented
// methods will result in the gRPC server returning an UNIMPLEMENTED status to the client.
// This includes situations where the method handler is misspelled or has the wrong
// signature. For this reason, this function should be used with great care and
// is not recommended to be used by most users.
func NewLoadBalancerService(s interface{}) *LoadBalancerService {
ns := &LoadBalancerService{}
if h, ok := s.(interface {
BalanceLoad(LoadBalancer_BalanceLoadServer) error
}); ok {
ns.BalanceLoad = h.BalanceLoad
}
return ns
}
// UnstableLoadBalancerService is the service API for LoadBalancer service.
// LoadBalancerServer is the service API for LoadBalancer service.
// New methods may be added to this interface if they are added to the service
// definition, which is not a backward-compatible change. For this reason,
// use of this type is not recommended.
type UnstableLoadBalancerService interface {
// use of this type is not recommended unless you own the service definition.
type LoadBalancerServer interface {
// Bidirectional rpc to get a list of servers.
BalanceLoad(LoadBalancer_BalanceLoadServer) error
}
// UnimplementedLoadBalancerServer can be embedded to have forward compatible implementations of
// LoadBalancerServer
type UnimplementedLoadBalancerServer struct {
}
func (*UnimplementedLoadBalancerServer) BalanceLoad(LoadBalancer_BalanceLoadServer) error {
return status.Errorf(codes.Unimplemented, "method BalanceLoad not implemented")
}
// RegisterLoadBalancerServer registers a service implementation with a gRPC server.
func RegisterLoadBalancerServer(s grpc.ServiceRegistrar, srv LoadBalancerServer) {
str := &LoadBalancerService{
BalanceLoad: srv.BalanceLoad,
}
RegisterLoadBalancerService(s, str)
}

View File

@ -4,12 +4,8 @@
package grpc_lookup_v1
import (
context "context"
fmt "fmt"
proto "github.com/golang/protobuf/proto"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
math "math"
)
@ -180,85 +176,3 @@ var fileDescriptor_3bab962d3362f3ca = []byte{
0x29, 0xa7, 0xcf, 0x5e, 0xb3, 0x1d, 0x27, 0xef, 0x01, 0x00, 0x00, 0xff, 0xff, 0xca, 0x8d, 0x5c,
0xc7, 0x39, 0x02, 0x00, 0x00,
}
// Reference imports to suppress errors if they are not otherwise used.
var _ context.Context
var _ grpc.ClientConnInterface
// 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.SupportPackageIsVersion6
// RouteLookupServiceClient is the client API for RouteLookupService service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type RouteLookupServiceClient interface {
// Lookup returns a target for a single key.
RouteLookup(ctx context.Context, in *RouteLookupRequest, opts ...grpc.CallOption) (*RouteLookupResponse, error)
}
type routeLookupServiceClient struct {
cc grpc.ClientConnInterface
}
func NewRouteLookupServiceClient(cc grpc.ClientConnInterface) RouteLookupServiceClient {
return &routeLookupServiceClient{cc}
}
func (c *routeLookupServiceClient) RouteLookup(ctx context.Context, in *RouteLookupRequest, opts ...grpc.CallOption) (*RouteLookupResponse, error) {
out := new(RouteLookupResponse)
err := c.cc.Invoke(ctx, "/grpc.lookup.v1.RouteLookupService/RouteLookup", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// RouteLookupServiceServer is the server API for RouteLookupService service.
type RouteLookupServiceServer interface {
// Lookup returns a target for a single key.
RouteLookup(context.Context, *RouteLookupRequest) (*RouteLookupResponse, error)
}
// UnimplementedRouteLookupServiceServer can be embedded to have forward compatible implementations.
type UnimplementedRouteLookupServiceServer struct {
}
func (*UnimplementedRouteLookupServiceServer) RouteLookup(ctx context.Context, req *RouteLookupRequest) (*RouteLookupResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method RouteLookup not implemented")
}
func RegisterRouteLookupServiceServer(s *grpc.Server, srv RouteLookupServiceServer) {
s.RegisterService(&_RouteLookupService_serviceDesc, srv)
}
func _RouteLookupService_RouteLookup_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(RouteLookupRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(RouteLookupServiceServer).RouteLookup(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/grpc.lookup.v1.RouteLookupService/RouteLookup",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(RouteLookupServiceServer).RouteLookup(ctx, req.(*RouteLookupRequest))
}
return interceptor(ctx, in, info, handler)
}
var _RouteLookupService_serviceDesc = grpc.ServiceDesc{
ServiceName: "grpc.lookup.v1.RouteLookupService",
HandlerType: (*RouteLookupServiceServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "RouteLookup",
Handler: _RouteLookupService_RouteLookup_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "grpc/lookup/v1/rls.proto",
}

View File

@ -13,6 +13,35 @@ import (
// is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion7
// RouteLookupServiceClient is the client API for RouteLookupService service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type RouteLookupServiceClient interface {
// Lookup returns a target for a single key.
RouteLookup(ctx context.Context, in *RouteLookupRequest, opts ...grpc.CallOption) (*RouteLookupResponse, error)
}
type routeLookupServiceClient struct {
cc grpc.ClientConnInterface
}
func NewRouteLookupServiceClient(cc grpc.ClientConnInterface) RouteLookupServiceClient {
return &routeLookupServiceClient{cc}
}
var routeLookupServiceRouteLookupStreamDesc = &grpc.StreamDesc{
StreamName: "RouteLookup",
}
func (c *routeLookupServiceClient) RouteLookup(ctx context.Context, in *RouteLookupRequest, opts ...grpc.CallOption) (*RouteLookupResponse, error) {
out := new(RouteLookupResponse)
err := c.cc.Invoke(ctx, "/grpc.lookup.v1.RouteLookupService/RouteLookup", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// RouteLookupServiceService is the service API for RouteLookupService service.
// Fields should be assigned to their respective handler implementations only before
// RegisterRouteLookupServiceService is called. Any unassigned fields will result in the
@ -63,27 +92,28 @@ func RegisterRouteLookupServiceService(s grpc.ServiceRegistrar, srv *RouteLookup
s.RegisterService(&sd, nil)
}
// NewRouteLookupServiceService creates a new RouteLookupServiceService containing the
// implemented methods of the RouteLookupService service in s. Any unimplemented
// methods will result in the gRPC server returning an UNIMPLEMENTED status to the client.
// This includes situations where the method handler is misspelled or has the wrong
// signature. For this reason, this function should be used with great care and
// is not recommended to be used by most users.
func NewRouteLookupServiceService(s interface{}) *RouteLookupServiceService {
ns := &RouteLookupServiceService{}
if h, ok := s.(interface {
RouteLookup(context.Context, *RouteLookupRequest) (*RouteLookupResponse, error)
}); ok {
ns.RouteLookup = h.RouteLookup
}
return ns
}
// UnstableRouteLookupServiceService is the service API for RouteLookupService service.
// RouteLookupServiceServer is the service API for RouteLookupService service.
// New methods may be added to this interface if they are added to the service
// definition, which is not a backward-compatible change. For this reason,
// use of this type is not recommended.
type UnstableRouteLookupServiceService interface {
// use of this type is not recommended unless you own the service definition.
type RouteLookupServiceServer interface {
// Lookup returns a target for a single key.
RouteLookup(context.Context, *RouteLookupRequest) (*RouteLookupResponse, error)
}
// UnimplementedRouteLookupServiceServer can be embedded to have forward compatible implementations of
// RouteLookupServiceServer
type UnimplementedRouteLookupServiceServer struct {
}
func (*UnimplementedRouteLookupServiceServer) RouteLookup(context.Context, *RouteLookupRequest) (*RouteLookupResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method RouteLookup not implemented")
}
// RegisterRouteLookupServiceServer registers a service implementation with a gRPC server.
func RegisterRouteLookupServiceServer(s grpc.ServiceRegistrar, srv RouteLookupServiceServer) {
str := &RouteLookupServiceService{
RouteLookup: srv.RouteLookup,
}
RegisterRouteLookupServiceService(s, str)
}

View File

@ -63,7 +63,13 @@ func NewPayload(t testpb.PayloadType, size int) *testpb.Payload {
type testServer struct{}
var _ testpb.UnstableBenchmarkServiceService = (*testServer)(nil)
func (s *testServer) Svc() *testpb.BenchmarkServiceService {
return &testpb.BenchmarkServiceService{
UnaryCall: s.UnaryCall,
StreamingCall: s.StreamingCall,
UnconstrainedStreamingCall: s.UnconstrainedStreamingCall,
}
}
func (s *testServer) UnaryCall(ctx context.Context, in *testpb.SimpleRequest) (*testpb.SimpleResponse, error) {
return &testpb.SimpleResponse{
@ -147,7 +153,13 @@ type byteBufServer struct {
respSize int32
}
var _ testpb.UnstableBenchmarkServiceService = (*byteBufServer)(nil)
func (s *byteBufServer) Svc() *testpb.BenchmarkServiceService {
return &testpb.BenchmarkServiceService{
UnaryCall: s.UnaryCall,
StreamingCall: s.StreamingCall,
UnconstrainedStreamingCall: s.UnconstrainedStreamingCall,
}
}
// UnaryCall is an empty function and is not used for benchmark.
// If bytebuf UnaryCall benchmark is needed later, the function body needs to be updated.
@ -212,13 +224,13 @@ func StartServer(info ServerInfo, opts ...grpc.ServerOption) func() {
s := grpc.NewServer(opts...)
switch info.Type {
case "protobuf":
testpb.RegisterBenchmarkServiceService(s, testpb.NewBenchmarkServiceService(&testServer{}))
testpb.RegisterBenchmarkServiceService(s, (&testServer{}).Svc())
case "bytebuf":
respSize, ok := info.Metadata.(int32)
if !ok {
logger.Fatalf("failed to StartServer, invalid metadata: %v, for Type: %v", info.Metadata, info.Type)
}
testpb.RegisterBenchmarkServiceService(s, testpb.NewBenchmarkServiceService(&byteBufServer{respSize: respSize}))
testpb.RegisterBenchmarkServiceService(s, (&byteBufServer{respSize: respSize}).Svc())
default:
logger.Fatalf("failed to StartServer, unknown Type: %v", info.Type)
}

View File

@ -253,48 +253,6 @@ func RegisterBenchmarkServiceService(s grpc.ServiceRegistrar, srv *BenchmarkServ
s.RegisterService(&sd, nil)
}
// NewBenchmarkServiceService creates a new BenchmarkServiceService containing the
// implemented methods of the BenchmarkService service in s. Any unimplemented
// methods will result in the gRPC server returning an UNIMPLEMENTED status to the client.
// This includes situations where the method handler is misspelled or has the wrong
// signature. For this reason, this function should be used with great care and
// is not recommended to be used by most users.
func NewBenchmarkServiceService(s interface{}) *BenchmarkServiceService {
ns := &BenchmarkServiceService{}
if h, ok := s.(interface {
UnaryCall(context.Context, *SimpleRequest) (*SimpleResponse, error)
}); ok {
ns.UnaryCall = h.UnaryCall
}
if h, ok := s.(interface {
StreamingCall(BenchmarkService_StreamingCallServer) error
}); ok {
ns.StreamingCall = h.StreamingCall
}
if h, ok := s.(interface {
UnconstrainedStreamingCall(BenchmarkService_UnconstrainedStreamingCallServer) error
}); ok {
ns.UnconstrainedStreamingCall = h.UnconstrainedStreamingCall
}
return ns
}
// UnstableBenchmarkServiceService is the service API for BenchmarkService service.
// New methods may be added to this interface if they are added to the service
// definition, which is not a backward-compatible change. For this reason,
// use of this type is not recommended.
type UnstableBenchmarkServiceService interface {
// One request followed by one response.
// The server returns the client payload as-is.
UnaryCall(context.Context, *SimpleRequest) (*SimpleResponse, error)
// One request followed by one response.
// The server returns the client payload as-is.
StreamingCall(BenchmarkService_StreamingCallServer) error
// Unconstrainted streaming.
// Both server and client keep sending & receiving simultaneously.
UnconstrainedStreamingCall(BenchmarkService_UnconstrainedStreamingCallServer) error
}
// WorkerServiceClient is the client API for WorkerService service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
@ -591,59 +549,3 @@ func RegisterWorkerServiceService(s grpc.ServiceRegistrar, srv *WorkerServiceSer
s.RegisterService(&sd, nil)
}
// NewWorkerServiceService creates a new WorkerServiceService containing the
// implemented methods of the WorkerService service in s. Any unimplemented
// methods will result in the gRPC server returning an UNIMPLEMENTED status to the client.
// This includes situations where the method handler is misspelled or has the wrong
// signature. For this reason, this function should be used with great care and
// is not recommended to be used by most users.
func NewWorkerServiceService(s interface{}) *WorkerServiceService {
ns := &WorkerServiceService{}
if h, ok := s.(interface {
RunServer(WorkerService_RunServerServer) error
}); ok {
ns.RunServer = h.RunServer
}
if h, ok := s.(interface {
RunClient(WorkerService_RunClientServer) error
}); ok {
ns.RunClient = h.RunClient
}
if h, ok := s.(interface {
CoreCount(context.Context, *CoreRequest) (*CoreResponse, error)
}); ok {
ns.CoreCount = h.CoreCount
}
if h, ok := s.(interface {
QuitWorker(context.Context, *Void) (*Void, error)
}); ok {
ns.QuitWorker = h.QuitWorker
}
return ns
}
// UnstableWorkerServiceService is the service API for WorkerService service.
// New methods may be added to this interface if they are added to the service
// definition, which is not a backward-compatible change. For this reason,
// use of this type is not recommended.
type UnstableWorkerServiceService interface {
// Start server with specified workload.
// First request sent specifies the ServerConfig followed by ServerStatus
// response. After that, a "Mark" can be sent anytime to request the latest
// stats. Closing the stream will initiate shutdown of the test server
// and once the shutdown has finished, the OK status is sent to terminate
// this RPC.
RunServer(WorkerService_RunServerServer) error
// Start client with specified workload.
// First request sent specifies the ClientConfig followed by ClientStatus
// response. After that, a "Mark" can be sent anytime to request the latest
// stats. Closing the stream will initiate shutdown of the test client
// and once the shutdown has finished, the OK status is sent to terminate
// this RPC.
RunClient(WorkerService_RunClientServer) error
// Just return the core count - unary call
CoreCount(context.Context, *CoreRequest) (*CoreResponse, error)
// Quit this worker
QuitWorker(context.Context, *Void) (*Void, error)
}

View File

@ -79,7 +79,14 @@ type workerServer struct {
serverPort int
}
var _ testpb.UnstableWorkerServiceService = (*workerServer)(nil)
func (s *workerServer) Svc() *testpb.WorkerServiceService {
return &testpb.WorkerServiceService{
RunServer: s.RunServer,
RunClient: s.RunClient,
CoreCount: s.CoreCount,
QuitWorker: s.QuitWorker,
}
}
func (s *workerServer) RunServer(stream testpb.WorkerService_RunServerServer) error {
var bs *benchmarkServer
@ -210,10 +217,10 @@ func main() {
s := grpc.NewServer()
stop := make(chan bool)
testpb.RegisterWorkerServiceService(s, testpb.NewWorkerServiceService(&workerServer{
testpb.RegisterWorkerServiceService(s, (&workerServer{
stop: stop,
serverPort: *serverPort,
}))
}).Svc())
go func() {
<-stop

View File

@ -4,16 +4,12 @@
package grpc_channelz_v1
import (
context "context"
fmt "fmt"
proto "github.com/golang/protobuf/proto"
any "github.com/golang/protobuf/ptypes/any"
duration "github.com/golang/protobuf/ptypes/duration"
timestamp "github.com/golang/protobuf/ptypes/timestamp"
wrappers "github.com/golang/protobuf/ptypes/wrappers"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
math "math"
)
@ -2925,315 +2921,3 @@ var fileDescriptor_6ee37dfd35a8ab00 = []byte{
0xd3, 0x77, 0xc6, 0x68, 0xe7, 0x3c, 0xcf, 0x4f, 0xf3, 0x5f, 0xfd, 0x37, 0x00, 0x00, 0xff, 0xff,
0x54, 0xae, 0x0b, 0x93, 0xdf, 0x1f, 0x00, 0x00,
}
// Reference imports to suppress errors if they are not otherwise used.
var _ context.Context
var _ grpc.ClientConnInterface
// 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.SupportPackageIsVersion6
// ChannelzClient is the client API for Channelz service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type ChannelzClient interface {
// Gets all root channels (i.e. channels the application has directly
// created). This does not include subchannels nor non-top level channels.
GetTopChannels(ctx context.Context, in *GetTopChannelsRequest, opts ...grpc.CallOption) (*GetTopChannelsResponse, error)
// Gets all servers that exist in the process.
GetServers(ctx context.Context, in *GetServersRequest, opts ...grpc.CallOption) (*GetServersResponse, error)
// Returns a single Server, or else a NOT_FOUND code.
GetServer(ctx context.Context, in *GetServerRequest, opts ...grpc.CallOption) (*GetServerResponse, error)
// Gets all server sockets that exist in the process.
GetServerSockets(ctx context.Context, in *GetServerSocketsRequest, opts ...grpc.CallOption) (*GetServerSocketsResponse, error)
// Returns a single Channel, or else a NOT_FOUND code.
GetChannel(ctx context.Context, in *GetChannelRequest, opts ...grpc.CallOption) (*GetChannelResponse, error)
// Returns a single Subchannel, or else a NOT_FOUND code.
GetSubchannel(ctx context.Context, in *GetSubchannelRequest, opts ...grpc.CallOption) (*GetSubchannelResponse, error)
// Returns a single Socket or else a NOT_FOUND code.
GetSocket(ctx context.Context, in *GetSocketRequest, opts ...grpc.CallOption) (*GetSocketResponse, error)
}
type channelzClient struct {
cc grpc.ClientConnInterface
}
func NewChannelzClient(cc grpc.ClientConnInterface) ChannelzClient {
return &channelzClient{cc}
}
func (c *channelzClient) GetTopChannels(ctx context.Context, in *GetTopChannelsRequest, opts ...grpc.CallOption) (*GetTopChannelsResponse, error) {
out := new(GetTopChannelsResponse)
err := c.cc.Invoke(ctx, "/grpc.channelz.v1.Channelz/GetTopChannels", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *channelzClient) GetServers(ctx context.Context, in *GetServersRequest, opts ...grpc.CallOption) (*GetServersResponse, error) {
out := new(GetServersResponse)
err := c.cc.Invoke(ctx, "/grpc.channelz.v1.Channelz/GetServers", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *channelzClient) GetServer(ctx context.Context, in *GetServerRequest, opts ...grpc.CallOption) (*GetServerResponse, error) {
out := new(GetServerResponse)
err := c.cc.Invoke(ctx, "/grpc.channelz.v1.Channelz/GetServer", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *channelzClient) GetServerSockets(ctx context.Context, in *GetServerSocketsRequest, opts ...grpc.CallOption) (*GetServerSocketsResponse, error) {
out := new(GetServerSocketsResponse)
err := c.cc.Invoke(ctx, "/grpc.channelz.v1.Channelz/GetServerSockets", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *channelzClient) GetChannel(ctx context.Context, in *GetChannelRequest, opts ...grpc.CallOption) (*GetChannelResponse, error) {
out := new(GetChannelResponse)
err := c.cc.Invoke(ctx, "/grpc.channelz.v1.Channelz/GetChannel", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *channelzClient) GetSubchannel(ctx context.Context, in *GetSubchannelRequest, opts ...grpc.CallOption) (*GetSubchannelResponse, error) {
out := new(GetSubchannelResponse)
err := c.cc.Invoke(ctx, "/grpc.channelz.v1.Channelz/GetSubchannel", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *channelzClient) GetSocket(ctx context.Context, in *GetSocketRequest, opts ...grpc.CallOption) (*GetSocketResponse, error) {
out := new(GetSocketResponse)
err := c.cc.Invoke(ctx, "/grpc.channelz.v1.Channelz/GetSocket", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// ChannelzServer is the server API for Channelz service.
type ChannelzServer interface {
// Gets all root channels (i.e. channels the application has directly
// created). This does not include subchannels nor non-top level channels.
GetTopChannels(context.Context, *GetTopChannelsRequest) (*GetTopChannelsResponse, error)
// Gets all servers that exist in the process.
GetServers(context.Context, *GetServersRequest) (*GetServersResponse, error)
// Returns a single Server, or else a NOT_FOUND code.
GetServer(context.Context, *GetServerRequest) (*GetServerResponse, error)
// Gets all server sockets that exist in the process.
GetServerSockets(context.Context, *GetServerSocketsRequest) (*GetServerSocketsResponse, error)
// Returns a single Channel, or else a NOT_FOUND code.
GetChannel(context.Context, *GetChannelRequest) (*GetChannelResponse, error)
// Returns a single Subchannel, or else a NOT_FOUND code.
GetSubchannel(context.Context, *GetSubchannelRequest) (*GetSubchannelResponse, error)
// Returns a single Socket or else a NOT_FOUND code.
GetSocket(context.Context, *GetSocketRequest) (*GetSocketResponse, error)
}
// UnimplementedChannelzServer can be embedded to have forward compatible implementations.
type UnimplementedChannelzServer struct {
}
func (*UnimplementedChannelzServer) GetTopChannels(ctx context.Context, req *GetTopChannelsRequest) (*GetTopChannelsResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetTopChannels not implemented")
}
func (*UnimplementedChannelzServer) GetServers(ctx context.Context, req *GetServersRequest) (*GetServersResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetServers not implemented")
}
func (*UnimplementedChannelzServer) GetServer(ctx context.Context, req *GetServerRequest) (*GetServerResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetServer not implemented")
}
func (*UnimplementedChannelzServer) GetServerSockets(ctx context.Context, req *GetServerSocketsRequest) (*GetServerSocketsResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetServerSockets not implemented")
}
func (*UnimplementedChannelzServer) GetChannel(ctx context.Context, req *GetChannelRequest) (*GetChannelResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetChannel not implemented")
}
func (*UnimplementedChannelzServer) GetSubchannel(ctx context.Context, req *GetSubchannelRequest) (*GetSubchannelResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetSubchannel not implemented")
}
func (*UnimplementedChannelzServer) GetSocket(ctx context.Context, req *GetSocketRequest) (*GetSocketResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetSocket not implemented")
}
func RegisterChannelzServer(s *grpc.Server, srv ChannelzServer) {
s.RegisterService(&_Channelz_serviceDesc, srv)
}
func _Channelz_GetTopChannels_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetTopChannelsRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ChannelzServer).GetTopChannels(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/grpc.channelz.v1.Channelz/GetTopChannels",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ChannelzServer).GetTopChannels(ctx, req.(*GetTopChannelsRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Channelz_GetServers_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetServersRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ChannelzServer).GetServers(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/grpc.channelz.v1.Channelz/GetServers",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ChannelzServer).GetServers(ctx, req.(*GetServersRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Channelz_GetServer_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetServerRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ChannelzServer).GetServer(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/grpc.channelz.v1.Channelz/GetServer",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ChannelzServer).GetServer(ctx, req.(*GetServerRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Channelz_GetServerSockets_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetServerSocketsRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ChannelzServer).GetServerSockets(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/grpc.channelz.v1.Channelz/GetServerSockets",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ChannelzServer).GetServerSockets(ctx, req.(*GetServerSocketsRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Channelz_GetChannel_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetChannelRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ChannelzServer).GetChannel(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/grpc.channelz.v1.Channelz/GetChannel",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ChannelzServer).GetChannel(ctx, req.(*GetChannelRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Channelz_GetSubchannel_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetSubchannelRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ChannelzServer).GetSubchannel(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/grpc.channelz.v1.Channelz/GetSubchannel",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ChannelzServer).GetSubchannel(ctx, req.(*GetSubchannelRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Channelz_GetSocket_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetSocketRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ChannelzServer).GetSocket(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/grpc.channelz.v1.Channelz/GetSocket",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ChannelzServer).GetSocket(ctx, req.(*GetSocketRequest))
}
return interceptor(ctx, in, info, handler)
}
var _Channelz_serviceDesc = grpc.ServiceDesc{
ServiceName: "grpc.channelz.v1.Channelz",
HandlerType: (*ChannelzServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "GetTopChannels",
Handler: _Channelz_GetTopChannels_Handler,
},
{
MethodName: "GetServers",
Handler: _Channelz_GetServers_Handler,
},
{
MethodName: "GetServer",
Handler: _Channelz_GetServer_Handler,
},
{
MethodName: "GetServerSockets",
Handler: _Channelz_GetServerSockets_Handler,
},
{
MethodName: "GetChannel",
Handler: _Channelz_GetChannel_Handler,
},
{
MethodName: "GetSubchannel",
Handler: _Channelz_GetSubchannel_Handler,
},
{
MethodName: "GetSocket",
Handler: _Channelz_GetSocket_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "grpc/channelz/v1/channelz.proto",
}

View File

@ -13,6 +13,126 @@ import (
// is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion7
// ChannelzClient is the client API for Channelz service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type ChannelzClient interface {
// Gets all root channels (i.e. channels the application has directly
// created). This does not include subchannels nor non-top level channels.
GetTopChannels(ctx context.Context, in *GetTopChannelsRequest, opts ...grpc.CallOption) (*GetTopChannelsResponse, error)
// Gets all servers that exist in the process.
GetServers(ctx context.Context, in *GetServersRequest, opts ...grpc.CallOption) (*GetServersResponse, error)
// Returns a single Server, or else a NOT_FOUND code.
GetServer(ctx context.Context, in *GetServerRequest, opts ...grpc.CallOption) (*GetServerResponse, error)
// Gets all server sockets that exist in the process.
GetServerSockets(ctx context.Context, in *GetServerSocketsRequest, opts ...grpc.CallOption) (*GetServerSocketsResponse, error)
// Returns a single Channel, or else a NOT_FOUND code.
GetChannel(ctx context.Context, in *GetChannelRequest, opts ...grpc.CallOption) (*GetChannelResponse, error)
// Returns a single Subchannel, or else a NOT_FOUND code.
GetSubchannel(ctx context.Context, in *GetSubchannelRequest, opts ...grpc.CallOption) (*GetSubchannelResponse, error)
// Returns a single Socket or else a NOT_FOUND code.
GetSocket(ctx context.Context, in *GetSocketRequest, opts ...grpc.CallOption) (*GetSocketResponse, error)
}
type channelzClient struct {
cc grpc.ClientConnInterface
}
func NewChannelzClient(cc grpc.ClientConnInterface) ChannelzClient {
return &channelzClient{cc}
}
var channelzGetTopChannelsStreamDesc = &grpc.StreamDesc{
StreamName: "GetTopChannels",
}
func (c *channelzClient) GetTopChannels(ctx context.Context, in *GetTopChannelsRequest, opts ...grpc.CallOption) (*GetTopChannelsResponse, error) {
out := new(GetTopChannelsResponse)
err := c.cc.Invoke(ctx, "/grpc.channelz.v1.Channelz/GetTopChannels", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
var channelzGetServersStreamDesc = &grpc.StreamDesc{
StreamName: "GetServers",
}
func (c *channelzClient) GetServers(ctx context.Context, in *GetServersRequest, opts ...grpc.CallOption) (*GetServersResponse, error) {
out := new(GetServersResponse)
err := c.cc.Invoke(ctx, "/grpc.channelz.v1.Channelz/GetServers", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
var channelzGetServerStreamDesc = &grpc.StreamDesc{
StreamName: "GetServer",
}
func (c *channelzClient) GetServer(ctx context.Context, in *GetServerRequest, opts ...grpc.CallOption) (*GetServerResponse, error) {
out := new(GetServerResponse)
err := c.cc.Invoke(ctx, "/grpc.channelz.v1.Channelz/GetServer", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
var channelzGetServerSocketsStreamDesc = &grpc.StreamDesc{
StreamName: "GetServerSockets",
}
func (c *channelzClient) GetServerSockets(ctx context.Context, in *GetServerSocketsRequest, opts ...grpc.CallOption) (*GetServerSocketsResponse, error) {
out := new(GetServerSocketsResponse)
err := c.cc.Invoke(ctx, "/grpc.channelz.v1.Channelz/GetServerSockets", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
var channelzGetChannelStreamDesc = &grpc.StreamDesc{
StreamName: "GetChannel",
}
func (c *channelzClient) GetChannel(ctx context.Context, in *GetChannelRequest, opts ...grpc.CallOption) (*GetChannelResponse, error) {
out := new(GetChannelResponse)
err := c.cc.Invoke(ctx, "/grpc.channelz.v1.Channelz/GetChannel", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
var channelzGetSubchannelStreamDesc = &grpc.StreamDesc{
StreamName: "GetSubchannel",
}
func (c *channelzClient) GetSubchannel(ctx context.Context, in *GetSubchannelRequest, opts ...grpc.CallOption) (*GetSubchannelResponse, error) {
out := new(GetSubchannelResponse)
err := c.cc.Invoke(ctx, "/grpc.channelz.v1.Channelz/GetSubchannel", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
var channelzGetSocketStreamDesc = &grpc.StreamDesc{
StreamName: "GetSocket",
}
func (c *channelzClient) GetSocket(ctx context.Context, in *GetSocketRequest, opts ...grpc.CallOption) (*GetSocketResponse, error) {
out := new(GetSocketResponse)
err := c.cc.Invoke(ctx, "/grpc.channelz.v1.Channelz/GetSocket", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// ChannelzService is the service API for Channelz service.
// Fields should be assigned to their respective handler implementations only before
// RegisterChannelzService is called. Any unassigned fields will result in the
@ -232,57 +352,11 @@ func RegisterChannelzService(s grpc.ServiceRegistrar, srv *ChannelzService) {
s.RegisterService(&sd, nil)
}
// NewChannelzService creates a new ChannelzService containing the
// implemented methods of the Channelz service in s. Any unimplemented
// methods will result in the gRPC server returning an UNIMPLEMENTED status to the client.
// This includes situations where the method handler is misspelled or has the wrong
// signature. For this reason, this function should be used with great care and
// is not recommended to be used by most users.
func NewChannelzService(s interface{}) *ChannelzService {
ns := &ChannelzService{}
if h, ok := s.(interface {
GetTopChannels(context.Context, *GetTopChannelsRequest) (*GetTopChannelsResponse, error)
}); ok {
ns.GetTopChannels = h.GetTopChannels
}
if h, ok := s.(interface {
GetServers(context.Context, *GetServersRequest) (*GetServersResponse, error)
}); ok {
ns.GetServers = h.GetServers
}
if h, ok := s.(interface {
GetServer(context.Context, *GetServerRequest) (*GetServerResponse, error)
}); ok {
ns.GetServer = h.GetServer
}
if h, ok := s.(interface {
GetServerSockets(context.Context, *GetServerSocketsRequest) (*GetServerSocketsResponse, error)
}); ok {
ns.GetServerSockets = h.GetServerSockets
}
if h, ok := s.(interface {
GetChannel(context.Context, *GetChannelRequest) (*GetChannelResponse, error)
}); ok {
ns.GetChannel = h.GetChannel
}
if h, ok := s.(interface {
GetSubchannel(context.Context, *GetSubchannelRequest) (*GetSubchannelResponse, error)
}); ok {
ns.GetSubchannel = h.GetSubchannel
}
if h, ok := s.(interface {
GetSocket(context.Context, *GetSocketRequest) (*GetSocketResponse, error)
}); ok {
ns.GetSocket = h.GetSocket
}
return ns
}
// UnstableChannelzService is the service API for Channelz service.
// ChannelzServer is the service API for Channelz service.
// New methods may be added to this interface if they are added to the service
// definition, which is not a backward-compatible change. For this reason,
// use of this type is not recommended.
type UnstableChannelzService interface {
// use of this type is not recommended unless you own the service definition.
type ChannelzServer interface {
// Gets all root channels (i.e. channels the application has directly
// created). This does not include subchannels nor non-top level channels.
GetTopChannels(context.Context, *GetTopChannelsRequest) (*GetTopChannelsResponse, error)
@ -299,3 +373,44 @@ type UnstableChannelzService interface {
// Returns a single Socket or else a NOT_FOUND code.
GetSocket(context.Context, *GetSocketRequest) (*GetSocketResponse, error)
}
// UnimplementedChannelzServer can be embedded to have forward compatible implementations of
// ChannelzServer
type UnimplementedChannelzServer struct {
}
func (*UnimplementedChannelzServer) GetTopChannels(context.Context, *GetTopChannelsRequest) (*GetTopChannelsResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetTopChannels not implemented")
}
func (*UnimplementedChannelzServer) GetServers(context.Context, *GetServersRequest) (*GetServersResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetServers not implemented")
}
func (*UnimplementedChannelzServer) GetServer(context.Context, *GetServerRequest) (*GetServerResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetServer not implemented")
}
func (*UnimplementedChannelzServer) GetServerSockets(context.Context, *GetServerSocketsRequest) (*GetServerSocketsResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetServerSockets not implemented")
}
func (*UnimplementedChannelzServer) GetChannel(context.Context, *GetChannelRequest) (*GetChannelResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetChannel not implemented")
}
func (*UnimplementedChannelzServer) GetSubchannel(context.Context, *GetSubchannelRequest) (*GetSubchannelResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetSubchannel not implemented")
}
func (*UnimplementedChannelzServer) GetSocket(context.Context, *GetSocketRequest) (*GetSocketResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetSocket not implemented")
}
// RegisterChannelzServer registers a service implementation with a gRPC server.
func RegisterChannelzServer(s grpc.ServiceRegistrar, srv ChannelzServer) {
str := &ChannelzService{
GetTopChannels: srv.GetTopChannels,
GetServers: srv.GetServers,
GetServer: srv.GetServer,
GetServerSockets: srv.GetServerSockets,
GetChannel: srv.GetChannel,
GetSubchannel: srv.GetSubchannel,
GetSocket: srv.GetSocket,
}
RegisterChannelzService(s, str)
}

View File

@ -98,7 +98,7 @@ type myEchoService{
// Optional; not recommended: to guarantee myEchoService fully implements
// EchoService:
var _ pb.UnstableEchoService = &myEchoService{}
var _ pb.EchoServer = &myEchoService{}
func main() {
// ...
@ -111,7 +111,7 @@ func main() {
// Optional: to gracefully detect missing methods:
if _, ok := &myEchoService{}.(pb.UnstableEchoService); !ok {
if _, ok := &myEchoService{}.(pb.EchoServer); !ok {
fmt.Println("myEchoService does not implement all methods of EchoService.")
}

View File

@ -63,14 +63,13 @@ func generateFileContent(gen *protogen.Plugin, file *protogen.File, g *protogen.
for _, service := range file.Services {
genClient(gen, file, g, service)
genService(gen, file, g, service)
genUnstableServiceInterface(gen, file, g, service)
if *genUnstableServerInterfaces {
genUnstableServerInterface(gen, file, g, service)
}
}
}
func genClient(gen *protogen.Plugin, file *protogen.File, g *protogen.GeneratedFile, service *protogen.Service) {
if *migrationMode {
return
}
clientName := service.GoName + "Client"
g.P("// ", clientName, " is the client API for ", service.GoName, " service.")
@ -258,9 +257,6 @@ func genService(gen *protogen.Plugin, file *protogen.File, g *protogen.Generated
// Service registration.
genRegisterFunction(gen, file, g, service)
// Short-cut service constructor.
genServiceConstructor(gen, g, service)
}
func genRegisterFunction(gen *protogen.Plugin, file *protogen.File, g *protogen.GeneratedFile, service *protogen.Service) {
@ -324,40 +320,21 @@ func genRegisterFunction(gen *protogen.Plugin, file *protogen.File, g *protogen.
g.P()
}
func genServiceConstructor(gen *protogen.Plugin, g *protogen.GeneratedFile, service *protogen.Service) {
g.P("// New", service.GoName, "Service creates a new ", service.GoName, "Service containing the")
g.P("// implemented methods of the ", service.GoName, " service in s. Any unimplemented")
g.P("// methods will result in the gRPC server returning an UNIMPLEMENTED status to the client.")
g.P("// This includes situations where the method handler is misspelled or has the wrong")
g.P("// signature. For this reason, this function should be used with great care and")
g.P("// is not recommended to be used by most users.")
g.P("func New", service.GoName, "Service(s interface{}) *", service.GoName, "Service {")
g.P("ns := &", service.GoName, "Service{}")
for _, method := range service.Methods {
g.P("if h, ok := s.(interface {", methodSignature(g, method), "}); ok {")
g.P("ns.", method.GoName, " = h.", method.GoName)
g.P("}")
}
g.P("return ns")
g.P("}")
g.P()
}
func genUnstableServiceInterface(gen *protogen.Plugin, file *protogen.File, g *protogen.GeneratedFile, service *protogen.Service) {
func genUnstableServerInterface(gen *protogen.Plugin, file *protogen.File, g *protogen.GeneratedFile, service *protogen.Service) {
// Service interface.
serviceType := service.GoName + "Service"
g.P("// Unstable", serviceType, " is the service API for ", service.GoName, " service.")
serverType := service.GoName + "Server"
g.P("// ", serverType, " is the service API for ", service.GoName, " service.")
g.P("// New methods may be added to this interface if they are added to the service")
g.P("// definition, which is not a backward-compatible change. For this reason, ")
g.P("// use of this type is not recommended.")
g.P("// use of this type is not recommended unless you own the service definition.")
if service.Desc.Options().(*descriptorpb.ServiceOptions).GetDeprecated() {
g.P("//")
g.P(deprecationComment)
}
g.Annotate("Unstable"+serviceType, service.Location)
g.P("type Unstable", serviceType, " interface {")
g.Annotate(serverType, service.Location)
g.P("type ", serverType, " interface {")
for _, method := range service.Methods {
g.Annotate("Unstable"+serviceType+"."+method.GoName, method.Location)
g.Annotate(serverType+"."+method.GoName, method.Location)
if method.Desc.Options().(*descriptorpb.MethodOptions).GetDeprecated() {
g.P(deprecationComment)
}
@ -366,6 +343,50 @@ func genUnstableServiceInterface(gen *protogen.Plugin, file *protogen.File, g *p
}
g.P("}")
g.P()
// Unimplemented implementation.
genUnimplementedServer(gen, file, g, service)
// Service registration.
genUnstableRegisterFunction(gen, file, g, service)
}
func genUnimplementedServer(gen *protogen.Plugin, file *protogen.File, g *protogen.GeneratedFile, service *protogen.Service) {
// Server Unimplemented struct for forward compatibility.
serverType := service.GoName + "Server"
g.P("// Unimplemented", serverType, " can be embedded to have forward compatible implementations of")
g.P("// ", serverType)
g.P("type Unimplemented", serverType, " struct {")
g.P("}")
g.P()
for _, method := range service.Methods {
nilArg := ""
if !method.Desc.IsStreamingClient() && !method.Desc.IsStreamingServer() {
nilArg = "nil,"
}
g.P("func (Unimplemented", serverType, ") ", methodSignature(g, method), "{")
g.P("return ", nilArg, statusPackage.Ident("Errorf"), "(", codesPackage.Ident("Unimplemented"), `, "method `, method.GoName, ` not implemented")`)
g.P("}")
}
g.P()
}
func genUnstableRegisterFunction(gen *protogen.Plugin, file *protogen.File, g *protogen.GeneratedFile, service *protogen.Service) {
serverType := service.GoName + "Server"
g.P("// Register", serverType, " registers a service implementation with a gRPC server.")
if service.Desc.Options().(*descriptorpb.ServiceOptions).GetDeprecated() {
g.P("//")
g.P(deprecationComment)
}
g.P("func Register", serverType, "(s ", grpcPackage.Ident("ServiceRegistrar"), ", srv ", serverType, ") {")
g.P("str := &", service.GoName, "Service{")
for _, method := range service.Methods {
g.P(method.GoName, ": srv.", method.GoName, ",")
}
g.P("}")
g.P("Register", service.GoName, "Service(s, str)")
g.P("}")
g.P()
}
func methodSignature(g *protogen.GeneratedFile, method *protogen.Method) string {
@ -452,9 +473,6 @@ func genMethodHandler(gen *protogen.Plugin, g *protogen.GeneratedFile, method *p
}
func genServerStreamTypes(gen *protogen.Plugin, g *protogen.GeneratedFile, method *protogen.Method) {
if *migrationMode {
return
}
if !method.Desc.IsStreamingClient() && !method.Desc.IsStreamingServer() {
// Unary method
return

View File

@ -37,11 +37,11 @@ import (
"google.golang.org/protobuf/types/pluginpb"
)
var migrationMode *bool
var genUnstableServerInterfaces *bool
func main() {
var flags flag.FlagSet
migrationMode = flags.Bool("migration_mode", false, "set to generate new symbols only; requires symbols produced by legacy protoc-gen-go")
genUnstableServerInterfaces = flags.Bool("gen_unstable_server_interfaces", false, `set to generate legacy "Server" interfaces which do not guarantee backward compatibility`)
protogen.Options{
ParamFunc: flags.Set,

View File

@ -4,12 +4,8 @@
package grpc_gcp
import (
context "context"
fmt "fmt"
proto "github.com/golang/protobuf/proto"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
math "math"
)
@ -979,127 +975,3 @@ var fileDescriptor_54c074f40c7c7e99 = []byte{
0x5f, 0xef, 0xa8, 0xf5, 0x83, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0xc1, 0xf9, 0x9d, 0xf2, 0xd9,
0x0b, 0x00, 0x00,
}
// Reference imports to suppress errors if they are not otherwise used.
var _ context.Context
var _ grpc.ClientConnInterface
// 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.SupportPackageIsVersion6
// HandshakerServiceClient is the client API for HandshakerService service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type HandshakerServiceClient interface {
// Handshaker service accepts a stream of handshaker request, returning a
// stream of handshaker response. Client is expected to send exactly one
// message with either client_start or server_start followed by one or more
// messages with next. Each time client sends a request, the handshaker
// service expects to respond. Client does not have to wait for service's
// response before sending next request.
DoHandshake(ctx context.Context, opts ...grpc.CallOption) (HandshakerService_DoHandshakeClient, error)
}
type handshakerServiceClient struct {
cc grpc.ClientConnInterface
}
func NewHandshakerServiceClient(cc grpc.ClientConnInterface) HandshakerServiceClient {
return &handshakerServiceClient{cc}
}
func (c *handshakerServiceClient) DoHandshake(ctx context.Context, opts ...grpc.CallOption) (HandshakerService_DoHandshakeClient, error) {
stream, err := c.cc.NewStream(ctx, &_HandshakerService_serviceDesc.Streams[0], "/grpc.gcp.HandshakerService/DoHandshake", opts...)
if err != nil {
return nil, err
}
x := &handshakerServiceDoHandshakeClient{stream}
return x, nil
}
type HandshakerService_DoHandshakeClient interface {
Send(*HandshakerReq) error
Recv() (*HandshakerResp, error)
grpc.ClientStream
}
type handshakerServiceDoHandshakeClient struct {
grpc.ClientStream
}
func (x *handshakerServiceDoHandshakeClient) Send(m *HandshakerReq) error {
return x.ClientStream.SendMsg(m)
}
func (x *handshakerServiceDoHandshakeClient) Recv() (*HandshakerResp, error) {
m := new(HandshakerResp)
if err := x.ClientStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
// HandshakerServiceServer is the server API for HandshakerService service.
type HandshakerServiceServer interface {
// Handshaker service accepts a stream of handshaker request, returning a
// stream of handshaker response. Client is expected to send exactly one
// message with either client_start or server_start followed by one or more
// messages with next. Each time client sends a request, the handshaker
// service expects to respond. Client does not have to wait for service's
// response before sending next request.
DoHandshake(HandshakerService_DoHandshakeServer) error
}
// UnimplementedHandshakerServiceServer can be embedded to have forward compatible implementations.
type UnimplementedHandshakerServiceServer struct {
}
func (*UnimplementedHandshakerServiceServer) DoHandshake(srv HandshakerService_DoHandshakeServer) error {
return status.Errorf(codes.Unimplemented, "method DoHandshake not implemented")
}
func RegisterHandshakerServiceServer(s *grpc.Server, srv HandshakerServiceServer) {
s.RegisterService(&_HandshakerService_serviceDesc, srv)
}
func _HandshakerService_DoHandshake_Handler(srv interface{}, stream grpc.ServerStream) error {
return srv.(HandshakerServiceServer).DoHandshake(&handshakerServiceDoHandshakeServer{stream})
}
type HandshakerService_DoHandshakeServer interface {
Send(*HandshakerResp) error
Recv() (*HandshakerReq, error)
grpc.ServerStream
}
type handshakerServiceDoHandshakeServer struct {
grpc.ServerStream
}
func (x *handshakerServiceDoHandshakeServer) Send(m *HandshakerResp) error {
return x.ServerStream.SendMsg(m)
}
func (x *handshakerServiceDoHandshakeServer) Recv() (*HandshakerReq, error) {
m := new(HandshakerReq)
if err := x.ServerStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
var _HandshakerService_serviceDesc = grpc.ServiceDesc{
ServiceName: "grpc.gcp.HandshakerService",
HandlerType: (*HandshakerServiceServer)(nil),
Methods: []grpc.MethodDesc{},
Streams: []grpc.StreamDesc{
{
StreamName: "DoHandshake",
Handler: _HandshakerService_DoHandshake_Handler,
ServerStreams: true,
ClientStreams: true,
},
},
Metadata: "grpc/gcp/handshaker.proto",
}

View File

@ -3,6 +3,7 @@
package grpc_gcp
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
@ -12,6 +13,64 @@ import (
// is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion7
// HandshakerServiceClient is the client API for HandshakerService service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type HandshakerServiceClient interface {
// Handshaker service accepts a stream of handshaker request, returning a
// stream of handshaker response. Client is expected to send exactly one
// message with either client_start or server_start followed by one or more
// messages with next. Each time client sends a request, the handshaker
// service expects to respond. Client does not have to wait for service's
// response before sending next request.
DoHandshake(ctx context.Context, opts ...grpc.CallOption) (HandshakerService_DoHandshakeClient, error)
}
type handshakerServiceClient struct {
cc grpc.ClientConnInterface
}
func NewHandshakerServiceClient(cc grpc.ClientConnInterface) HandshakerServiceClient {
return &handshakerServiceClient{cc}
}
var handshakerServiceDoHandshakeStreamDesc = &grpc.StreamDesc{
StreamName: "DoHandshake",
ServerStreams: true,
ClientStreams: true,
}
func (c *handshakerServiceClient) DoHandshake(ctx context.Context, opts ...grpc.CallOption) (HandshakerService_DoHandshakeClient, error) {
stream, err := c.cc.NewStream(ctx, handshakerServiceDoHandshakeStreamDesc, "/grpc.gcp.HandshakerService/DoHandshake", opts...)
if err != nil {
return nil, err
}
x := &handshakerServiceDoHandshakeClient{stream}
return x, nil
}
type HandshakerService_DoHandshakeClient interface {
Send(*HandshakerReq) error
Recv() (*HandshakerResp, error)
grpc.ClientStream
}
type handshakerServiceDoHandshakeClient struct {
grpc.ClientStream
}
func (x *handshakerServiceDoHandshakeClient) Send(m *HandshakerReq) error {
return x.ClientStream.SendMsg(m)
}
func (x *handshakerServiceDoHandshakeClient) Recv() (*HandshakerResp, error) {
m := new(HandshakerResp)
if err := x.ClientStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
// HandshakerServiceService is the service API for HandshakerService service.
// Fields should be assigned to their respective handler implementations only before
// RegisterHandshakerServiceService is called. Any unassigned fields will result in the
@ -30,6 +89,28 @@ func (s *HandshakerServiceService) doHandshake(_ interface{}, stream grpc.Server
return s.DoHandshake(&handshakerServiceDoHandshakeServer{stream})
}
type HandshakerService_DoHandshakeServer interface {
Send(*HandshakerResp) error
Recv() (*HandshakerReq, error)
grpc.ServerStream
}
type handshakerServiceDoHandshakeServer struct {
grpc.ServerStream
}
func (x *handshakerServiceDoHandshakeServer) Send(m *HandshakerResp) error {
return x.ServerStream.SendMsg(m)
}
func (x *handshakerServiceDoHandshakeServer) Recv() (*HandshakerReq, error) {
m := new(HandshakerReq)
if err := x.ServerStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
// RegisterHandshakerServiceService registers a service implementation with a gRPC server.
func RegisterHandshakerServiceService(s grpc.ServiceRegistrar, srv *HandshakerServiceService) {
srvCopy := *srv
@ -55,27 +136,11 @@ func RegisterHandshakerServiceService(s grpc.ServiceRegistrar, srv *HandshakerSe
s.RegisterService(&sd, nil)
}
// NewHandshakerServiceService creates a new HandshakerServiceService containing the
// implemented methods of the HandshakerService service in s. Any unimplemented
// methods will result in the gRPC server returning an UNIMPLEMENTED status to the client.
// This includes situations where the method handler is misspelled or has the wrong
// signature. For this reason, this function should be used with great care and
// is not recommended to be used by most users.
func NewHandshakerServiceService(s interface{}) *HandshakerServiceService {
ns := &HandshakerServiceService{}
if h, ok := s.(interface {
DoHandshake(HandshakerService_DoHandshakeServer) error
}); ok {
ns.DoHandshake = h.DoHandshake
}
return ns
}
// UnstableHandshakerServiceService is the service API for HandshakerService service.
// HandshakerServiceServer is the service API for HandshakerService service.
// New methods may be added to this interface if they are added to the service
// definition, which is not a backward-compatible change. For this reason,
// use of this type is not recommended.
type UnstableHandshakerServiceService interface {
// use of this type is not recommended unless you own the service definition.
type HandshakerServiceServer interface {
// Handshaker service accepts a stream of handshaker request, returning a
// stream of handshaker response. Client is expected to send exactly one
// message with either client_start or server_start followed by one or more
@ -84,3 +149,20 @@ type UnstableHandshakerServiceService interface {
// response before sending next request.
DoHandshake(HandshakerService_DoHandshakeServer) error
}
// UnimplementedHandshakerServiceServer can be embedded to have forward compatible implementations of
// HandshakerServiceServer
type UnimplementedHandshakerServiceServer struct {
}
func (*UnimplementedHandshakerServiceServer) DoHandshake(HandshakerService_DoHandshakeServer) error {
return status.Errorf(codes.Unimplemented, "method DoHandshake not implemented")
}
// RegisterHandshakerServiceServer registers a service implementation with a gRPC server.
func RegisterHandshakerServiceServer(s grpc.ServiceRegistrar, srv HandshakerServiceServer) {
str := &HandshakerServiceService{
DoHandshake: srv.DoHandshake,
}
RegisterHandshakerServiceService(s, str)
}

View File

@ -4,13 +4,9 @@
package google_security_meshca_v1
import (
context "context"
fmt "fmt"
proto "github.com/golang/protobuf/proto"
duration "github.com/golang/protobuf/ptypes/duration"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
math "math"
)
@ -157,87 +153,3 @@ var fileDescriptor_f72841047b94fe5e = []byte{
0x75, 0x36, 0xec, 0xba, 0x62, 0xee, 0x66, 0x99, 0x93, 0xe5, 0x45, 0xb7, 0xcf, 0xc3, 0x77, 0x00,
0x00, 0x00, 0xff, 0xff, 0xb7, 0x0d, 0xfd, 0xff, 0xf7, 0x01, 0x00, 0x00,
}
// Reference imports to suppress errors if they are not otherwise used.
var _ context.Context
var _ grpc.ClientConnInterface
// 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.SupportPackageIsVersion6
// MeshCertificateServiceClient is the client API for MeshCertificateService service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type MeshCertificateServiceClient interface {
// Using provided CSR, returns a signed certificate that represents a GCP
// service account identity.
CreateCertificate(ctx context.Context, in *MeshCertificateRequest, opts ...grpc.CallOption) (*MeshCertificateResponse, error)
}
type meshCertificateServiceClient struct {
cc grpc.ClientConnInterface
}
func NewMeshCertificateServiceClient(cc grpc.ClientConnInterface) MeshCertificateServiceClient {
return &meshCertificateServiceClient{cc}
}
func (c *meshCertificateServiceClient) CreateCertificate(ctx context.Context, in *MeshCertificateRequest, opts ...grpc.CallOption) (*MeshCertificateResponse, error) {
out := new(MeshCertificateResponse)
err := c.cc.Invoke(ctx, "/google.security.meshca.v1.MeshCertificateService/CreateCertificate", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// MeshCertificateServiceServer is the server API for MeshCertificateService service.
type MeshCertificateServiceServer interface {
// Using provided CSR, returns a signed certificate that represents a GCP
// service account identity.
CreateCertificate(context.Context, *MeshCertificateRequest) (*MeshCertificateResponse, error)
}
// UnimplementedMeshCertificateServiceServer can be embedded to have forward compatible implementations.
type UnimplementedMeshCertificateServiceServer struct {
}
func (*UnimplementedMeshCertificateServiceServer) CreateCertificate(ctx context.Context, req *MeshCertificateRequest) (*MeshCertificateResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method CreateCertificate not implemented")
}
func RegisterMeshCertificateServiceServer(s *grpc.Server, srv MeshCertificateServiceServer) {
s.RegisterService(&_MeshCertificateService_serviceDesc, srv)
}
func _MeshCertificateService_CreateCertificate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(MeshCertificateRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(MeshCertificateServiceServer).CreateCertificate(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/google.security.meshca.v1.MeshCertificateService/CreateCertificate",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(MeshCertificateServiceServer).CreateCertificate(ctx, req.(*MeshCertificateRequest))
}
return interceptor(ctx, in, info, handler)
}
var _MeshCertificateService_serviceDesc = grpc.ServiceDesc{
ServiceName: "google.security.meshca.v1.MeshCertificateService",
HandlerType: (*MeshCertificateServiceServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "CreateCertificate",
Handler: _MeshCertificateService_CreateCertificate_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "istio/google/security/meshca/v1/meshca.proto",
}

View File

@ -13,6 +13,36 @@ import (
// is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion7
// MeshCertificateServiceClient is the client API for MeshCertificateService service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type MeshCertificateServiceClient interface {
// Using provided CSR, returns a signed certificate that represents a GCP
// service account identity.
CreateCertificate(ctx context.Context, in *MeshCertificateRequest, opts ...grpc.CallOption) (*MeshCertificateResponse, error)
}
type meshCertificateServiceClient struct {
cc grpc.ClientConnInterface
}
func NewMeshCertificateServiceClient(cc grpc.ClientConnInterface) MeshCertificateServiceClient {
return &meshCertificateServiceClient{cc}
}
var meshCertificateServiceCreateCertificateStreamDesc = &grpc.StreamDesc{
StreamName: "CreateCertificate",
}
func (c *meshCertificateServiceClient) CreateCertificate(ctx context.Context, in *MeshCertificateRequest, opts ...grpc.CallOption) (*MeshCertificateResponse, error) {
out := new(MeshCertificateResponse)
err := c.cc.Invoke(ctx, "/google.security.meshca.v1.MeshCertificateService/CreateCertificate", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// MeshCertificateServiceService is the service API for MeshCertificateService service.
// Fields should be assigned to their respective handler implementations only before
// RegisterMeshCertificateServiceService is called. Any unassigned fields will result in the
@ -64,28 +94,29 @@ func RegisterMeshCertificateServiceService(s grpc.ServiceRegistrar, srv *MeshCer
s.RegisterService(&sd, nil)
}
// NewMeshCertificateServiceService creates a new MeshCertificateServiceService containing the
// implemented methods of the MeshCertificateService service in s. Any unimplemented
// methods will result in the gRPC server returning an UNIMPLEMENTED status to the client.
// This includes situations where the method handler is misspelled or has the wrong
// signature. For this reason, this function should be used with great care and
// is not recommended to be used by most users.
func NewMeshCertificateServiceService(s interface{}) *MeshCertificateServiceService {
ns := &MeshCertificateServiceService{}
if h, ok := s.(interface {
CreateCertificate(context.Context, *MeshCertificateRequest) (*MeshCertificateResponse, error)
}); ok {
ns.CreateCertificate = h.CreateCertificate
}
return ns
}
// UnstableMeshCertificateServiceService is the service API for MeshCertificateService service.
// MeshCertificateServiceServer is the service API for MeshCertificateService service.
// New methods may be added to this interface if they are added to the service
// definition, which is not a backward-compatible change. For this reason,
// use of this type is not recommended.
type UnstableMeshCertificateServiceService interface {
// use of this type is not recommended unless you own the service definition.
type MeshCertificateServiceServer interface {
// Using provided CSR, returns a signed certificate that represents a GCP
// service account identity.
CreateCertificate(context.Context, *MeshCertificateRequest) (*MeshCertificateResponse, error)
}
// UnimplementedMeshCertificateServiceServer can be embedded to have forward compatible implementations of
// MeshCertificateServiceServer
type UnimplementedMeshCertificateServiceServer struct {
}
func (*UnimplementedMeshCertificateServiceServer) CreateCertificate(context.Context, *MeshCertificateRequest) (*MeshCertificateResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method CreateCertificate not implemented")
}
// RegisterMeshCertificateServiceServer registers a service implementation with a gRPC server.
func RegisterMeshCertificateServiceServer(s grpc.ServiceRegistrar, srv MeshCertificateServiceServer) {
str := &MeshCertificateServiceService{
CreateCertificate: srv.CreateCertificate,
}
RegisterMeshCertificateServiceService(s, str)
}

View File

@ -318,49 +318,3 @@ func RegisterEchoService(s grpc.ServiceRegistrar, srv *EchoService) {
s.RegisterService(&sd, nil)
}
// NewEchoService creates a new EchoService containing the
// implemented methods of the Echo service in s. Any unimplemented
// methods will result in the gRPC server returning an UNIMPLEMENTED status to the client.
// This includes situations where the method handler is misspelled or has the wrong
// signature. For this reason, this function should be used with great care and
// is not recommended to be used by most users.
func NewEchoService(s interface{}) *EchoService {
ns := &EchoService{}
if h, ok := s.(interface {
UnaryEcho(context.Context, *EchoRequest) (*EchoResponse, error)
}); ok {
ns.UnaryEcho = h.UnaryEcho
}
if h, ok := s.(interface {
ServerStreamingEcho(*EchoRequest, Echo_ServerStreamingEchoServer) error
}); ok {
ns.ServerStreamingEcho = h.ServerStreamingEcho
}
if h, ok := s.(interface {
ClientStreamingEcho(Echo_ClientStreamingEchoServer) error
}); ok {
ns.ClientStreamingEcho = h.ClientStreamingEcho
}
if h, ok := s.(interface {
BidirectionalStreamingEcho(Echo_BidirectionalStreamingEchoServer) error
}); ok {
ns.BidirectionalStreamingEcho = h.BidirectionalStreamingEcho
}
return ns
}
// UnstableEchoService is the service API for Echo service.
// New methods may be added to this interface if they are added to the service
// definition, which is not a backward-compatible change. For this reason,
// use of this type is not recommended.
type UnstableEchoService interface {
// UnaryEcho is unary echo.
UnaryEcho(context.Context, *EchoRequest) (*EchoResponse, error)
// ServerStreamingEcho is server side streaming.
ServerStreamingEcho(*EchoRequest, Echo_ServerStreamingEchoServer) error
// ClientStreamingEcho is client side streaming.
ClientStreamingEcho(Echo_ClientStreamingEchoServer) error
// BidirectionalStreamingEcho is bidi streaming.
BidirectionalStreamingEcho(Echo_BidirectionalStreamingEchoServer) error
}

View File

@ -91,28 +91,3 @@ func RegisterGreeterService(s grpc.ServiceRegistrar, srv *GreeterService) {
s.RegisterService(&sd, nil)
}
// NewGreeterService creates a new GreeterService containing the
// implemented methods of the Greeter service in s. Any unimplemented
// methods will result in the gRPC server returning an UNIMPLEMENTED status to the client.
// This includes situations where the method handler is misspelled or has the wrong
// signature. For this reason, this function should be used with great care and
// is not recommended to be used by most users.
func NewGreeterService(s interface{}) *GreeterService {
ns := &GreeterService{}
if h, ok := s.(interface {
SayHello(context.Context, *HelloRequest) (*HelloReply, error)
}); ok {
ns.SayHello = h.SayHello
}
return ns
}
// UnstableGreeterService is the service API for Greeter service.
// New methods may be added to this interface if they are added to the service
// definition, which is not a backward-compatible change. For this reason,
// use of this type is not recommended.
type UnstableGreeterService interface {
// Sends a greeting
SayHello(context.Context, *HelloRequest) (*HelloReply, error)
}

View File

@ -350,65 +350,3 @@ func RegisterRouteGuideService(s grpc.ServiceRegistrar, srv *RouteGuideService)
s.RegisterService(&sd, nil)
}
// NewRouteGuideService creates a new RouteGuideService containing the
// implemented methods of the RouteGuide service in s. Any unimplemented
// methods will result in the gRPC server returning an UNIMPLEMENTED status to the client.
// This includes situations where the method handler is misspelled or has the wrong
// signature. For this reason, this function should be used with great care and
// is not recommended to be used by most users.
func NewRouteGuideService(s interface{}) *RouteGuideService {
ns := &RouteGuideService{}
if h, ok := s.(interface {
GetFeature(context.Context, *Point) (*Feature, error)
}); ok {
ns.GetFeature = h.GetFeature
}
if h, ok := s.(interface {
ListFeatures(*Rectangle, RouteGuide_ListFeaturesServer) error
}); ok {
ns.ListFeatures = h.ListFeatures
}
if h, ok := s.(interface {
RecordRoute(RouteGuide_RecordRouteServer) error
}); ok {
ns.RecordRoute = h.RecordRoute
}
if h, ok := s.(interface {
RouteChat(RouteGuide_RouteChatServer) error
}); ok {
ns.RouteChat = h.RouteChat
}
return ns
}
// UnstableRouteGuideService is the service API for RouteGuide service.
// New methods may be added to this interface if they are added to the service
// definition, which is not a backward-compatible change. For this reason,
// use of this type is not recommended.
type UnstableRouteGuideService interface {
// A simple RPC.
//
// Obtains the feature at a given position.
//
// A feature with an empty name is returned if there's no feature at the given
// position.
GetFeature(context.Context, *Point) (*Feature, error)
// A server-to-client streaming RPC.
//
// Obtains the Features available within the given Rectangle. Results are
// streamed rather than returned at once (e.g. in a response message with a
// repeated field), as the rectangle may cover a large area and contain a
// huge number of features.
ListFeatures(*Rectangle, RouteGuide_ListFeaturesServer) error
// A client-to-server streaming RPC.
//
// Accepts a stream of Points on a route being traversed, returning a
// RouteSummary when traversal is completed.
RecordRoute(RouteGuide_RecordRouteServer) error
// A Bidirectional streaming RPC.
//
// Accepts a stream of RouteNotes sent while a route is being traversed,
// while receiving other RouteNotes (e.g. from other users).
RouteChat(RouteGuide_RouteChatServer) error
}

View File

@ -60,6 +60,15 @@ type routeGuideServer struct {
routeNotes map[string][]*pb.RouteNote
}
func (s *routeGuideServer) Svc() *pb.RouteGuideService {
return &pb.RouteGuideService{
GetFeature: s.GetFeature,
ListFeatures: s.ListFeatures,
RecordRoute: s.RecordRoute,
RouteChat: s.RouteChat,
}
}
// GetFeature returns the feature at the given point.
func (s *routeGuideServer) GetFeature(ctx context.Context, point *pb.Point) (*pb.Feature, error) {
for _, feature := range s.savedFeatures {
@ -237,7 +246,7 @@ func main() {
opts = []grpc.ServerOption{grpc.Creds(creds)}
}
grpcServer := grpc.NewServer(opts...)
pb.RegisterRouteGuideService(grpcServer, pb.NewRouteGuideService(newServer()))
pb.RegisterRouteGuideService(grpcServer, newServer().Svc())
grpcServer.Serve(lis)
}

View File

@ -4,12 +4,8 @@
package grpc_health_v1
import (
context "context"
fmt "fmt"
proto "github.com/golang/protobuf/proto"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
math "math"
)
@ -163,181 +159,3 @@ var fileDescriptor_e265fd9d4e077217 = []byte{
0xd3, 0x20, 0x46, 0xe8, 0x85, 0x19, 0x26, 0xb1, 0x81, 0x93, 0x83, 0x31, 0x20, 0x00, 0x00, 0xff,
0xff, 0x12, 0x7d, 0x96, 0xcb, 0x2d, 0x02, 0x00, 0x00,
}
// Reference imports to suppress errors if they are not otherwise used.
var _ context.Context
var _ grpc.ClientConnInterface
// 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.SupportPackageIsVersion6
// HealthClient is the client API for Health service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type HealthClient interface {
// If the requested service is unknown, the call will fail with status
// NOT_FOUND.
Check(ctx context.Context, in *HealthCheckRequest, opts ...grpc.CallOption) (*HealthCheckResponse, error)
// Performs a watch for the serving status of the requested service.
// The server will immediately send back a message indicating the current
// serving status. It will then subsequently send a new message whenever
// the service's serving status changes.
//
// If the requested service is unknown when the call is received, the
// server will send a message setting the serving status to
// SERVICE_UNKNOWN but will *not* terminate the call. If at some
// future point, the serving status of the service becomes known, the
// server will send a new message with the service's serving status.
//
// If the call terminates with status UNIMPLEMENTED, then clients
// should assume this method is not supported and should not retry the
// call. If the call terminates with any other status (including OK),
// clients should retry the call with appropriate exponential backoff.
Watch(ctx context.Context, in *HealthCheckRequest, opts ...grpc.CallOption) (Health_WatchClient, error)
}
type healthClient struct {
cc grpc.ClientConnInterface
}
func NewHealthClient(cc grpc.ClientConnInterface) HealthClient {
return &healthClient{cc}
}
func (c *healthClient) Check(ctx context.Context, in *HealthCheckRequest, opts ...grpc.CallOption) (*HealthCheckResponse, error) {
out := new(HealthCheckResponse)
err := c.cc.Invoke(ctx, "/grpc.health.v1.Health/Check", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *healthClient) Watch(ctx context.Context, in *HealthCheckRequest, opts ...grpc.CallOption) (Health_WatchClient, error) {
stream, err := c.cc.NewStream(ctx, &_Health_serviceDesc.Streams[0], "/grpc.health.v1.Health/Watch", opts...)
if err != nil {
return nil, err
}
x := &healthWatchClient{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 Health_WatchClient interface {
Recv() (*HealthCheckResponse, error)
grpc.ClientStream
}
type healthWatchClient struct {
grpc.ClientStream
}
func (x *healthWatchClient) Recv() (*HealthCheckResponse, error) {
m := new(HealthCheckResponse)
if err := x.ClientStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
// HealthServer is the server API for Health service.
type HealthServer interface {
// If the requested service is unknown, the call will fail with status
// NOT_FOUND.
Check(context.Context, *HealthCheckRequest) (*HealthCheckResponse, error)
// Performs a watch for the serving status of the requested service.
// The server will immediately send back a message indicating the current
// serving status. It will then subsequently send a new message whenever
// the service's serving status changes.
//
// If the requested service is unknown when the call is received, the
// server will send a message setting the serving status to
// SERVICE_UNKNOWN but will *not* terminate the call. If at some
// future point, the serving status of the service becomes known, the
// server will send a new message with the service's serving status.
//
// If the call terminates with status UNIMPLEMENTED, then clients
// should assume this method is not supported and should not retry the
// call. If the call terminates with any other status (including OK),
// clients should retry the call with appropriate exponential backoff.
Watch(*HealthCheckRequest, Health_WatchServer) error
}
// UnimplementedHealthServer can be embedded to have forward compatible implementations.
type UnimplementedHealthServer struct {
}
func (*UnimplementedHealthServer) Check(ctx context.Context, req *HealthCheckRequest) (*HealthCheckResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Check not implemented")
}
func (*UnimplementedHealthServer) Watch(req *HealthCheckRequest, srv Health_WatchServer) error {
return status.Errorf(codes.Unimplemented, "method Watch not implemented")
}
func RegisterHealthServer(s *grpc.Server, srv HealthServer) {
s.RegisterService(&_Health_serviceDesc, srv)
}
func _Health_Check_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(HealthCheckRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(HealthServer).Check(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/grpc.health.v1.Health/Check",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(HealthServer).Check(ctx, req.(*HealthCheckRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Health_Watch_Handler(srv interface{}, stream grpc.ServerStream) error {
m := new(HealthCheckRequest)
if err := stream.RecvMsg(m); err != nil {
return err
}
return srv.(HealthServer).Watch(m, &healthWatchServer{stream})
}
type Health_WatchServer interface {
Send(*HealthCheckResponse) error
grpc.ServerStream
}
type healthWatchServer struct {
grpc.ServerStream
}
func (x *healthWatchServer) Send(m *HealthCheckResponse) error {
return x.ServerStream.SendMsg(m)
}
var _Health_serviceDesc = grpc.ServiceDesc{
ServiceName: "grpc.health.v1.Health",
HandlerType: (*HealthServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Check",
Handler: _Health_Check_Handler,
},
},
Streams: []grpc.StreamDesc{
{
StreamName: "Watch",
Handler: _Health_Watch_Handler,
ServerStreams: true,
},
},
Metadata: "grpc/health/v1/health.proto",
}

View File

@ -13,6 +13,89 @@ import (
// is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion7
// HealthClient is the client API for Health service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type HealthClient interface {
// If the requested service is unknown, the call will fail with status
// NOT_FOUND.
Check(ctx context.Context, in *HealthCheckRequest, opts ...grpc.CallOption) (*HealthCheckResponse, error)
// Performs a watch for the serving status of the requested service.
// The server will immediately send back a message indicating the current
// serving status. It will then subsequently send a new message whenever
// the service's serving status changes.
//
// If the requested service is unknown when the call is received, the
// server will send a message setting the serving status to
// SERVICE_UNKNOWN but will *not* terminate the call. If at some
// future point, the serving status of the service becomes known, the
// server will send a new message with the service's serving status.
//
// If the call terminates with status UNIMPLEMENTED, then clients
// should assume this method is not supported and should not retry the
// call. If the call terminates with any other status (including OK),
// clients should retry the call with appropriate exponential backoff.
Watch(ctx context.Context, in *HealthCheckRequest, opts ...grpc.CallOption) (Health_WatchClient, error)
}
type healthClient struct {
cc grpc.ClientConnInterface
}
func NewHealthClient(cc grpc.ClientConnInterface) HealthClient {
return &healthClient{cc}
}
var healthCheckStreamDesc = &grpc.StreamDesc{
StreamName: "Check",
}
func (c *healthClient) Check(ctx context.Context, in *HealthCheckRequest, opts ...grpc.CallOption) (*HealthCheckResponse, error) {
out := new(HealthCheckResponse)
err := c.cc.Invoke(ctx, "/grpc.health.v1.Health/Check", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
var healthWatchStreamDesc = &grpc.StreamDesc{
StreamName: "Watch",
ServerStreams: true,
}
func (c *healthClient) Watch(ctx context.Context, in *HealthCheckRequest, opts ...grpc.CallOption) (Health_WatchClient, error) {
stream, err := c.cc.NewStream(ctx, healthWatchStreamDesc, "/grpc.health.v1.Health/Watch", opts...)
if err != nil {
return nil, err
}
x := &healthWatchClient{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 Health_WatchClient interface {
Recv() (*HealthCheckResponse, error)
grpc.ClientStream
}
type healthWatchClient struct {
grpc.ClientStream
}
func (x *healthWatchClient) Recv() (*HealthCheckResponse, error) {
m := new(HealthCheckResponse)
if err := x.ClientStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
// HealthService is the service API for Health service.
// Fields should be assigned to their respective handler implementations only before
// RegisterHealthService is called. Any unassigned fields will result in the
@ -64,6 +147,19 @@ func (s *HealthService) watch(_ interface{}, stream grpc.ServerStream) error {
return s.Watch(m, &healthWatchServer{stream})
}
type Health_WatchServer interface {
Send(*HealthCheckResponse) error
grpc.ServerStream
}
type healthWatchServer struct {
grpc.ServerStream
}
func (x *healthWatchServer) Send(m *HealthCheckResponse) error {
return x.ServerStream.SendMsg(m)
}
// RegisterHealthService registers a service implementation with a gRPC server.
func RegisterHealthService(s grpc.ServiceRegistrar, srv *HealthService) {
srvCopy := *srv
@ -98,32 +194,11 @@ func RegisterHealthService(s grpc.ServiceRegistrar, srv *HealthService) {
s.RegisterService(&sd, nil)
}
// NewHealthService creates a new HealthService containing the
// implemented methods of the Health service in s. Any unimplemented
// methods will result in the gRPC server returning an UNIMPLEMENTED status to the client.
// This includes situations where the method handler is misspelled or has the wrong
// signature. For this reason, this function should be used with great care and
// is not recommended to be used by most users.
func NewHealthService(s interface{}) *HealthService {
ns := &HealthService{}
if h, ok := s.(interface {
Check(context.Context, *HealthCheckRequest) (*HealthCheckResponse, error)
}); ok {
ns.Check = h.Check
}
if h, ok := s.(interface {
Watch(*HealthCheckRequest, Health_WatchServer) error
}); ok {
ns.Watch = h.Watch
}
return ns
}
// UnstableHealthService is the service API for Health service.
// HealthServer is the service API for Health service.
// New methods may be added to this interface if they are added to the service
// definition, which is not a backward-compatible change. For this reason,
// use of this type is not recommended.
type UnstableHealthService interface {
// use of this type is not recommended unless you own the service definition.
type HealthServer interface {
// If the requested service is unknown, the call will fail with status
// NOT_FOUND.
Check(context.Context, *HealthCheckRequest) (*HealthCheckResponse, error)
@ -144,3 +219,24 @@ type UnstableHealthService interface {
// clients should retry the call with appropriate exponential backoff.
Watch(*HealthCheckRequest, Health_WatchServer) error
}
// UnimplementedHealthServer can be embedded to have forward compatible implementations of
// HealthServer
type UnimplementedHealthServer struct {
}
func (*UnimplementedHealthServer) Check(context.Context, *HealthCheckRequest) (*HealthCheckResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Check not implemented")
}
func (*UnimplementedHealthServer) Watch(*HealthCheckRequest, Health_WatchServer) error {
return status.Errorf(codes.Unimplemented, "method Watch not implemented")
}
// RegisterHealthServer registers a service implementation with a gRPC server.
func RegisterHealthServer(s grpc.ServiceRegistrar, srv HealthServer) {
str := &HealthService{
Check: srv.Check,
Watch: srv.Watch,
}
RegisterHealthService(s, str)
}

View File

@ -118,7 +118,14 @@ type testServer struct {
te *test
}
var _ testpb.UnstableTestServiceService = (*testServer)(nil)
func (s *testServer) Svc() *testpb.TestServiceService {
return &testpb.TestServiceService{
UnaryCall: s.UnaryCall,
FullDuplexCall: s.FullDuplexCall,
ClientStreamCall: s.ClientStreamCall,
ServerStreamCall: s.ServerStreamCall,
}
}
func (s *testServer) UnaryCall(ctx context.Context, in *testpb.SimpleRequest) (*testpb.SimpleResponse, error) {
md, ok := metadata.FromIncomingContext(ctx)
@ -784,7 +791,7 @@ func (ed *expectedData) toServerLogEntries() []*pb.GrpcLogEntry {
func runRPCs(t *testing.T, tc *testConfig, cc *rpcConfig) *expectedData {
te := newTest(t, tc)
te.startServer(testpb.NewTestServiceService(&testServer{te: te}))
te.startServer((&testServer{te: te}).Svc())
defer te.tearDown()
expect := &expectedData{

View File

@ -455,74 +455,6 @@ func RegisterTestServiceService(s grpc.ServiceRegistrar, srv *TestServiceService
s.RegisterService(&sd, nil)
}
// NewTestServiceService creates a new TestServiceService containing the
// implemented methods of the TestService service in s. Any unimplemented
// methods will result in the gRPC server returning an UNIMPLEMENTED status to the client.
// This includes situations where the method handler is misspelled or has the wrong
// signature. For this reason, this function should be used with great care and
// is not recommended to be used by most users.
func NewTestServiceService(s interface{}) *TestServiceService {
ns := &TestServiceService{}
if h, ok := s.(interface {
EmptyCall(context.Context, *Empty) (*Empty, error)
}); ok {
ns.EmptyCall = h.EmptyCall
}
if h, ok := s.(interface {
UnaryCall(context.Context, *SimpleRequest) (*SimpleResponse, error)
}); ok {
ns.UnaryCall = h.UnaryCall
}
if h, ok := s.(interface {
StreamingOutputCall(*StreamingOutputCallRequest, TestService_StreamingOutputCallServer) error
}); ok {
ns.StreamingOutputCall = h.StreamingOutputCall
}
if h, ok := s.(interface {
StreamingInputCall(TestService_StreamingInputCallServer) error
}); ok {
ns.StreamingInputCall = h.StreamingInputCall
}
if h, ok := s.(interface {
FullDuplexCall(TestService_FullDuplexCallServer) error
}); ok {
ns.FullDuplexCall = h.FullDuplexCall
}
if h, ok := s.(interface {
HalfDuplexCall(TestService_HalfDuplexCallServer) error
}); ok {
ns.HalfDuplexCall = h.HalfDuplexCall
}
return ns
}
// UnstableTestServiceService is the service API for TestService service.
// New methods may be added to this interface if they are added to the service
// definition, which is not a backward-compatible change. For this reason,
// use of this type is not recommended.
type UnstableTestServiceService interface {
// One empty request followed by one empty response.
EmptyCall(context.Context, *Empty) (*Empty, error)
// One request followed by one response.
// The server returns the client payload as-is.
UnaryCall(context.Context, *SimpleRequest) (*SimpleResponse, error)
// One request followed by a sequence of responses (streamed download).
// The server returns the payload with client desired type and sizes.
StreamingOutputCall(*StreamingOutputCallRequest, TestService_StreamingOutputCallServer) error
// A sequence of requests followed by one response (streamed upload).
// The server returns the aggregated size of client payload as the result.
StreamingInputCall(TestService_StreamingInputCallServer) error
// A sequence of requests with each request served by the server immediately.
// As one request could lead to multiple responses, this interface
// demonstrates the idea of full duplexing.
FullDuplexCall(TestService_FullDuplexCallServer) error
// A sequence of requests followed by a sequence of responses.
// The server buffers all the client requests and then serves them in order. A
// stream of responses are returned to the client when the server starts with
// first request.
HalfDuplexCall(TestService_HalfDuplexCallServer) error
}
// UnimplementedServiceClient is the client API for UnimplementedService service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
@ -602,31 +534,6 @@ func RegisterUnimplementedServiceService(s grpc.ServiceRegistrar, srv *Unimpleme
s.RegisterService(&sd, nil)
}
// NewUnimplementedServiceService creates a new UnimplementedServiceService containing the
// implemented methods of the UnimplementedService service in s. Any unimplemented
// methods will result in the gRPC server returning an UNIMPLEMENTED status to the client.
// This includes situations where the method handler is misspelled or has the wrong
// signature. For this reason, this function should be used with great care and
// is not recommended to be used by most users.
func NewUnimplementedServiceService(s interface{}) *UnimplementedServiceService {
ns := &UnimplementedServiceService{}
if h, ok := s.(interface {
UnimplementedCall(context.Context, *Empty) (*Empty, error)
}); ok {
ns.UnimplementedCall = h.UnimplementedCall
}
return ns
}
// UnstableUnimplementedServiceService is the service API for UnimplementedService service.
// New methods may be added to this interface if they are added to the service
// definition, which is not a backward-compatible change. For this reason,
// use of this type is not recommended.
type UnstableUnimplementedServiceService interface {
// A call that no server should implement
UnimplementedCall(context.Context, *Empty) (*Empty, error)
}
// LoadBalancerStatsServiceClient is the client API for LoadBalancerStatsService service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
@ -705,28 +612,3 @@ func RegisterLoadBalancerStatsServiceService(s grpc.ServiceRegistrar, srv *LoadB
s.RegisterService(&sd, nil)
}
// NewLoadBalancerStatsServiceService creates a new LoadBalancerStatsServiceService containing the
// implemented methods of the LoadBalancerStatsService service in s. Any unimplemented
// methods will result in the gRPC server returning an UNIMPLEMENTED status to the client.
// This includes situations where the method handler is misspelled or has the wrong
// signature. For this reason, this function should be used with great care and
// is not recommended to be used by most users.
func NewLoadBalancerStatsServiceService(s interface{}) *LoadBalancerStatsServiceService {
ns := &LoadBalancerStatsServiceService{}
if h, ok := s.(interface {
GetClientStats(context.Context, *LoadBalancerStatsRequest) (*LoadBalancerStatsResponse, error)
}); ok {
ns.GetClientStats = h.GetClientStats
}
return ns
}
// UnstableLoadBalancerStatsServiceService is the service API for LoadBalancerStatsService service.
// New methods may be added to this interface if they are added to the service
// definition, which is not a backward-compatible change. For this reason,
// use of this type is not recommended.
type UnstableLoadBalancerStatsServiceService interface {
// Gets the backend distribution for RPCs sent by a test client.
GetClientStats(context.Context, *LoadBalancerStatsRequest) (*LoadBalancerStatsResponse, error)
}

View File

@ -677,7 +677,15 @@ type testServer struct{}
// NewTestServer creates a test server for test service.
func NewTestServer() *testpb.TestServiceService {
return testpb.NewTestServiceService(testpb.UnstableTestServiceService(&testServer{}))
s := testServer{}
return &testpb.TestServiceService{
EmptyCall: s.EmptyCall,
UnaryCall: s.UnaryCall,
StreamingOutputCall: s.StreamingOutputCall,
StreamingInputCall: s.StreamingInputCall,
FullDuplexCall: s.FullDuplexCall,
HalfDuplexCall: s.HalfDuplexCall,
}
}
func (s *testServer) EmptyCall(ctx context.Context, in *testpb.Empty) (*testpb.Empty, error) {

View File

@ -4,12 +4,8 @@
package proto
import (
context "context"
fmt "fmt"
proto "github.com/golang/protobuf/proto"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
math "math"
)
@ -366,125 +362,3 @@ var fileDescriptor_e1ab2aa17b47c6fb = []byte{
0x95, 0xbb, 0x2e, 0xf9, 0xc9, 0xfd, 0xaf, 0x42, 0xfa, 0xbc, 0xf9, 0x13, 0x00, 0x00, 0xff, 0xff,
0x5d, 0x47, 0x09, 0xa9, 0x19, 0x03, 0x00, 0x00,
}
// Reference imports to suppress errors if they are not otherwise used.
var _ context.Context
var _ grpc.ClientConnInterface
// 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.SupportPackageIsVersion6
// ProfilingClient is the client API for Profiling service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type ProfilingClient interface {
// Enable allows users to toggle profiling on and off remotely.
Enable(ctx context.Context, in *EnableRequest, opts ...grpc.CallOption) (*EnableResponse, error)
// GetStreamStats is used to retrieve an array of stream-level stats from a
// gRPC client/server.
GetStreamStats(ctx context.Context, in *GetStreamStatsRequest, opts ...grpc.CallOption) (*GetStreamStatsResponse, error)
}
type profilingClient struct {
cc grpc.ClientConnInterface
}
func NewProfilingClient(cc grpc.ClientConnInterface) ProfilingClient {
return &profilingClient{cc}
}
func (c *profilingClient) Enable(ctx context.Context, in *EnableRequest, opts ...grpc.CallOption) (*EnableResponse, error) {
out := new(EnableResponse)
err := c.cc.Invoke(ctx, "/grpc.go.profiling.v1alpha.Profiling/Enable", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *profilingClient) GetStreamStats(ctx context.Context, in *GetStreamStatsRequest, opts ...grpc.CallOption) (*GetStreamStatsResponse, error) {
out := new(GetStreamStatsResponse)
err := c.cc.Invoke(ctx, "/grpc.go.profiling.v1alpha.Profiling/GetStreamStats", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// ProfilingServer is the server API for Profiling service.
type ProfilingServer interface {
// Enable allows users to toggle profiling on and off remotely.
Enable(context.Context, *EnableRequest) (*EnableResponse, error)
// GetStreamStats is used to retrieve an array of stream-level stats from a
// gRPC client/server.
GetStreamStats(context.Context, *GetStreamStatsRequest) (*GetStreamStatsResponse, error)
}
// UnimplementedProfilingServer can be embedded to have forward compatible implementations.
type UnimplementedProfilingServer struct {
}
func (*UnimplementedProfilingServer) Enable(ctx context.Context, req *EnableRequest) (*EnableResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Enable not implemented")
}
func (*UnimplementedProfilingServer) GetStreamStats(ctx context.Context, req *GetStreamStatsRequest) (*GetStreamStatsResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetStreamStats not implemented")
}
func RegisterProfilingServer(s *grpc.Server, srv ProfilingServer) {
s.RegisterService(&_Profiling_serviceDesc, srv)
}
func _Profiling_Enable_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(EnableRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ProfilingServer).Enable(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/grpc.go.profiling.v1alpha.Profiling/Enable",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ProfilingServer).Enable(ctx, req.(*EnableRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Profiling_GetStreamStats_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetStreamStatsRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ProfilingServer).GetStreamStats(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/grpc.go.profiling.v1alpha.Profiling/GetStreamStats",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ProfilingServer).GetStreamStats(ctx, req.(*GetStreamStatsRequest))
}
return interceptor(ctx, in, info, handler)
}
var _Profiling_serviceDesc = grpc.ServiceDesc{
ServiceName: "grpc.go.profiling.v1alpha.Profiling",
HandlerType: (*ProfilingServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Enable",
Handler: _Profiling_Enable_Handler,
},
{
MethodName: "GetStreamStats",
Handler: _Profiling_GetStreamStats_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "profiling/proto/service.proto",
}

View File

@ -13,6 +13,51 @@ import (
// is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion7
// ProfilingClient is the client API for Profiling service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type ProfilingClient interface {
// Enable allows users to toggle profiling on and off remotely.
Enable(ctx context.Context, in *EnableRequest, opts ...grpc.CallOption) (*EnableResponse, error)
// GetStreamStats is used to retrieve an array of stream-level stats from a
// gRPC client/server.
GetStreamStats(ctx context.Context, in *GetStreamStatsRequest, opts ...grpc.CallOption) (*GetStreamStatsResponse, error)
}
type profilingClient struct {
cc grpc.ClientConnInterface
}
func NewProfilingClient(cc grpc.ClientConnInterface) ProfilingClient {
return &profilingClient{cc}
}
var profilingEnableStreamDesc = &grpc.StreamDesc{
StreamName: "Enable",
}
func (c *profilingClient) Enable(ctx context.Context, in *EnableRequest, opts ...grpc.CallOption) (*EnableResponse, error) {
out := new(EnableResponse)
err := c.cc.Invoke(ctx, "/grpc.go.profiling.v1alpha.Profiling/Enable", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
var profilingGetStreamStatsStreamDesc = &grpc.StreamDesc{
StreamName: "GetStreamStats",
}
func (c *profilingClient) GetStreamStats(ctx context.Context, in *GetStreamStatsRequest, opts ...grpc.CallOption) (*GetStreamStatsResponse, error) {
out := new(GetStreamStatsResponse)
err := c.cc.Invoke(ctx, "/grpc.go.profiling.v1alpha.Profiling/GetStreamStats", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// ProfilingService is the service API for Profiling service.
// Fields should be assigned to their respective handler implementations only before
// RegisterProfilingService is called. Any unassigned fields will result in the
@ -92,35 +137,35 @@ func RegisterProfilingService(s grpc.ServiceRegistrar, srv *ProfilingService) {
s.RegisterService(&sd, nil)
}
// NewProfilingService creates a new ProfilingService containing the
// implemented methods of the Profiling service in s. Any unimplemented
// methods will result in the gRPC server returning an UNIMPLEMENTED status to the client.
// This includes situations where the method handler is misspelled or has the wrong
// signature. For this reason, this function should be used with great care and
// is not recommended to be used by most users.
func NewProfilingService(s interface{}) *ProfilingService {
ns := &ProfilingService{}
if h, ok := s.(interface {
Enable(context.Context, *EnableRequest) (*EnableResponse, error)
}); ok {
ns.Enable = h.Enable
}
if h, ok := s.(interface {
GetStreamStats(context.Context, *GetStreamStatsRequest) (*GetStreamStatsResponse, error)
}); ok {
ns.GetStreamStats = h.GetStreamStats
}
return ns
}
// UnstableProfilingService is the service API for Profiling service.
// ProfilingServer is the service API for Profiling service.
// New methods may be added to this interface if they are added to the service
// definition, which is not a backward-compatible change. For this reason,
// use of this type is not recommended.
type UnstableProfilingService interface {
// use of this type is not recommended unless you own the service definition.
type ProfilingServer interface {
// Enable allows users to toggle profiling on and off remotely.
Enable(context.Context, *EnableRequest) (*EnableResponse, error)
// GetStreamStats is used to retrieve an array of stream-level stats from a
// gRPC client/server.
GetStreamStats(context.Context, *GetStreamStatsRequest) (*GetStreamStatsResponse, error)
}
// UnimplementedProfilingServer can be embedded to have forward compatible implementations of
// ProfilingServer
type UnimplementedProfilingServer struct {
}
func (*UnimplementedProfilingServer) Enable(context.Context, *EnableRequest) (*EnableResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Enable not implemented")
}
func (*UnimplementedProfilingServer) GetStreamStats(context.Context, *GetStreamStatsRequest) (*GetStreamStatsResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetStreamStats not implemented")
}
// RegisterProfilingServer registers a service implementation with a gRPC server.
func RegisterProfilingServer(s grpc.ServiceRegistrar, srv ProfilingServer) {
str := &ProfilingService{
Enable: srv.Enable,
GetStreamStats: srv.GetStreamStats,
}
RegisterProfilingService(s, str)
}

View File

@ -4,12 +4,8 @@
package grpc_reflection_v1alpha
import (
context "context"
fmt "fmt"
proto "github.com/golang/protobuf/proto"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
math "math"
)
@ -636,119 +632,3 @@ var fileDescriptor_e8cf9f2921ad6c95 = []byte{
0xcb, 0xb3, 0xdb, 0x8c, 0xdb, 0xea, 0x53, 0xd5, 0xb9, 0xfd, 0xd3, 0x35, 0xdc, 0x54, 0xbe, 0x39,
0xfd, 0x1b, 0x00, 0x00, 0xff, 0xff, 0x6c, 0x74, 0x3a, 0x67, 0xe7, 0x06, 0x00, 0x00,
}
// Reference imports to suppress errors if they are not otherwise used.
var _ context.Context
var _ grpc.ClientConnInterface
// 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.SupportPackageIsVersion6
// ServerReflectionClient is the client API for ServerReflection service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type ServerReflectionClient interface {
// The reflection service is structured as a bidirectional stream, ensuring
// all related requests go to a single server.
ServerReflectionInfo(ctx context.Context, opts ...grpc.CallOption) (ServerReflection_ServerReflectionInfoClient, error)
}
type serverReflectionClient struct {
cc grpc.ClientConnInterface
}
func NewServerReflectionClient(cc grpc.ClientConnInterface) ServerReflectionClient {
return &serverReflectionClient{cc}
}
func (c *serverReflectionClient) ServerReflectionInfo(ctx context.Context, opts ...grpc.CallOption) (ServerReflection_ServerReflectionInfoClient, error) {
stream, err := c.cc.NewStream(ctx, &_ServerReflection_serviceDesc.Streams[0], "/grpc.reflection.v1alpha.ServerReflection/ServerReflectionInfo", opts...)
if err != nil {
return nil, err
}
x := &serverReflectionServerReflectionInfoClient{stream}
return x, nil
}
type ServerReflection_ServerReflectionInfoClient interface {
Send(*ServerReflectionRequest) error
Recv() (*ServerReflectionResponse, error)
grpc.ClientStream
}
type serverReflectionServerReflectionInfoClient struct {
grpc.ClientStream
}
func (x *serverReflectionServerReflectionInfoClient) Send(m *ServerReflectionRequest) error {
return x.ClientStream.SendMsg(m)
}
func (x *serverReflectionServerReflectionInfoClient) Recv() (*ServerReflectionResponse, error) {
m := new(ServerReflectionResponse)
if err := x.ClientStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
// ServerReflectionServer is the server API for ServerReflection service.
type ServerReflectionServer interface {
// The reflection service is structured as a bidirectional stream, ensuring
// all related requests go to a single server.
ServerReflectionInfo(ServerReflection_ServerReflectionInfoServer) error
}
// UnimplementedServerReflectionServer can be embedded to have forward compatible implementations.
type UnimplementedServerReflectionServer struct {
}
func (*UnimplementedServerReflectionServer) ServerReflectionInfo(srv ServerReflection_ServerReflectionInfoServer) error {
return status.Errorf(codes.Unimplemented, "method ServerReflectionInfo not implemented")
}
func RegisterServerReflectionServer(s *grpc.Server, srv ServerReflectionServer) {
s.RegisterService(&_ServerReflection_serviceDesc, srv)
}
func _ServerReflection_ServerReflectionInfo_Handler(srv interface{}, stream grpc.ServerStream) error {
return srv.(ServerReflectionServer).ServerReflectionInfo(&serverReflectionServerReflectionInfoServer{stream})
}
type ServerReflection_ServerReflectionInfoServer interface {
Send(*ServerReflectionResponse) error
Recv() (*ServerReflectionRequest, error)
grpc.ServerStream
}
type serverReflectionServerReflectionInfoServer struct {
grpc.ServerStream
}
func (x *serverReflectionServerReflectionInfoServer) Send(m *ServerReflectionResponse) error {
return x.ServerStream.SendMsg(m)
}
func (x *serverReflectionServerReflectionInfoServer) Recv() (*ServerReflectionRequest, error) {
m := new(ServerReflectionRequest)
if err := x.ServerStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
var _ServerReflection_serviceDesc = grpc.ServiceDesc{
ServiceName: "grpc.reflection.v1alpha.ServerReflection",
HandlerType: (*ServerReflectionServer)(nil),
Methods: []grpc.MethodDesc{},
Streams: []grpc.StreamDesc{
{
StreamName: "ServerReflectionInfo",
Handler: _ServerReflection_ServerReflectionInfo_Handler,
ServerStreams: true,
ClientStreams: true,
},
},
Metadata: "reflection/grpc_reflection_v1alpha/reflection.proto",
}

View File

@ -3,6 +3,7 @@
package grpc_reflection_v1alpha
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
@ -12,6 +13,60 @@ import (
// is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion7
// ServerReflectionClient is the client API for ServerReflection service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type ServerReflectionClient interface {
// The reflection service is structured as a bidirectional stream, ensuring
// all related requests go to a single server.
ServerReflectionInfo(ctx context.Context, opts ...grpc.CallOption) (ServerReflection_ServerReflectionInfoClient, error)
}
type serverReflectionClient struct {
cc grpc.ClientConnInterface
}
func NewServerReflectionClient(cc grpc.ClientConnInterface) ServerReflectionClient {
return &serverReflectionClient{cc}
}
var serverReflectionServerReflectionInfoStreamDesc = &grpc.StreamDesc{
StreamName: "ServerReflectionInfo",
ServerStreams: true,
ClientStreams: true,
}
func (c *serverReflectionClient) ServerReflectionInfo(ctx context.Context, opts ...grpc.CallOption) (ServerReflection_ServerReflectionInfoClient, error) {
stream, err := c.cc.NewStream(ctx, serverReflectionServerReflectionInfoStreamDesc, "/grpc.reflection.v1alpha.ServerReflection/ServerReflectionInfo", opts...)
if err != nil {
return nil, err
}
x := &serverReflectionServerReflectionInfoClient{stream}
return x, nil
}
type ServerReflection_ServerReflectionInfoClient interface {
Send(*ServerReflectionRequest) error
Recv() (*ServerReflectionResponse, error)
grpc.ClientStream
}
type serverReflectionServerReflectionInfoClient struct {
grpc.ClientStream
}
func (x *serverReflectionServerReflectionInfoClient) Send(m *ServerReflectionRequest) error {
return x.ClientStream.SendMsg(m)
}
func (x *serverReflectionServerReflectionInfoClient) Recv() (*ServerReflectionResponse, error) {
m := new(ServerReflectionResponse)
if err := x.ClientStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
// ServerReflectionService is the service API for ServerReflection service.
// Fields should be assigned to their respective handler implementations only before
// RegisterServerReflectionService is called. Any unassigned fields will result in the
@ -26,6 +81,28 @@ func (s *ServerReflectionService) serverReflectionInfo(_ interface{}, stream grp
return s.ServerReflectionInfo(&serverReflectionServerReflectionInfoServer{stream})
}
type ServerReflection_ServerReflectionInfoServer interface {
Send(*ServerReflectionResponse) error
Recv() (*ServerReflectionRequest, error)
grpc.ServerStream
}
type serverReflectionServerReflectionInfoServer struct {
grpc.ServerStream
}
func (x *serverReflectionServerReflectionInfoServer) Send(m *ServerReflectionResponse) error {
return x.ServerStream.SendMsg(m)
}
func (x *serverReflectionServerReflectionInfoServer) Recv() (*ServerReflectionRequest, error) {
m := new(ServerReflectionRequest)
if err := x.ServerStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
// RegisterServerReflectionService registers a service implementation with a gRPC server.
func RegisterServerReflectionService(s grpc.ServiceRegistrar, srv *ServerReflectionService) {
srvCopy := *srv
@ -51,28 +128,29 @@ func RegisterServerReflectionService(s grpc.ServiceRegistrar, srv *ServerReflect
s.RegisterService(&sd, nil)
}
// NewServerReflectionService creates a new ServerReflectionService containing the
// implemented methods of the ServerReflection service in s. Any unimplemented
// methods will result in the gRPC server returning an UNIMPLEMENTED status to the client.
// This includes situations where the method handler is misspelled or has the wrong
// signature. For this reason, this function should be used with great care and
// is not recommended to be used by most users.
func NewServerReflectionService(s interface{}) *ServerReflectionService {
ns := &ServerReflectionService{}
if h, ok := s.(interface {
ServerReflectionInfo(ServerReflection_ServerReflectionInfoServer) error
}); ok {
ns.ServerReflectionInfo = h.ServerReflectionInfo
}
return ns
}
// UnstableServerReflectionService is the service API for ServerReflection service.
// ServerReflectionServer is the service API for ServerReflection service.
// New methods may be added to this interface if they are added to the service
// definition, which is not a backward-compatible change. For this reason,
// use of this type is not recommended.
type UnstableServerReflectionService interface {
// use of this type is not recommended unless you own the service definition.
type ServerReflectionServer interface {
// The reflection service is structured as a bidirectional stream, ensuring
// all related requests go to a single server.
ServerReflectionInfo(ServerReflection_ServerReflectionInfoServer) error
}
// UnimplementedServerReflectionServer can be embedded to have forward compatible implementations of
// ServerReflectionServer
type UnimplementedServerReflectionServer struct {
}
func (*UnimplementedServerReflectionServer) ServerReflectionInfo(ServerReflection_ServerReflectionInfoServer) error {
return status.Errorf(codes.Unimplemented, "method ServerReflectionInfo not implemented")
}
// RegisterServerReflectionServer registers a service implementation with a gRPC server.
func RegisterServerReflectionServer(s grpc.ServiceRegistrar, srv ServerReflectionServer) {
str := &ServerReflectionService{
ServerReflectionInfo: srv.ServerReflectionInfo,
}
RegisterServerReflectionService(s, str)
}

View File

@ -165,33 +165,3 @@ func RegisterSearchServiceService(s grpc.ServiceRegistrar, srv *SearchServiceSer
s.RegisterService(&sd, nil)
}
// NewSearchServiceService creates a new SearchServiceService containing the
// implemented methods of the SearchService service in s. Any unimplemented
// methods will result in the gRPC server returning an UNIMPLEMENTED status to the client.
// This includes situations where the method handler is misspelled or has the wrong
// signature. For this reason, this function should be used with great care and
// is not recommended to be used by most users.
func NewSearchServiceService(s interface{}) *SearchServiceService {
ns := &SearchServiceService{}
if h, ok := s.(interface {
Search(context.Context, *SearchRequest) (*SearchResponse, error)
}); ok {
ns.Search = h.Search
}
if h, ok := s.(interface {
StreamingSearch(SearchService_StreamingSearchServer) error
}); ok {
ns.StreamingSearch = h.StreamingSearch
}
return ns
}
// UnstableSearchServiceService is the service API for SearchService service.
// New methods may be added to this interface if they are added to the service
// definition, which is not a backward-compatible change. For this reason,
// use of this type is not recommended.
type UnstableSearchServiceService interface {
Search(context.Context, *SearchRequest) (*SearchResponse, error)
StreamingSearch(SearchService_StreamingSearchServer) error
}

View File

@ -168,7 +168,12 @@ func (x) TestAllExtensionNumbersForType(t *testing.T) {
type server struct{}
var _ pb.UnstableSearchServiceService = (*server)(nil)
func (s *server) Svc() *pb.SearchServiceService {
return &pb.SearchServiceService{
Search: s.Search,
StreamingSearch: s.StreamingSearch,
}
}
func (s *server) Search(ctx context.Context, in *pb.SearchRequest) (*pb.SearchResponse, error) {
return &pb.SearchResponse{}, nil
@ -195,7 +200,7 @@ func (x) TestReflectionEnd2end(t *testing.T) {
t.Fatalf("failed to listen: %v", err)
}
s := grpc.NewServer()
pb.RegisterSearchServiceService(s, pb.NewSearchServiceService(&server{}))
pb.RegisterSearchServiceService(s, (&server{}).Svc())
pbv3.RegisterSearchServiceV3Server(s, &serverV3{})
// Register reflection service on s.
Register(s)

View File

@ -96,7 +96,7 @@ done
for src in ${LEGACY_SOURCES[@]}; do
echo "protoc ${src}"
protoc --go_out=${OPTS},plugins=grpc:${WORKDIR}/out --go-grpc_out=${OPTS},migration_mode=true:${WORKDIR}/out \
protoc --go_out=${OPTS}:${WORKDIR}/out --go-grpc_out=${OPTS},gen_unstable_server_interfaces=true:${WORKDIR}/out \
-I"." \
-I${WORKDIR}/grpc-proto \
-I${WORKDIR}/googleapis \

View File

@ -130,11 +130,8 @@ func (cs *certStore) loadCerts() error {
return nil
}
// serverImpl is used to implement pb.GreeterServer.
type serverImpl struct{}
// SayHello is a simple implementation of pb.GreeterServer.
func (s *serverImpl) SayHello(ctx context.Context, in *pb.HelloRequest) (*pb.HelloReply, error) {
// sayHello is a simple implementation of the pb.GreeterServer SayHello method.
func sayHello(ctx context.Context, in *pb.HelloRequest) (*pb.HelloReply, error) {
return &pb.HelloReply{Message: "Hello " + in.Name}, nil
}
@ -409,7 +406,7 @@ func (s) TestEnd2End(t *testing.T) {
t.Fatalf("failed to listen: %v", err)
}
defer lis.Close()
pb.RegisterGreeterService(s, pb.NewGreeterService(&serverImpl{}))
pb.RegisterGreeterService(s, &pb.GreeterService{SayHello: sayHello})
go s.Serve(lis)
clientOptions := &ClientOptions{
Certificates: test.clientCert,

View File

@ -324,52 +324,3 @@ func RegisterTestServiceService(s grpc.ServiceRegistrar, srv *TestServiceService
s.RegisterService(&sd, nil)
}
// NewTestServiceService creates a new TestServiceService containing the
// implemented methods of the TestService service in s. Any unimplemented
// methods will result in the gRPC server returning an UNIMPLEMENTED status to the client.
// This includes situations where the method handler is misspelled or has the wrong
// signature. For this reason, this function should be used with great care and
// is not recommended to be used by most users.
func NewTestServiceService(s interface{}) *TestServiceService {
ns := &TestServiceService{}
if h, ok := s.(interface {
UnaryCall(context.Context, *SimpleRequest) (*SimpleResponse, error)
}); ok {
ns.UnaryCall = h.UnaryCall
}
if h, ok := s.(interface {
FullDuplexCall(TestService_FullDuplexCallServer) error
}); ok {
ns.FullDuplexCall = h.FullDuplexCall
}
if h, ok := s.(interface {
ClientStreamCall(TestService_ClientStreamCallServer) error
}); ok {
ns.ClientStreamCall = h.ClientStreamCall
}
if h, ok := s.(interface {
ServerStreamCall(*SimpleRequest, TestService_ServerStreamCallServer) error
}); ok {
ns.ServerStreamCall = h.ServerStreamCall
}
return ns
}
// UnstableTestServiceService is the service API for TestService service.
// New methods may be added to this interface if they are added to the service
// definition, which is not a backward-compatible change. For this reason,
// use of this type is not recommended.
type UnstableTestServiceService interface {
// One request followed by one response.
// The server returns the client id as-is.
UnaryCall(context.Context, *SimpleRequest) (*SimpleResponse, error)
// A sequence of requests with each request served by the server immediately.
// As one request could lead to multiple responses, this interface
// demonstrates the idea of full duplexing.
FullDuplexCall(TestService_FullDuplexCallServer) error
// Client stream
ClientStreamCall(TestService_ClientStreamCallServer) error
// Server stream
ServerStreamCall(*SimpleRequest, TestService_ServerStreamCallServer) error
}

View File

@ -75,7 +75,14 @@ var (
type testServer struct{}
var _ testpb.UnstableTestServiceService = (*testServer)(nil)
func (s *testServer) Svc() *testpb.TestServiceService {
return &testpb.TestServiceService{
UnaryCall: s.UnaryCall,
FullDuplexCall: s.FullDuplexCall,
ClientStreamCall: s.ClientStreamCall,
ServerStreamCall: s.ServerStreamCall,
}
}
func (s *testServer) UnaryCall(ctx context.Context, in *testpb.SimpleRequest) (*testpb.SimpleResponse, error) {
if err := grpc.SendHeader(ctx, testHeaderMetadata); err != nil {
@ -815,7 +822,7 @@ func checkServerStats(t *testing.T, got []*gotData, expect *expectedData, checkF
func testServerStats(t *testing.T, tc *testConfig, cc *rpcConfig, checkFuncs []func(t *testing.T, d *gotData, e *expectedData)) {
h := &statshandler{}
te := newTest(t, tc, nil, h)
te.startServer(testpb.NewTestServiceService(&testServer{}))
te.startServer((&testServer{}).Svc())
defer te.tearDown()
var (
@ -1106,7 +1113,7 @@ func checkClientStats(t *testing.T, got []*gotData, expect *expectedData, checkF
func testClientStats(t *testing.T, tc *testConfig, cc *rpcConfig, checkFuncs map[int]*checkFuncWithCount) {
h := &statshandler{}
te := newTest(t, tc, h, nil)
te.startServer(testpb.NewTestServiceService(&testServer{}))
te.startServer((&testServer{}).Svc())
defer te.tearDown()
var (

View File

@ -151,13 +151,18 @@ type server struct {
gauges map[string]*gauge
}
var _ metricspb.UnstableMetricsServiceService = (*server)(nil)
// newMetricsServer returns a new metrics server.
func newMetricsServer() *server {
return &server{gauges: make(map[string]*gauge)}
}
func (s *server) Svc() *metricspb.MetricsServiceService {
return &metricspb.MetricsServiceService{
GetAllGauges: s.GetAllGauges,
GetGauge: s.GetGauge,
}
}
// GetAllGauges returns all gauges.
func (s *server) GetAllGauges(in *metricspb.EmptyMessage, stream metricspb.MetricsService_GetAllGaugesServer) error {
s.mutex.RLock()
@ -203,9 +208,8 @@ func startServer(server *server, port int) {
}
s := grpc.NewServer()
metricspb.RegisterMetricsServiceService(s, metricspb.NewMetricsServiceService(server))
metricspb.RegisterMetricsServiceService(s, server.Svc())
s.Serve(lis)
}
// performRPCs uses weightedRandomTestSelector to select test case and runs the tests.

View File

@ -165,36 +165,3 @@ func RegisterMetricsServiceService(s grpc.ServiceRegistrar, srv *MetricsServiceS
s.RegisterService(&sd, nil)
}
// NewMetricsServiceService creates a new MetricsServiceService containing the
// implemented methods of the MetricsService service in s. Any unimplemented
// methods will result in the gRPC server returning an UNIMPLEMENTED status to the client.
// This includes situations where the method handler is misspelled or has the wrong
// signature. For this reason, this function should be used with great care and
// is not recommended to be used by most users.
func NewMetricsServiceService(s interface{}) *MetricsServiceService {
ns := &MetricsServiceService{}
if h, ok := s.(interface {
GetAllGauges(*EmptyMessage, MetricsService_GetAllGaugesServer) error
}); ok {
ns.GetAllGauges = h.GetAllGauges
}
if h, ok := s.(interface {
GetGauge(context.Context, *GaugeRequest) (*GaugeResponse, error)
}); ok {
ns.GetGauge = h.GetGauge
}
return ns
}
// UnstableMetricsServiceService is the service API for MetricsService service.
// New methods may be added to this interface if they are added to the service
// definition, which is not a backward-compatible change. For this reason,
// use of this type is not recommended.
type UnstableMetricsServiceService interface {
// Returns the values of all the gauges that are currently being maintained by
// the service
GetAllGauges(*EmptyMessage, MetricsService_GetAllGaugesServer) error
// Returns the value of one gauge
GetGauge(context.Context, *GaugeRequest) (*GaugeResponse, error)
}

View File

@ -179,7 +179,7 @@ func testPickExtraMetadata(t *testing.T, e env) {
grpc.WithBalancerName(testBalancerName),
grpc.WithUserAgent(testUserAgent),
}
te.startServer((&testServer{security: e.security}).Svc())
te.startServer(testServer{security: e.security}.Svc())
defer te.tearDown()
// Set resolver to xds to trigger the extra metadata code path.
@ -228,7 +228,7 @@ func testDoneInfo(t *testing.T, e env) {
grpc.WithBalancerName(testBalancerName),
}
te.userAgent = failAppUA
te.startServer((&testServer{security: e.security}).Svc())
te.startServer(testServer{security: e.security}.Svc())
defer te.tearDown()
cc := te.clientConn()
@ -498,7 +498,7 @@ func (s) TestAddressAttributesInNewSubConn(t *testing.T) {
}
s := grpc.NewServer()
testpb.RegisterTestServiceService(s, testServer{}.Svc())
testpb.RegisterTestServiceService(s, (&testServer{}).Svc())
go s.Serve(lis)
defer s.Stop()
t.Logf("Started gRPC server at %s...", lis.Addr().String())

View File

@ -134,8 +134,6 @@ type testServer struct {
unaryCallSleepTime time.Duration
}
var _ testpb.UnstableTestServiceService = (*testServer)(nil)
// Svc returns a registerable TestService for this testServer instances.
// Because `s` is passed by value for convenience, any subsequent changes to
// `s` are not recognized.
@ -4859,10 +4857,10 @@ func (s) TestFlowControlLogicalRace(t *testing.T) {
defer lis.Close()
s := grpc.NewServer()
testpb.RegisterTestServiceService(s, testpb.NewTestServiceService(&flowControlLogicalRaceServer{
testpb.RegisterTestServiceService(s, (&flowControlLogicalRaceServer{
itemCount: itemCount,
itemSize: itemSize,
}))
}).Svc())
defer s.Stop()
go s.Serve(lis)
@ -4920,6 +4918,12 @@ type flowControlLogicalRaceServer struct {
itemCount int
}
func (s *flowControlLogicalRaceServer) Svc() *testpb.TestServiceService {
return &testpb.TestServiceService{
StreamingOutputCall: s.StreamingOutputCall,
}
}
func (s *flowControlLogicalRaceServer) StreamingOutputCall(req *testpb.StreamingOutputCallRequest, srv testpb.TestService_StreamingOutputCallServer) error {
for i := 0; i < s.itemCount; i++ {
err := srv.Send(&testpb.StreamingOutputCallResponse{
@ -5083,16 +5087,12 @@ type stubServer struct {
r *manual.Resolver
}
func (ss *stubServer) EmptyCall(ctx context.Context, in *testpb.Empty) (*testpb.Empty, error) {
return ss.emptyCall(ctx, in)
}
func (ss *stubServer) UnaryCall(ctx context.Context, in *testpb.SimpleRequest) (*testpb.SimpleResponse, error) {
return ss.unaryCall(ctx, in)
}
func (ss *stubServer) FullDuplexCall(stream testpb.TestService_FullDuplexCallServer) error {
return ss.fullDuplexCall(stream)
func (ss *stubServer) Svc() *testpb.TestServiceService {
return &testpb.TestServiceService{
EmptyCall: ss.emptyCall,
UnaryCall: ss.unaryCall,
FullDuplexCall: ss.fullDuplexCall,
}
}
// Start starts the server and creates a client connected to it.
@ -5115,7 +5115,7 @@ func (ss *stubServer) Start(sopts []grpc.ServerOption, dopts ...grpc.DialOption)
ss.cleanups = append(ss.cleanups, func() { lis.Close() })
s := grpc.NewServer(sopts...)
testpb.RegisterTestServiceService(s, testpb.NewTestServiceService(ss))
testpb.RegisterTestServiceService(s, ss.Svc())
go s.Serve(lis)
ss.cleanups = append(ss.cleanups, s.Stop)
ss.s = s
@ -6258,7 +6258,7 @@ func (s) TestServeExitsWhenListenerClosed(t *testing.T) {
s := grpc.NewServer()
defer s.Stop()
testpb.RegisterTestServiceService(s, testpb.NewTestServiceService(ss))
testpb.RegisterTestServiceService(s, ss.Svc())
lis, err := net.Listen("tcp", "localhost:0")
if err != nil {
@ -6477,7 +6477,7 @@ func (s) TestDisabledIOBuffers(t *testing.T) {
}
s := grpc.NewServer(grpc.WriteBufferSize(0), grpc.ReadBufferSize(0))
testpb.RegisterTestServiceService(s, testpb.NewTestServiceService(ss))
testpb.RegisterTestServiceService(s, ss.Svc())
lis, err := net.Listen("tcp", "localhost:0")
if err != nil {

View File

@ -48,7 +48,7 @@ func (s) TestGracefulClientOnGoAway(t *testing.T) {
s := grpc.NewServer(grpc.KeepaliveParams(keepalive.ServerParameters{MaxConnectionAge: maxConnAge}))
defer s.Stop()
testpb.RegisterTestServiceService(s, testpb.NewTestServiceService(ss))
testpb.RegisterTestServiceService(s, ss.Svc())
lis, err := net.Listen("tcp", "localhost:0")
if err != nil {

View File

@ -117,7 +117,7 @@ func (s) TestGracefulStop(t *testing.T) {
},
}
s := grpc.NewServer()
testpb.RegisterTestServiceService(s, testpb.NewTestServiceService(ss))
testpb.RegisterTestServiceService(s, ss.Svc())
// 1. Start Server
wg := sync.WaitGroup{}

View File

@ -454,71 +454,3 @@ func RegisterTestServiceService(s grpc.ServiceRegistrar, srv *TestServiceService
s.RegisterService(&sd, nil)
}
// NewTestServiceService creates a new TestServiceService containing the
// implemented methods of the TestService service in s. Any unimplemented
// methods will result in the gRPC server returning an UNIMPLEMENTED status to the client.
// This includes situations where the method handler is misspelled or has the wrong
// signature. For this reason, this function should be used with great care and
// is not recommended to be used by most users.
func NewTestServiceService(s interface{}) *TestServiceService {
ns := &TestServiceService{}
if h, ok := s.(interface {
EmptyCall(context.Context, *Empty) (*Empty, error)
}); ok {
ns.EmptyCall = h.EmptyCall
}
if h, ok := s.(interface {
UnaryCall(context.Context, *SimpleRequest) (*SimpleResponse, error)
}); ok {
ns.UnaryCall = h.UnaryCall
}
if h, ok := s.(interface {
StreamingOutputCall(*StreamingOutputCallRequest, TestService_StreamingOutputCallServer) error
}); ok {
ns.StreamingOutputCall = h.StreamingOutputCall
}
if h, ok := s.(interface {
StreamingInputCall(TestService_StreamingInputCallServer) error
}); ok {
ns.StreamingInputCall = h.StreamingInputCall
}
if h, ok := s.(interface {
FullDuplexCall(TestService_FullDuplexCallServer) error
}); ok {
ns.FullDuplexCall = h.FullDuplexCall
}
if h, ok := s.(interface {
HalfDuplexCall(TestService_HalfDuplexCallServer) error
}); ok {
ns.HalfDuplexCall = h.HalfDuplexCall
}
return ns
}
// UnstableTestServiceService is the service API for TestService service.
// New methods may be added to this interface if they are added to the service
// definition, which is not a backward-compatible change. For this reason,
// use of this type is not recommended.
type UnstableTestServiceService interface {
// One empty request followed by one empty response.
EmptyCall(context.Context, *Empty) (*Empty, error)
// One request followed by one response.
// The server returns the client payload as-is.
UnaryCall(context.Context, *SimpleRequest) (*SimpleResponse, error)
// One request followed by a sequence of responses (streamed download).
// The server returns the payload with client desired type and sizes.
StreamingOutputCall(*StreamingOutputCallRequest, TestService_StreamingOutputCallServer) error
// A sequence of requests followed by one response (streamed upload).
// The server returns the aggregated size of client payload as the result.
StreamingInputCall(TestService_StreamingInputCallServer) error
// A sequence of requests with each request served by the server immediately.
// As one request could lead to multiple responses, this interface
// demonstrates the idea of full duplexing.
FullDuplexCall(TestService_FullDuplexCallServer) error
// A sequence of requests followed by a sequence of responses.
// The server buffers all the client requests and then serves them in order. A
// stream of responses are returned to the client when the server starts with
// first request.
HalfDuplexCall(TestService_HalfDuplexCallServer) error
}

View File

@ -64,7 +64,7 @@ func testLocalCredsE2ESucceed(network, address string) error {
s := grpc.NewServer(sopts...)
defer s.Stop()
testpb.RegisterTestServiceService(s, testpb.NewTestServiceService(ss))
testpb.RegisterTestServiceService(s, ss.Svc())
lis, err := net.Listen(network, address)
if err != nil {
@ -162,7 +162,7 @@ func testLocalCredsE2EFail(dopts []grpc.DialOption) error {
s := grpc.NewServer(sopts...)
defer s.Stop()
testpb.RegisterTestServiceService(s, testpb.NewTestServiceService(ss))
testpb.RegisterTestServiceService(s, ss.Svc())
lis, err := net.Listen("tcp", "localhost:0")
if err != nil {