From 1d75935a08a5e3814ebec6d247a1decac6697442 Mon Sep 17 00:00:00 2001 From: "zero@thinky" Date: Sat, 4 Apr 2026 19:53:05 +0300 Subject: [PATCH] feat(proto): add service monitor --- proto/hellreign.proto | 11 ++ proto/proto/hellreign.pb.go | 207 ++++++++++++++++++++++++++----- proto/proto/hellreign_grpc.pb.go | 33 ++++- 3 files changed, 219 insertions(+), 32 deletions(-) diff --git a/proto/hellreign.proto b/proto/hellreign.proto index 2cea8d1..0abc0a3 100644 --- a/proto/hellreign.proto +++ b/proto/hellreign.proto @@ -6,6 +6,16 @@ option go_package="gitea.d3m0k1d.ru/d3m0k1d/HellreigN/proto/proto"; service Collector { rpc Stream(stream CollectorRequest) returns (CollectorResponse); + rpc ServicesStream(stream ServicesUpdate) returns (ServicesUpdateResp); +} +message ServicesUpdateResp { +} +message ServicesUpdate { + message ServiceUpdate { + string name = 1; + string status = 2; + } + repeated ServiceUpdate services = 1; } message CollectorRequest { @@ -31,3 +41,4 @@ message FinishedCommand { string stdout = 3; string stderr = 4; } + diff --git a/proto/proto/hellreign.pb.go b/proto/proto/hellreign.pb.go index 2902f4c..c138eaa 100644 --- a/proto/proto/hellreign.pb.go +++ b/proto/proto/hellreign.pb.go @@ -21,6 +21,86 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +type ServicesUpdateResp struct { + state protoimpl.MessageState `protogen:"open.v1"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ServicesUpdateResp) Reset() { + *x = ServicesUpdateResp{} + mi := &file_hellreign_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ServicesUpdateResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ServicesUpdateResp) ProtoMessage() {} + +func (x *ServicesUpdateResp) ProtoReflect() protoreflect.Message { + mi := &file_hellreign_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ServicesUpdateResp.ProtoReflect.Descriptor instead. +func (*ServicesUpdateResp) Descriptor() ([]byte, []int) { + return file_hellreign_proto_rawDescGZIP(), []int{0} +} + +type ServicesUpdate struct { + state protoimpl.MessageState `protogen:"open.v1"` + Services []*ServicesUpdate_ServiceUpdate `protobuf:"bytes,1,rep,name=services,proto3" json:"services,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ServicesUpdate) Reset() { + *x = ServicesUpdate{} + mi := &file_hellreign_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ServicesUpdate) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ServicesUpdate) ProtoMessage() {} + +func (x *ServicesUpdate) ProtoReflect() protoreflect.Message { + mi := &file_hellreign_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ServicesUpdate.ProtoReflect.Descriptor instead. +func (*ServicesUpdate) Descriptor() ([]byte, []int) { + return file_hellreign_proto_rawDescGZIP(), []int{1} +} + +func (x *ServicesUpdate) GetServices() []*ServicesUpdate_ServiceUpdate { + if x != nil { + return x.Services + } + return nil +} + type CollectorRequest struct { state protoimpl.MessageState `protogen:"open.v1"` Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` @@ -30,7 +110,7 @@ type CollectorRequest struct { func (x *CollectorRequest) Reset() { *x = CollectorRequest{} - mi := &file_hellreign_proto_msgTypes[0] + mi := &file_hellreign_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -42,7 +122,7 @@ func (x *CollectorRequest) String() string { func (*CollectorRequest) ProtoMessage() {} func (x *CollectorRequest) ProtoReflect() protoreflect.Message { - mi := &file_hellreign_proto_msgTypes[0] + mi := &file_hellreign_proto_msgTypes[2] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -55,7 +135,7 @@ func (x *CollectorRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use CollectorRequest.ProtoReflect.Descriptor instead. func (*CollectorRequest) Descriptor() ([]byte, []int) { - return file_hellreign_proto_rawDescGZIP(), []int{0} + return file_hellreign_proto_rawDescGZIP(), []int{2} } func (x *CollectorRequest) GetMessage() string { @@ -73,7 +153,7 @@ type CollectorResponse struct { func (x *CollectorResponse) Reset() { *x = CollectorResponse{} - mi := &file_hellreign_proto_msgTypes[1] + mi := &file_hellreign_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -85,7 +165,7 @@ func (x *CollectorResponse) String() string { func (*CollectorResponse) ProtoMessage() {} func (x *CollectorResponse) ProtoReflect() protoreflect.Message { - mi := &file_hellreign_proto_msgTypes[1] + mi := &file_hellreign_proto_msgTypes[3] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -98,7 +178,7 @@ func (x *CollectorResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use CollectorResponse.ProtoReflect.Descriptor instead. func (*CollectorResponse) Descriptor() ([]byte, []int) { - return file_hellreign_proto_rawDescGZIP(), []int{1} + return file_hellreign_proto_rawDescGZIP(), []int{3} } type Command struct { @@ -112,7 +192,7 @@ type Command struct { func (x *Command) Reset() { *x = Command{} - mi := &file_hellreign_proto_msgTypes[2] + mi := &file_hellreign_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -124,7 +204,7 @@ func (x *Command) String() string { func (*Command) ProtoMessage() {} func (x *Command) ProtoReflect() protoreflect.Message { - mi := &file_hellreign_proto_msgTypes[2] + mi := &file_hellreign_proto_msgTypes[4] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -137,7 +217,7 @@ func (x *Command) ProtoReflect() protoreflect.Message { // Deprecated: Use Command.ProtoReflect.Descriptor instead. func (*Command) Descriptor() ([]byte, []int) { - return file_hellreign_proto_rawDescGZIP(), []int{2} + return file_hellreign_proto_rawDescGZIP(), []int{4} } func (x *Command) GetId() int64 { @@ -173,7 +253,7 @@ type FinishedCommand struct { func (x *FinishedCommand) Reset() { *x = FinishedCommand{} - mi := &file_hellreign_proto_msgTypes[3] + mi := &file_hellreign_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -185,7 +265,7 @@ func (x *FinishedCommand) String() string { func (*FinishedCommand) ProtoMessage() {} func (x *FinishedCommand) ProtoReflect() protoreflect.Message { - mi := &file_hellreign_proto_msgTypes[3] + mi := &file_hellreign_proto_msgTypes[5] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -198,7 +278,7 @@ func (x *FinishedCommand) ProtoReflect() protoreflect.Message { // Deprecated: Use FinishedCommand.ProtoReflect.Descriptor instead. func (*FinishedCommand) Descriptor() ([]byte, []int) { - return file_hellreign_proto_rawDescGZIP(), []int{3} + return file_hellreign_proto_rawDescGZIP(), []int{5} } func (x *FinishedCommand) GetId() int64 { @@ -229,11 +309,69 @@ func (x *FinishedCommand) GetStderr() string { return "" } +type ServicesUpdate_ServiceUpdate struct { + state protoimpl.MessageState `protogen:"open.v1"` + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Status string `protobuf:"bytes,2,opt,name=status,proto3" json:"status,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ServicesUpdate_ServiceUpdate) Reset() { + *x = ServicesUpdate_ServiceUpdate{} + mi := &file_hellreign_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ServicesUpdate_ServiceUpdate) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ServicesUpdate_ServiceUpdate) ProtoMessage() {} + +func (x *ServicesUpdate_ServiceUpdate) ProtoReflect() protoreflect.Message { + mi := &file_hellreign_proto_msgTypes[6] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ServicesUpdate_ServiceUpdate.ProtoReflect.Descriptor instead. +func (*ServicesUpdate_ServiceUpdate) Descriptor() ([]byte, []int) { + return file_hellreign_proto_rawDescGZIP(), []int{1, 0} +} + +func (x *ServicesUpdate_ServiceUpdate) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *ServicesUpdate_ServiceUpdate) GetStatus() string { + if x != nil { + return x.Status + } + return "" +} + var File_hellreign_proto protoreflect.FileDescriptor const file_hellreign_proto_rawDesc = "" + "\n" + - "\x0fhellreign.proto\x12\x04chat\",\n" + + "\x0fhellreign.proto\x12\x04chat\"\x14\n" + + "\x12ServicesUpdateResp\"\x8d\x01\n" + + "\x0eServicesUpdate\x12>\n" + + "\bservices\x18\x01 \x03(\v2\".chat.ServicesUpdate.ServiceUpdateR\bservices\x1a;\n" + + "\rServiceUpdate\x12\x12\n" + + "\x04name\x18\x01 \x01(\tR\x04name\x12\x16\n" + + "\x06status\x18\x02 \x01(\tR\x06status\",\n" + "\x10CollectorRequest\x12\x18\n" + "\amessage\x18\x01 \x01(\tR\amessage\"\x13\n" + "\x11CollectorResponse\"X\n" + @@ -246,9 +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\x06stderr2H\n" + + "\x06stderr\x18\x04 \x01(\tR\x06stderr2\x8c\x01\n" + "\tCollector\x12;\n" + - "\x06Stream\x12\x16.chat.CollectorRequest\x1a\x17.chat.CollectorResponse(\x012?\n" + + "\x06Stream\x12\x16.chat.CollectorRequest\x1a\x17.chat.CollectorResponse(\x01\x12B\n" + + "\x0eServicesStream\x12\x14.chat.ServicesUpdate\x1a\x18.chat.ServicesUpdateResp(\x012?\n" + "\tCommander\x122\n" + "\x06Stream\x12\x15.chat.FinishedCommand\x1a\r.chat.Command(\x010\x01B0Z.gitea.d3m0k1d.ru/d3m0k1d/HellreigN/proto/protob\x06proto3" @@ -264,23 +403,29 @@ func file_hellreign_proto_rawDescGZIP() []byte { return file_hellreign_proto_rawDescData } -var file_hellreign_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_hellreign_proto_msgTypes = make([]protoimpl.MessageInfo, 7) var file_hellreign_proto_goTypes = []any{ - (*CollectorRequest)(nil), // 0: chat.CollectorRequest - (*CollectorResponse)(nil), // 1: chat.CollectorResponse - (*Command)(nil), // 2: chat.Command - (*FinishedCommand)(nil), // 3: chat.FinishedCommand + (*ServicesUpdateResp)(nil), // 0: chat.ServicesUpdateResp + (*ServicesUpdate)(nil), // 1: chat.ServicesUpdate + (*CollectorRequest)(nil), // 2: chat.CollectorRequest + (*CollectorResponse)(nil), // 3: chat.CollectorResponse + (*Command)(nil), // 4: chat.Command + (*FinishedCommand)(nil), // 5: chat.FinishedCommand + (*ServicesUpdate_ServiceUpdate)(nil), // 6: chat.ServicesUpdate.ServiceUpdate } var file_hellreign_proto_depIdxs = []int32{ - 0, // 0: chat.Collector.Stream:input_type -> chat.CollectorRequest - 3, // 1: chat.Commander.Stream:input_type -> chat.FinishedCommand - 1, // 2: chat.Collector.Stream:output_type -> chat.CollectorResponse - 2, // 3: chat.Commander.Stream:output_type -> chat.Command - 2, // [2:4] is the sub-list for method output_type - 0, // [0:2] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name + 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 + 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 + 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 + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name } func init() { file_hellreign_proto_init() } @@ -288,14 +433,14 @@ func file_hellreign_proto_init() { if File_hellreign_proto != nil { return } - file_hellreign_proto_msgTypes[2].OneofWrappers = []any{} + file_hellreign_proto_msgTypes[4].OneofWrappers = []any{} type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_hellreign_proto_rawDesc), len(file_hellreign_proto_rawDesc)), NumEnums: 0, - NumMessages: 4, + NumMessages: 7, NumExtensions: 0, NumServices: 2, }, diff --git a/proto/proto/hellreign_grpc.pb.go b/proto/proto/hellreign_grpc.pb.go index 357bb4f..ec651fc 100644 --- a/proto/proto/hellreign_grpc.pb.go +++ b/proto/proto/hellreign_grpc.pb.go @@ -19,7 +19,8 @@ import ( const _ = grpc.SupportPackageIsVersion9 const ( - Collector_Stream_FullMethodName = "/chat.Collector/Stream" + Collector_Stream_FullMethodName = "/chat.Collector/Stream" + Collector_ServicesStream_FullMethodName = "/chat.Collector/ServicesStream" ) // CollectorClient is the client API for Collector service. @@ -27,6 +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) } type collectorClient struct { @@ -50,11 +52,25 @@ 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) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + stream, err := c.cc.NewStream(ctx, &Collector_ServiceDesc.Streams[1], Collector_ServicesStream_FullMethodName, cOpts...) + if err != nil { + return nil, err + } + x := &grpc.GenericClientStream[ServicesUpdate, ServicesUpdateResp]{ClientStream: 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 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 mustEmbedUnimplementedCollectorServer() } @@ -68,6 +84,9 @@ 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) mustEmbedUnimplementedCollectorServer() {} func (UnimplementedCollectorServer) testEmbeddedByValue() {} @@ -96,6 +115,13 @@ 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}) +} + +// 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) @@ -109,6 +135,11 @@ var Collector_ServiceDesc = grpc.ServiceDesc{ Handler: _Collector_Stream_Handler, ClientStreams: true, }, + { + StreamName: "ServicesStream", + Handler: _Collector_ServicesStream_Handler, + ClientStreams: true, + }, }, Metadata: "hellreign.proto", }