31 lines
834 B
Go
31 lines
834 B
Go
package cron
|
||
|
||
import (
|
||
"context"
|
||
"github.com/zeromicro/go-zero/core/logx"
|
||
"gitlink.org.cn/jcce-pcm/pcm-coordinator/rpc/client/participantservice"
|
||
"gitlink.org.cn/jcce-pcm/pcm-participant-openstack/internal/config"
|
||
"gitlink.org.cn/jcce-pcm/utils/tool"
|
||
)
|
||
|
||
func ReportHeartbeat(participantRpc participantservice.ParticipantService) {
|
||
participantId, err := tool.GetParticipantId("etc/pcmopenstack.yaml")
|
||
if err != nil {
|
||
logx.Errorf("获取participant id失败! err:", err)
|
||
return
|
||
}
|
||
resp, err := participantRpc.ReportHeartbeat(context.Background(), &participantservice.ParticipantHeartbeatReq{
|
||
ParticipantId: participantId,
|
||
Host: config.HOST,
|
||
Port: config.PORT,
|
||
})
|
||
if err != nil {
|
||
logx.Error(err)
|
||
return
|
||
}
|
||
if resp.Code != 200 {
|
||
logx.Error(resp.Msg)
|
||
}
|
||
logx.Info("心跳推送成功!")
|
||
}
|