|
- /*
-
- 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 (
- "github.com/zeromicro/go-zero/zrpc"
- "gitlink.org.cn/jcce-pcm/pcm-coordinator/api/internal/svc"
- "gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/constants"
- "gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/models"
- "gitlink.org.cn/jcce-pcm/pcm-coordinator/pkg/tracker"
- "gitlink.org.cn/jcce-pcm/pcm-participant-kubernetes/kubernetesclient"
- )
-
- func SyncParticipantRpc(svc *svc.ServiceContext) {
- // 查询出所有p端信息
- var participants []*models.ScParticipantPhyInfo
- tx := svc.DbEngin.Find(&participants)
- if tx.Error != nil {
-
- }
- for _, participant := range participants {
-
- if len(participant.RpcAddress) != 0 && svc.K8sRpc[participant.Id] == nil {
- switch participant.Type {
- case constants.CLOUD, "SEALOS":
- // 初始化p端rpc客户端
- svc.K8sRpc[participant.Id] = kubernetesclient.NewKubernetes(zrpc.MustNewClient(zrpc.RpcClientConf{
- Endpoints: []string{participant.RpcAddress},
- NonBlock: true,
- }))
-
- // 初始化p端prometheus client
- promClient, err := tracker.NewPrometheus(participant.MetricsUrl)
- if err != nil {
- return
- }
- svc.PromClient[participant.Id] = promClient
- }
- }
- }
-
- }
|