You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

syncclusteralertlogic.go 956 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package monitoring
  2. import (
  3. "context"
  4. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
  5. "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
  6. "k8s.io/apimachinery/pkg/util/json"
  7. "time"
  8. "github.com/zeromicro/go-zero/core/logx"
  9. )
  10. type SyncClusterAlertLogic struct {
  11. logx.Logger
  12. ctx context.Context
  13. svcCtx *svc.ServiceContext
  14. }
  15. func NewSyncClusterAlertLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SyncClusterAlertLogic {
  16. return &SyncClusterAlertLogic{
  17. Logger: logx.WithContext(ctx),
  18. ctx: ctx,
  19. svcCtx: svcCtx,
  20. }
  21. }
  22. func (l *SyncClusterAlertLogic) SyncClusterAlert(req *types.SyncClusterAlertReq) error {
  23. if len(req.AlertRecordsMap) != 0 {
  24. for k, v := range req.AlertRecordsMap {
  25. bytes, err := json.Marshal(v)
  26. if err != nil {
  27. return err
  28. }
  29. setCmd := l.svcCtx.RedisClient.Set(l.ctx, k, bytes, 1*time.Minute)
  30. if setCmd.Err() != nil {
  31. logx.Error(setCmd.Err())
  32. }
  33. }
  34. }
  35. return nil
  36. }

PCM is positioned as Software stack over Cloud, aiming to build the standards and ecology of heterogeneous cloud collaboration for JCC in a non intrusive and autonomous peer-to-peer manner.