forked from JointCloud/pcm-hpc
26 lines
785 B
Go
26 lines
785 B
Go
package svc
|
|
|
|
import (
|
|
"github.com/robfig/cron/v3"
|
|
"github.com/zeromicro/go-zero/zrpc"
|
|
"gitlink.org.cn/jcce-pcm/pcm-coordinator/rpc/client/participantservice"
|
|
"gitlink.org.cn/jcce-pcm/pcm-coordinator/rpc/client/pcmcore"
|
|
"gitlink.org.cn/jcce-pcm/pcm-slurm/internal/config"
|
|
)
|
|
|
|
type ServiceContext struct {
|
|
Config config.Config
|
|
Cron *cron.Cron
|
|
PcmCoreRpc pcmcore.PcmCore
|
|
ParticipantRpc participantservice.ParticipantService
|
|
}
|
|
|
|
func NewServiceContext(c config.Config) *ServiceContext {
|
|
return &ServiceContext{
|
|
Cron: cron.New(cron.WithSeconds()),
|
|
Config: c,
|
|
PcmCoreRpc: pcmcore.NewPcmCore(zrpc.MustNewClient(c.PcmCoreRpcConf)),
|
|
ParticipantRpc: participantservice.NewParticipantService(zrpc.MustNewClient(c.PcmCoreRpcConf)),
|
|
}
|
|
}
|