feat 接入Prometheus

This commit is contained in:
2025-12-17 21:05:12 +08:00
parent efa9f50d3e
commit da91cff056
24 changed files with 289 additions and 60 deletions

View File

@@ -5,6 +5,7 @@ import (
"common/proto/sc/sc_pb"
"common/proto/ss/grpc_pb"
"gateway/handler/ws_handler"
"google.golang.org/protobuf/proto"
"sync"
)
@@ -23,9 +24,27 @@ func (s *Server) ToClient(server grpc_pb.Gateway_ToClientServer) error {
return
} else {
if args.UID == -1 {
for _, client := range ws_handler.UserMgr.GetAll() {
client.WriteBytes(sc_pb.MessageID(args.MessageID), args.Payload)
//utils.WorkerPool(ws_handler.UserMgr.GetAllInterface(), func(task interface{}) {
// client := task.(*ws_handler.Client)
// client.WriteBytes(sc_pb.MessageID(args.MessageID), args.Payload)
//})
data, err := proto.Marshal(&sc_pb.Message{
ID: sc_pb.MessageID(args.MessageID),
Payload: args.Payload,
})
if err != nil {
log.Errorf("ToClient proto.Marshal error: %v", err)
continue
}
for _, client := range ws_handler.UserMgr.GetAll() {
client.WriteBytesPreMarshal(data)
}
//for _, client := range ws_handler.UserMgr.GetAll() {
// client.WriteBytes(sc_pb.MessageID(args.MessageID), args.Payload)
//}
} else {
if client := ws_handler.UserMgr.GetByUID(args.UID); client != nil {
client.WriteBytes(sc_pb.MessageID(args.MessageID), args.Payload)