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.

registerclusterlogic.go 1.2 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package cloud
  2. import (
  3. "context"
  4. "gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/models"
  5. "gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/utils"
  6. "time"
  7. "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
  8. "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/types"
  9. "github.com/zeromicro/go-zero/core/logx"
  10. )
  11. type RegisterClusterLogic struct {
  12. logx.Logger
  13. ctx context.Context
  14. svcCtx *svc.ServiceContext
  15. }
  16. func NewRegisterClusterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RegisterClusterLogic {
  17. return &RegisterClusterLogic{
  18. Logger: logx.WithContext(ctx),
  19. ctx: ctx,
  20. svcCtx: svcCtx,
  21. }
  22. }
  23. func (l *RegisterClusterLogic) RegisterCluster(req *types.RegisterClusterReq) (resp *types.CloudResp, err error) {
  24. // 查询出所有p端信息
  25. participant := models.ScParticipantPhyInfo{}
  26. participant.Token = req.Token
  27. participant.Name = req.Name
  28. participant.Address = req.Address
  29. participant.Type = req.Type
  30. participant.Id = utils.GenSnowflakeID()
  31. participant.MetricsUrl = req.MetricsUrl
  32. participant.CreatedTime = time.Now()
  33. participant.UpdatedTime = time.Now()
  34. tx := l.svcCtx.DbEngin.Create(&participant)
  35. if tx.Error != nil {
  36. return nil, tx.Error
  37. }
  38. return
  39. }

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.