forked from JointCloud/pcm-coordinator
42 lines
1.3 KiB
Go
42 lines
1.3 KiB
Go
/*
|
|
|
|
Copyright (c) [2023] [pcm]
|
|
[pcm-coordinator] is licensed under Mulan PSL v2.
|
|
You can use this software according to the terms and conditions of the Mulan PSL v2.
|
|
You may obtain a copy of Mulan PSL v2 at:
|
|
http://license.coscl.org.cn/MulanPSL2
|
|
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
|
EITHER EXPaRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
|
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
|
See the Mulan PSL v2 for more details.
|
|
|
|
*/
|
|
|
|
package cron
|
|
|
|
import (
|
|
"gitlink.org.cn/JointCloud/pcm-coordinator/api/internal/svc"
|
|
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/constants"
|
|
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/models"
|
|
"gitlink.org.cn/JointCloud/pcm-coordinator/pkg/tracker"
|
|
)
|
|
|
|
func SyncParticipantRpc(svc *svc.ServiceContext) {
|
|
// 查询出所有p端信息
|
|
var participants []*models.ScParticipantPhyInfo
|
|
svc.DbEngin.Where("type in (?)", []string{constants.CLOUD, constants.SEALOS}).Find(&participants)
|
|
if len(participants) != 0 {
|
|
for _, participant := range participants {
|
|
if len(participant.MetricsUrl) != 0 {
|
|
// 初始化p端prometheus client
|
|
promClient, err := tracker.NewPrometheus(participant.MetricsUrl)
|
|
if err != nil {
|
|
return
|
|
}
|
|
svc.PromClient[participant.Id] = promClient
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|