package monitoring import ( "context" "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc" "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/types" "k8s.io/apimachinery/pkg/util/json" "time" "github.com/zeromicro/go-zero/core/logx" ) type SyncClusterAlertLogic struct { logx.Logger ctx context.Context svcCtx *svc.ServiceContext } func NewSyncClusterAlertLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SyncClusterAlertLogic { return &SyncClusterAlertLogic{ Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx, } } func (l *SyncClusterAlertLogic) SyncClusterAlert(req *types.SyncClusterAlertReq) error { if len(req.AlertRecordsMap) != 0 { for k, v := range req.AlertRecordsMap { bytes, err := json.Marshal(v) if err != nil { return err } setCmd := l.svcCtx.RedisClient.Set(l.ctx, k, bytes, 1*time.Minute) if setCmd.Err() != nil { logx.Error(setCmd.Err()) } } } return nil }