mirror of
https://github.com/linka-cloud/grpc.git
synced 2025-06-22 17:22:26 +00:00
proxy: use grpc interfaces instead of *grpc.Server and *grpc.ClientConn, use Service and service Options
Signed-off-by: Adphi <philippe.adrien.nousse@gmail.com>
This commit is contained in:
@ -1,4 +1,8 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.5.1
|
||||
// - protoc v5.28.2
|
||||
// source: proxy/testservice/test.proto
|
||||
|
||||
package testservice
|
||||
|
||||
@ -12,8 +16,16 @@ import (
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
// Requires gRPC-Go v1.32.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion7
|
||||
// Requires gRPC-Go v1.64.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion9
|
||||
|
||||
const (
|
||||
TestService_PingEmpty_FullMethodName = "/mwitkow.testproto.TestService/PingEmpty"
|
||||
TestService_Ping_FullMethodName = "/mwitkow.testproto.TestService/Ping"
|
||||
TestService_PingError_FullMethodName = "/mwitkow.testproto.TestService/PingError"
|
||||
TestService_PingList_FullMethodName = "/mwitkow.testproto.TestService/PingList"
|
||||
TestService_PingStream_FullMethodName = "/mwitkow.testproto.TestService/PingStream"
|
||||
)
|
||||
|
||||
// TestServiceClient is the client API for TestService service.
|
||||
//
|
||||
@ -22,8 +34,8 @@ type TestServiceClient interface {
|
||||
PingEmpty(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*PingResponse, error)
|
||||
Ping(ctx context.Context, in *PingRequest, opts ...grpc.CallOption) (*PingResponse, error)
|
||||
PingError(ctx context.Context, in *PingRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
|
||||
PingList(ctx context.Context, in *PingRequest, opts ...grpc.CallOption) (TestService_PingListClient, error)
|
||||
PingStream(ctx context.Context, opts ...grpc.CallOption) (TestService_PingStreamClient, error)
|
||||
PingList(ctx context.Context, in *PingRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[PingResponse], error)
|
||||
PingStream(ctx context.Context, opts ...grpc.CallOption) (grpc.BidiStreamingClient[PingRequest, PingResponse], error)
|
||||
}
|
||||
|
||||
type testServiceClient struct {
|
||||
@ -35,8 +47,9 @@ func NewTestServiceClient(cc grpc.ClientConnInterface) TestServiceClient {
|
||||
}
|
||||
|
||||
func (c *testServiceClient) PingEmpty(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*PingResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(PingResponse)
|
||||
err := c.cc.Invoke(ctx, "/mwitkow.testproto.TestService/PingEmpty", in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, TestService_PingEmpty_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -44,8 +57,9 @@ func (c *testServiceClient) PingEmpty(ctx context.Context, in *emptypb.Empty, op
|
||||
}
|
||||
|
||||
func (c *testServiceClient) Ping(ctx context.Context, in *PingRequest, opts ...grpc.CallOption) (*PingResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(PingResponse)
|
||||
err := c.cc.Invoke(ctx, "/mwitkow.testproto.TestService/Ping", in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, TestService_Ping_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -53,20 +67,22 @@ func (c *testServiceClient) Ping(ctx context.Context, in *PingRequest, opts ...g
|
||||
}
|
||||
|
||||
func (c *testServiceClient) PingError(ctx context.Context, in *PingRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(emptypb.Empty)
|
||||
err := c.cc.Invoke(ctx, "/mwitkow.testproto.TestService/PingError", in, out, opts...)
|
||||
err := c.cc.Invoke(ctx, TestService_PingError_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *testServiceClient) PingList(ctx context.Context, in *PingRequest, opts ...grpc.CallOption) (TestService_PingListClient, error) {
|
||||
stream, err := c.cc.NewStream(ctx, &TestService_ServiceDesc.Streams[0], "/mwitkow.testproto.TestService/PingList", opts...)
|
||||
func (c *testServiceClient) PingList(ctx context.Context, in *PingRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[PingResponse], error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
stream, err := c.cc.NewStream(ctx, &TestService_ServiceDesc.Streams[0], TestService_PingList_FullMethodName, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
x := &testServicePingListClient{stream}
|
||||
x := &grpc.GenericClientStream[PingRequest, PingResponse]{ClientStream: stream}
|
||||
if err := x.ClientStream.SendMsg(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -76,69 +92,40 @@ func (c *testServiceClient) PingList(ctx context.Context, in *PingRequest, opts
|
||||
return x, nil
|
||||
}
|
||||
|
||||
type TestService_PingListClient interface {
|
||||
Recv() (*PingResponse, error)
|
||||
grpc.ClientStream
|
||||
}
|
||||
// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
|
||||
type TestService_PingListClient = grpc.ServerStreamingClient[PingResponse]
|
||||
|
||||
type testServicePingListClient struct {
|
||||
grpc.ClientStream
|
||||
}
|
||||
|
||||
func (x *testServicePingListClient) Recv() (*PingResponse, error) {
|
||||
m := new(PingResponse)
|
||||
if err := x.ClientStream.RecvMsg(m); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
|
||||
func (c *testServiceClient) PingStream(ctx context.Context, opts ...grpc.CallOption) (TestService_PingStreamClient, error) {
|
||||
stream, err := c.cc.NewStream(ctx, &TestService_ServiceDesc.Streams[1], "/mwitkow.testproto.TestService/PingStream", opts...)
|
||||
func (c *testServiceClient) PingStream(ctx context.Context, opts ...grpc.CallOption) (grpc.BidiStreamingClient[PingRequest, PingResponse], error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
stream, err := c.cc.NewStream(ctx, &TestService_ServiceDesc.Streams[1], TestService_PingStream_FullMethodName, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
x := &testServicePingStreamClient{stream}
|
||||
x := &grpc.GenericClientStream[PingRequest, PingResponse]{ClientStream: stream}
|
||||
return x, nil
|
||||
}
|
||||
|
||||
type TestService_PingStreamClient interface {
|
||||
Send(*PingRequest) error
|
||||
Recv() (*PingResponse, error)
|
||||
grpc.ClientStream
|
||||
}
|
||||
|
||||
type testServicePingStreamClient struct {
|
||||
grpc.ClientStream
|
||||
}
|
||||
|
||||
func (x *testServicePingStreamClient) Send(m *PingRequest) error {
|
||||
return x.ClientStream.SendMsg(m)
|
||||
}
|
||||
|
||||
func (x *testServicePingStreamClient) Recv() (*PingResponse, error) {
|
||||
m := new(PingResponse)
|
||||
if err := x.ClientStream.RecvMsg(m); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
|
||||
type TestService_PingStreamClient = grpc.BidiStreamingClient[PingRequest, PingResponse]
|
||||
|
||||
// TestServiceServer is the server API for TestService service.
|
||||
// All implementations must embed UnimplementedTestServiceServer
|
||||
// for forward compatibility
|
||||
// for forward compatibility.
|
||||
type TestServiceServer interface {
|
||||
PingEmpty(context.Context, *emptypb.Empty) (*PingResponse, error)
|
||||
Ping(context.Context, *PingRequest) (*PingResponse, error)
|
||||
PingError(context.Context, *PingRequest) (*emptypb.Empty, error)
|
||||
PingList(*PingRequest, TestService_PingListServer) error
|
||||
PingStream(TestService_PingStreamServer) error
|
||||
PingList(*PingRequest, grpc.ServerStreamingServer[PingResponse]) error
|
||||
PingStream(grpc.BidiStreamingServer[PingRequest, PingResponse]) error
|
||||
mustEmbedUnimplementedTestServiceServer()
|
||||
}
|
||||
|
||||
// UnimplementedTestServiceServer must be embedded to have forward compatible implementations.
|
||||
type UnimplementedTestServiceServer struct {
|
||||
}
|
||||
// UnimplementedTestServiceServer must be embedded to have
|
||||
// forward compatible implementations.
|
||||
//
|
||||
// NOTE: this should be embedded by value instead of pointer to avoid a nil
|
||||
// pointer dereference when methods are called.
|
||||
type UnimplementedTestServiceServer struct{}
|
||||
|
||||
func (UnimplementedTestServiceServer) PingEmpty(context.Context, *emptypb.Empty) (*PingResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method PingEmpty not implemented")
|
||||
@ -149,13 +136,14 @@ func (UnimplementedTestServiceServer) Ping(context.Context, *PingRequest) (*Ping
|
||||
func (UnimplementedTestServiceServer) PingError(context.Context, *PingRequest) (*emptypb.Empty, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method PingError not implemented")
|
||||
}
|
||||
func (UnimplementedTestServiceServer) PingList(*PingRequest, TestService_PingListServer) error {
|
||||
func (UnimplementedTestServiceServer) PingList(*PingRequest, grpc.ServerStreamingServer[PingResponse]) error {
|
||||
return status.Errorf(codes.Unimplemented, "method PingList not implemented")
|
||||
}
|
||||
func (UnimplementedTestServiceServer) PingStream(TestService_PingStreamServer) error {
|
||||
func (UnimplementedTestServiceServer) PingStream(grpc.BidiStreamingServer[PingRequest, PingResponse]) error {
|
||||
return status.Errorf(codes.Unimplemented, "method PingStream not implemented")
|
||||
}
|
||||
func (UnimplementedTestServiceServer) mustEmbedUnimplementedTestServiceServer() {}
|
||||
func (UnimplementedTestServiceServer) testEmbeddedByValue() {}
|
||||
|
||||
// UnsafeTestServiceServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to TestServiceServer will
|
||||
@ -165,6 +153,13 @@ type UnsafeTestServiceServer interface {
|
||||
}
|
||||
|
||||
func RegisterTestServiceServer(s grpc.ServiceRegistrar, srv TestServiceServer) {
|
||||
// If the following call pancis, it indicates UnimplementedTestServiceServer was
|
||||
// embedded by pointer and is nil. This will cause panics if an
|
||||
// unimplemented method is ever invoked, so we test this at initialization
|
||||
// time to prevent it from happening at runtime later due to I/O.
|
||||
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
|
||||
t.testEmbeddedByValue()
|
||||
}
|
||||
s.RegisterService(&TestService_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
@ -178,7 +173,7 @@ func _TestService_PingEmpty_Handler(srv interface{}, ctx context.Context, dec fu
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/mwitkow.testproto.TestService/PingEmpty",
|
||||
FullMethod: TestService_PingEmpty_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(TestServiceServer).PingEmpty(ctx, req.(*emptypb.Empty))
|
||||
@ -196,7 +191,7 @@ func _TestService_Ping_Handler(srv interface{}, ctx context.Context, dec func(in
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/mwitkow.testproto.TestService/Ping",
|
||||
FullMethod: TestService_Ping_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(TestServiceServer).Ping(ctx, req.(*PingRequest))
|
||||
@ -214,7 +209,7 @@ func _TestService_PingError_Handler(srv interface{}, ctx context.Context, dec fu
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/mwitkow.testproto.TestService/PingError",
|
||||
FullMethod: TestService_PingError_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(TestServiceServer).PingError(ctx, req.(*PingRequest))
|
||||
@ -227,47 +222,18 @@ func _TestService_PingList_Handler(srv interface{}, stream grpc.ServerStream) er
|
||||
if err := stream.RecvMsg(m); err != nil {
|
||||
return err
|
||||
}
|
||||
return srv.(TestServiceServer).PingList(m, &testServicePingListServer{stream})
|
||||
return srv.(TestServiceServer).PingList(m, &grpc.GenericServerStream[PingRequest, PingResponse]{ServerStream: stream})
|
||||
}
|
||||
|
||||
type TestService_PingListServer interface {
|
||||
Send(*PingResponse) error
|
||||
grpc.ServerStream
|
||||
}
|
||||
|
||||
type testServicePingListServer struct {
|
||||
grpc.ServerStream
|
||||
}
|
||||
|
||||
func (x *testServicePingListServer) Send(m *PingResponse) error {
|
||||
return x.ServerStream.SendMsg(m)
|
||||
}
|
||||
// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
|
||||
type TestService_PingListServer = grpc.ServerStreamingServer[PingResponse]
|
||||
|
||||
func _TestService_PingStream_Handler(srv interface{}, stream grpc.ServerStream) error {
|
||||
return srv.(TestServiceServer).PingStream(&testServicePingStreamServer{stream})
|
||||
return srv.(TestServiceServer).PingStream(&grpc.GenericServerStream[PingRequest, PingResponse]{ServerStream: stream})
|
||||
}
|
||||
|
||||
type TestService_PingStreamServer interface {
|
||||
Send(*PingResponse) error
|
||||
Recv() (*PingRequest, error)
|
||||
grpc.ServerStream
|
||||
}
|
||||
|
||||
type testServicePingStreamServer struct {
|
||||
grpc.ServerStream
|
||||
}
|
||||
|
||||
func (x *testServicePingStreamServer) Send(m *PingResponse) error {
|
||||
return x.ServerStream.SendMsg(m)
|
||||
}
|
||||
|
||||
func (x *testServicePingStreamServer) Recv() (*PingRequest, error) {
|
||||
m := new(PingRequest)
|
||||
if err := x.ServerStream.RecvMsg(m); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
|
||||
type TestService_PingStreamServer = grpc.BidiStreamingServer[PingRequest, PingResponse]
|
||||
|
||||
// TestService_ServiceDesc is the grpc.ServiceDesc for TestService service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
@ -302,5 +268,5 @@ var TestService_ServiceDesc = grpc.ServiceDesc{
|
||||
ClientStreams: true,
|
||||
},
|
||||
},
|
||||
Metadata: "test.proto",
|
||||
Metadata: "proxy/testservice/test.proto",
|
||||
}
|
||||
|
Reference in New Issue
Block a user