From 29506178938c8460e08cfbca85e4a274b493c4e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=E8=8A=B1?= Date: Sun, 25 Aug 2024 14:38:05 +0800 Subject: [PATCH] Update. --- proto/server_grpc.pb.go | 147 ++++++++++++++++++++++++++-------------- 1 file changed, 96 insertions(+), 51 deletions(-) diff --git a/proto/server_grpc.pb.go b/proto/server_grpc.pb.go index 3021afb..ba45be9 100644 --- a/proto/server_grpc.pb.go +++ b/proto/server_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.5.1 -// - protoc v5.27.3 +// - protoc-gen-go-grpc v1.3.0 +// - protoc v5.26.1 // source: proto/server.proto package proto @@ -15,8 +15,8 @@ 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.64.0 or later. -const _ = grpc.SupportPackageIsVersion9 +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 const ( ServerService_ReportSystemState_FullMethodName = "/proto.ServerService/ReportSystemState" @@ -34,8 +34,8 @@ type ServerServiceClient interface { ReportSystemState(ctx context.Context, in *State, opts ...grpc.CallOption) (*Receipt, error) ReportSystemInfo(ctx context.Context, in *Host, opts ...grpc.CallOption) (*Receipt, error) ReportTask(ctx context.Context, in *TaskResult, opts ...grpc.CallOption) (*Receipt, error) - RequestTask(ctx context.Context, in *Host, opts ...grpc.CallOption) (grpc.ServerStreamingClient[Task], error) - IOStream(ctx context.Context, opts ...grpc.CallOption) (grpc.BidiStreamingClient[IOStreamData, IOStreamData], error) + RequestTask(ctx context.Context, in *Host, opts ...grpc.CallOption) (ServerService_RequestTaskClient, error) + IOStream(ctx context.Context, opts ...grpc.CallOption) (ServerService_IOStreamClient, error) LookupGeoIP(ctx context.Context, in *GeoIP, opts ...grpc.CallOption) (*GeoIP, error) } @@ -48,9 +48,8 @@ func NewServerServiceClient(cc grpc.ClientConnInterface) ServerServiceClient { } func (c *serverServiceClient) ReportSystemState(ctx context.Context, in *State, opts ...grpc.CallOption) (*Receipt, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(Receipt) - err := c.cc.Invoke(ctx, ServerService_ReportSystemState_FullMethodName, in, out, cOpts...) + err := c.cc.Invoke(ctx, ServerService_ReportSystemState_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -58,9 +57,8 @@ func (c *serverServiceClient) ReportSystemState(ctx context.Context, in *State, } func (c *serverServiceClient) ReportSystemInfo(ctx context.Context, in *Host, opts ...grpc.CallOption) (*Receipt, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(Receipt) - err := c.cc.Invoke(ctx, ServerService_ReportSystemInfo_FullMethodName, in, out, cOpts...) + err := c.cc.Invoke(ctx, ServerService_ReportSystemInfo_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -68,22 +66,20 @@ func (c *serverServiceClient) ReportSystemInfo(ctx context.Context, in *Host, op } func (c *serverServiceClient) ReportTask(ctx context.Context, in *TaskResult, opts ...grpc.CallOption) (*Receipt, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(Receipt) - err := c.cc.Invoke(ctx, ServerService_ReportTask_FullMethodName, in, out, cOpts...) + err := c.cc.Invoke(ctx, ServerService_ReportTask_FullMethodName, in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *serverServiceClient) RequestTask(ctx context.Context, in *Host, opts ...grpc.CallOption) (grpc.ServerStreamingClient[Task], error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - stream, err := c.cc.NewStream(ctx, &ServerService_ServiceDesc.Streams[0], ServerService_RequestTask_FullMethodName, cOpts...) +func (c *serverServiceClient) RequestTask(ctx context.Context, in *Host, opts ...grpc.CallOption) (ServerService_RequestTaskClient, error) { + stream, err := c.cc.NewStream(ctx, &ServerService_ServiceDesc.Streams[0], ServerService_RequestTask_FullMethodName, opts...) if err != nil { return nil, err } - x := &grpc.GenericClientStream[Host, Task]{ClientStream: stream} + x := &serverServiceRequestTaskClient{stream} if err := x.ClientStream.SendMsg(in); err != nil { return nil, err } @@ -93,26 +89,57 @@ func (c *serverServiceClient) RequestTask(ctx context.Context, in *Host, opts .. return x, nil } -// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. -type ServerService_RequestTaskClient = grpc.ServerStreamingClient[Task] +type ServerService_RequestTaskClient interface { + Recv() (*Task, error) + grpc.ClientStream +} + +type serverServiceRequestTaskClient struct { + grpc.ClientStream +} -func (c *serverServiceClient) IOStream(ctx context.Context, opts ...grpc.CallOption) (grpc.BidiStreamingClient[IOStreamData, IOStreamData], error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - stream, err := c.cc.NewStream(ctx, &ServerService_ServiceDesc.Streams[1], ServerService_IOStream_FullMethodName, cOpts...) +func (x *serverServiceRequestTaskClient) Recv() (*Task, error) { + m := new(Task) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func (c *serverServiceClient) IOStream(ctx context.Context, opts ...grpc.CallOption) (ServerService_IOStreamClient, error) { + stream, err := c.cc.NewStream(ctx, &ServerService_ServiceDesc.Streams[1], ServerService_IOStream_FullMethodName, opts...) if err != nil { return nil, err } - x := &grpc.GenericClientStream[IOStreamData, IOStreamData]{ClientStream: stream} + x := &serverServiceIOStreamClient{stream} return x, nil } -// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. -type ServerService_IOStreamClient = grpc.BidiStreamingClient[IOStreamData, IOStreamData] +type ServerService_IOStreamClient interface { + Send(*IOStreamData) error + Recv() (*IOStreamData, error) + grpc.ClientStream +} + +type serverServiceIOStreamClient struct { + grpc.ClientStream +} + +func (x *serverServiceIOStreamClient) Send(m *IOStreamData) error { + return x.ClientStream.SendMsg(m) +} + +func (x *serverServiceIOStreamClient) Recv() (*IOStreamData, error) { + m := new(IOStreamData) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} func (c *serverServiceClient) LookupGeoIP(ctx context.Context, in *GeoIP, opts ...grpc.CallOption) (*GeoIP, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(GeoIP) - err := c.cc.Invoke(ctx, ServerService_LookupGeoIP_FullMethodName, in, out, cOpts...) + err := c.cc.Invoke(ctx, ServerService_LookupGeoIP_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -121,22 +148,19 @@ func (c *serverServiceClient) LookupGeoIP(ctx context.Context, in *GeoIP, opts . // ServerServiceServer is the server API for ServerService service. // All implementations should embed UnimplementedServerServiceServer -// for forward compatibility. +// for forward compatibility type ServerServiceServer interface { ReportSystemState(context.Context, *State) (*Receipt, error) ReportSystemInfo(context.Context, *Host) (*Receipt, error) ReportTask(context.Context, *TaskResult) (*Receipt, error) - RequestTask(*Host, grpc.ServerStreamingServer[Task]) error - IOStream(grpc.BidiStreamingServer[IOStreamData, IOStreamData]) error + RequestTask(*Host, ServerService_RequestTaskServer) error + IOStream(ServerService_IOStreamServer) error LookupGeoIP(context.Context, *GeoIP) (*GeoIP, error) } -// UnimplementedServerServiceServer should 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 UnimplementedServerServiceServer struct{} +// UnimplementedServerServiceServer should be embedded to have forward compatible implementations. +type UnimplementedServerServiceServer struct { +} func (UnimplementedServerServiceServer) ReportSystemState(context.Context, *State) (*Receipt, error) { return nil, status.Errorf(codes.Unimplemented, "method ReportSystemState not implemented") @@ -147,16 +171,15 @@ func (UnimplementedServerServiceServer) ReportSystemInfo(context.Context, *Host) func (UnimplementedServerServiceServer) ReportTask(context.Context, *TaskResult) (*Receipt, error) { return nil, status.Errorf(codes.Unimplemented, "method ReportTask not implemented") } -func (UnimplementedServerServiceServer) RequestTask(*Host, grpc.ServerStreamingServer[Task]) error { +func (UnimplementedServerServiceServer) RequestTask(*Host, ServerService_RequestTaskServer) error { return status.Errorf(codes.Unimplemented, "method RequestTask not implemented") } -func (UnimplementedServerServiceServer) IOStream(grpc.BidiStreamingServer[IOStreamData, IOStreamData]) error { +func (UnimplementedServerServiceServer) IOStream(ServerService_IOStreamServer) error { return status.Errorf(codes.Unimplemented, "method IOStream not implemented") } func (UnimplementedServerServiceServer) LookupGeoIP(context.Context, *GeoIP) (*GeoIP, error) { return nil, status.Errorf(codes.Unimplemented, "method LookupGeoIP not implemented") } -func (UnimplementedServerServiceServer) testEmbeddedByValue() {} // UnsafeServerServiceServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to ServerServiceServer will @@ -166,13 +189,6 @@ type UnsafeServerServiceServer interface { } func RegisterServerServiceServer(s grpc.ServiceRegistrar, srv ServerServiceServer) { - // If the following call pancis, it indicates UnimplementedServerServiceServer 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(&ServerService_ServiceDesc, srv) } @@ -235,18 +251,47 @@ func _ServerService_RequestTask_Handler(srv interface{}, stream grpc.ServerStrea if err := stream.RecvMsg(m); err != nil { return err } - return srv.(ServerServiceServer).RequestTask(m, &grpc.GenericServerStream[Host, Task]{ServerStream: stream}) + return srv.(ServerServiceServer).RequestTask(m, &serverServiceRequestTaskServer{stream}) +} + +type ServerService_RequestTaskServer interface { + Send(*Task) error + grpc.ServerStream } -// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. -type ServerService_RequestTaskServer = grpc.ServerStreamingServer[Task] +type serverServiceRequestTaskServer struct { + grpc.ServerStream +} + +func (x *serverServiceRequestTaskServer) Send(m *Task) error { + return x.ServerStream.SendMsg(m) +} func _ServerService_IOStream_Handler(srv interface{}, stream grpc.ServerStream) error { - return srv.(ServerServiceServer).IOStream(&grpc.GenericServerStream[IOStreamData, IOStreamData]{ServerStream: stream}) + return srv.(ServerServiceServer).IOStream(&serverServiceIOStreamServer{stream}) +} + +type ServerService_IOStreamServer interface { + Send(*IOStreamData) error + Recv() (*IOStreamData, error) + grpc.ServerStream +} + +type serverServiceIOStreamServer struct { + grpc.ServerStream +} + +func (x *serverServiceIOStreamServer) Send(m *IOStreamData) 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 ServerService_IOStreamServer = grpc.BidiStreamingServer[IOStreamData, IOStreamData] +func (x *serverServiceIOStreamServer) Recv() (*IOStreamData, error) { + m := new(IOStreamData) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} func _ServerService_LookupGeoIP_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(GeoIP)