From 3389df740c200e4b91ddae61d3acb551e5527f09 Mon Sep 17 00:00:00 2001 From: "zero@thinky" Date: Sat, 4 Apr 2026 20:45:59 +0300 Subject: [PATCH] feat!(proto): change service monitor from stream to unary --- proto/hellreign.proto | 2 +- proto/proto/hellreign.pb.go | 10 +++--- proto/proto/hellreign_grpc.pb.go | 54 ++++++++++++++++++-------------- 3 files changed, 37 insertions(+), 29 deletions(-) diff --git a/proto/hellreign.proto b/proto/hellreign.proto index 0abc0a3..0b2680e 100644 --- a/proto/hellreign.proto +++ b/proto/hellreign.proto @@ -6,7 +6,7 @@ option go_package="gitea.d3m0k1d.ru/d3m0k1d/HellreigN/proto/proto"; service Collector { rpc Stream(stream CollectorRequest) returns (CollectorResponse); - rpc ServicesStream(stream ServicesUpdate) returns (ServicesUpdateResp); + rpc ReportServices(ServicesUpdate) returns (ServicesUpdateResp); } message ServicesUpdateResp { } diff --git a/proto/proto/hellreign.pb.go b/proto/proto/hellreign.pb.go index c138eaa..707ce37 100644 --- a/proto/proto/hellreign.pb.go +++ b/proto/proto/hellreign.pb.go @@ -384,10 +384,10 @@ const file_hellreign_proto_rawDesc = "" + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x16\n" + "\x06status\x18\x02 \x01(\x05R\x06status\x12\x16\n" + "\x06stdout\x18\x03 \x01(\tR\x06stdout\x12\x16\n" + - "\x06stderr\x18\x04 \x01(\tR\x06stderr2\x8c\x01\n" + + "\x06stderr\x18\x04 \x01(\tR\x06stderr2\x8a\x01\n" + "\tCollector\x12;\n" + - "\x06Stream\x12\x16.chat.CollectorRequest\x1a\x17.chat.CollectorResponse(\x01\x12B\n" + - "\x0eServicesStream\x12\x14.chat.ServicesUpdate\x1a\x18.chat.ServicesUpdateResp(\x012?\n" + + "\x06Stream\x12\x16.chat.CollectorRequest\x1a\x17.chat.CollectorResponse(\x01\x12@\n" + + "\x0eReportServices\x12\x14.chat.ServicesUpdate\x1a\x18.chat.ServicesUpdateResp2?\n" + "\tCommander\x122\n" + "\x06Stream\x12\x15.chat.FinishedCommand\x1a\r.chat.Command(\x010\x01B0Z.gitea.d3m0k1d.ru/d3m0k1d/HellreigN/proto/protob\x06proto3" @@ -416,10 +416,10 @@ var file_hellreign_proto_goTypes = []any{ var file_hellreign_proto_depIdxs = []int32{ 6, // 0: chat.ServicesUpdate.services:type_name -> chat.ServicesUpdate.ServiceUpdate 2, // 1: chat.Collector.Stream:input_type -> chat.CollectorRequest - 1, // 2: chat.Collector.ServicesStream:input_type -> chat.ServicesUpdate + 1, // 2: chat.Collector.ReportServices:input_type -> chat.ServicesUpdate 5, // 3: chat.Commander.Stream:input_type -> chat.FinishedCommand 3, // 4: chat.Collector.Stream:output_type -> chat.CollectorResponse - 0, // 5: chat.Collector.ServicesStream:output_type -> chat.ServicesUpdateResp + 0, // 5: chat.Collector.ReportServices:output_type -> chat.ServicesUpdateResp 4, // 6: chat.Commander.Stream:output_type -> chat.Command 4, // [4:7] is the sub-list for method output_type 1, // [1:4] is the sub-list for method input_type diff --git a/proto/proto/hellreign_grpc.pb.go b/proto/proto/hellreign_grpc.pb.go index ec651fc..3c4b023 100644 --- a/proto/proto/hellreign_grpc.pb.go +++ b/proto/proto/hellreign_grpc.pb.go @@ -20,7 +20,7 @@ const _ = grpc.SupportPackageIsVersion9 const ( Collector_Stream_FullMethodName = "/chat.Collector/Stream" - Collector_ServicesStream_FullMethodName = "/chat.Collector/ServicesStream" + Collector_ReportServices_FullMethodName = "/chat.Collector/ReportServices" ) // CollectorClient is the client API for Collector service. @@ -28,7 +28,7 @@ const ( // 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 CollectorClient interface { Stream(ctx context.Context, opts ...grpc.CallOption) (grpc.ClientStreamingClient[CollectorRequest, CollectorResponse], error) - ServicesStream(ctx context.Context, opts ...grpc.CallOption) (grpc.ClientStreamingClient[ServicesUpdate, ServicesUpdateResp], error) + ReportServices(ctx context.Context, in *ServicesUpdate, opts ...grpc.CallOption) (*ServicesUpdateResp, error) } type collectorClient struct { @@ -52,25 +52,22 @@ func (c *collectorClient) Stream(ctx context.Context, opts ...grpc.CallOption) ( // This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. type Collector_StreamClient = grpc.ClientStreamingClient[CollectorRequest, CollectorResponse] -func (c *collectorClient) ServicesStream(ctx context.Context, opts ...grpc.CallOption) (grpc.ClientStreamingClient[ServicesUpdate, ServicesUpdateResp], error) { +func (c *collectorClient) ReportServices(ctx context.Context, in *ServicesUpdate, opts ...grpc.CallOption) (*ServicesUpdateResp, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - stream, err := c.cc.NewStream(ctx, &Collector_ServiceDesc.Streams[1], Collector_ServicesStream_FullMethodName, cOpts...) + out := new(ServicesUpdateResp) + err := c.cc.Invoke(ctx, Collector_ReportServices_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } - x := &grpc.GenericClientStream[ServicesUpdate, ServicesUpdateResp]{ClientStream: stream} - return x, nil + return out, nil } -// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. -type Collector_ServicesStreamClient = grpc.ClientStreamingClient[ServicesUpdate, ServicesUpdateResp] - // CollectorServer is the server API for Collector service. // All implementations must embed UnimplementedCollectorServer // for forward compatibility. type CollectorServer interface { Stream(grpc.ClientStreamingServer[CollectorRequest, CollectorResponse]) error - ServicesStream(grpc.ClientStreamingServer[ServicesUpdate, ServicesUpdateResp]) error + ReportServices(context.Context, *ServicesUpdate) (*ServicesUpdateResp, error) mustEmbedUnimplementedCollectorServer() } @@ -84,8 +81,8 @@ type UnimplementedCollectorServer struct{} func (UnimplementedCollectorServer) Stream(grpc.ClientStreamingServer[CollectorRequest, CollectorResponse]) error { return status.Error(codes.Unimplemented, "method Stream not implemented") } -func (UnimplementedCollectorServer) ServicesStream(grpc.ClientStreamingServer[ServicesUpdate, ServicesUpdateResp]) error { - return status.Error(codes.Unimplemented, "method ServicesStream not implemented") +func (UnimplementedCollectorServer) ReportServices(context.Context, *ServicesUpdate) (*ServicesUpdateResp, error) { + return nil, status.Error(codes.Unimplemented, "method ReportServices not implemented") } func (UnimplementedCollectorServer) mustEmbedUnimplementedCollectorServer() {} func (UnimplementedCollectorServer) testEmbeddedByValue() {} @@ -115,31 +112,42 @@ func _Collector_Stream_Handler(srv interface{}, stream grpc.ServerStream) error // This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. type Collector_StreamServer = grpc.ClientStreamingServer[CollectorRequest, CollectorResponse] -func _Collector_ServicesStream_Handler(srv interface{}, stream grpc.ServerStream) error { - return srv.(CollectorServer).ServicesStream(&grpc.GenericServerStream[ServicesUpdate, ServicesUpdateResp]{ServerStream: stream}) +func _Collector_ReportServices_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ServicesUpdate) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(CollectorServer).ReportServices(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Collector_ReportServices_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(CollectorServer).ReportServices(ctx, req.(*ServicesUpdate)) + } + return interceptor(ctx, in, info, handler) } -// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. -type Collector_ServicesStreamServer = grpc.ClientStreamingServer[ServicesUpdate, ServicesUpdateResp] - // Collector_ServiceDesc is the grpc.ServiceDesc for Collector service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) var Collector_ServiceDesc = grpc.ServiceDesc{ ServiceName: "chat.Collector", HandlerType: (*CollectorServer)(nil), - Methods: []grpc.MethodDesc{}, + Methods: []grpc.MethodDesc{ + { + MethodName: "ReportServices", + Handler: _Collector_ReportServices_Handler, + }, + }, Streams: []grpc.StreamDesc{ { StreamName: "Stream", Handler: _Collector_Stream_Handler, ClientStreams: true, }, - { - StreamName: "ServicesStream", - Handler: _Collector_ServicesStream_Handler, - ClientStreams: true, - }, }, Metadata: "hellreign.proto", }