forked from JointCloud/pcm-hpc
36 lines
953 B
Go
36 lines
953 B
Go
package logic
|
|
|
|
import (
|
|
"context"
|
|
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/pkg/utils/httputils"
|
|
|
|
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/svc"
|
|
"gitlink.org.cn/jcce-pcm/pcm-slurm/slurm"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
)
|
|
|
|
type PingLogic struct {
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
logx.Logger
|
|
}
|
|
|
|
func NewPingLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PingLogic {
|
|
return &PingLogic{
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
Logger: logx.WithContext(ctx),
|
|
}
|
|
}
|
|
|
|
func (l *PingLogic) Ping(in *slurm.PingReq) (*slurm.PingResp, error) {
|
|
var resp slurm.PingResp
|
|
slurmHttpRequest := httputils.GetHttpRequest()
|
|
slurmHttpRequest.SetHeader(httputils.ContentType, httputils.ApplicationJson).
|
|
SetHeader("X-SLURM-USER-NAME", l.svcCtx.Config.SlurmRestUser).
|
|
SetHeader("X-SLURM-USER-TOKEN", l.svcCtx.Config.SlurmToken).
|
|
SetResult(&resp).Get(l.svcCtx.Config.RestUrl + l.svcCtx.Config.Path.Ping)
|
|
return &resp, nil
|
|
}
|