|
- package mqs
-
- import (
- "context"
- "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler"
- "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/scheduler/schedulers"
- "gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
- )
-
- /*
- *
- */
- type VmMq struct {
- ctx context.Context
- svcCtx *svc.ServiceContext
- }
-
- func NewVmMq(ctx context.Context, svcCtx *svc.ServiceContext) *VmMq {
- return &VmMq{
- ctx: ctx,
- svcCtx: svcCtx,
- }
- }
-
- func (l *VmMq) Consume(val string) error {
- // 接受消息, 根据标签筛选过滤
- vmScheduler := schedulers.NewVmScheduler()
- schdl, err := scheduler.NewScheduler(vmScheduler, val, l.svcCtx.DbEngin, l.svcCtx.ParticipantRpc)
- if err != nil {
- return err
- }
-
- //检测是否指定了集群列表
- schdl.SpecifyClusters()
-
- //检测是否指定了nsID
- schdl.SpecifyNsID()
-
- //通过标签匹配筛选出集群范围
- schdl.MatchLabels()
-
- //todo 屏蔽原调度算法,因为监控数据暂未上报,临时采用随机调度
- schdl.TempAssign()
-
- // 存储数据
- err = schdl.SaveToDb()
- if err != nil {
- return err
- }
- return nil
- }
|