init
This commit is contained in:
parent
dd1f2099b7
commit
7b82550400
|
@ -0,0 +1,9 @@
|
|||
Name: slurmcore-api
|
||||
Host: 0.0.0.0
|
||||
Port: 8899
|
||||
|
||||
#rpc
|
||||
ShuguangRpcConf:
|
||||
Endpoints:
|
||||
- 127.0.0.1:2001
|
||||
NonBlock: true
|
|
@ -0,0 +1,12 @@
|
|||
package config
|
||||
|
||||
import (
|
||||
"github.com/zeromicro/go-zero/rest"
|
||||
"github.com/zeromicro/go-zero/zrpc"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
rest.RestConf
|
||||
|
||||
ShuguangRpcConf zrpc.RpcClientConf
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"PCM/app/slurm/slurmCore/api/internal/logic"
|
||||
"PCM/app/slurm/slurmCore/api/internal/svc"
|
||||
"PCM/app/slurm/slurmCore/api/internal/types"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
)
|
||||
|
||||
func GetDomainSummaryHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.GetDomainSummaryReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := logic.NewGetDomainSummaryLogic(r.Context(), svcCtx)
|
||||
resp, err := l.GetDomainSummary(&req)
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
} else {
|
||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"PCM/app/slurm/slurmCore/api/internal/logic"
|
||||
"PCM/app/slurm/slurmCore/api/internal/svc"
|
||||
"PCM/app/slurm/slurmCore/api/internal/types"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
)
|
||||
|
||||
func ListDbJobsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.ListDbJobsReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := logic.NewListDbJobsLogic(r.Context(), svcCtx)
|
||||
resp, err := l.ListDbJobs(&req)
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
} else {
|
||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"PCM/app/slurm/slurmCore/api/internal/logic"
|
||||
"PCM/app/slurm/slurmCore/api/internal/svc"
|
||||
"PCM/app/slurm/slurmCore/api/internal/types"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
)
|
||||
|
||||
func ListDomainHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.ListDomainReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := logic.NewListDomainLogic(r.Context(), svcCtx)
|
||||
resp, err := l.ListDomain(&req)
|
||||
if err != nil {
|
||||
httpx.ErrorCtx(r.Context(), w, err)
|
||||
} else {
|
||||
httpx.OkJsonCtx(r.Context(), w, resp)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
// Code generated by goctl. DO NOT EDIT.
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"PCM/app/slurm/slurmCore/api/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest"
|
||||
)
|
||||
|
||||
func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||||
server.AddRoutes(
|
||||
[]rest.Route{
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/listDomain",
|
||||
Handler: ListDomainHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/getDomainSummary",
|
||||
Handler: GetDomainSummaryHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/listDbJobs",
|
||||
Handler: ListDbJobsHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
)
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"PCM/app/slurm/slurmCore/api/internal/svc"
|
||||
"PCM/app/slurm/slurmCore/api/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetDomainSummaryLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewGetDomainSummaryLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetDomainSummaryLogic {
|
||||
return &GetDomainSummaryLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetDomainSummaryLogic) GetDomainSummary(req *types.GetDomainSummaryReq) (resp *types.GetDomainSummaryResp, err error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"PCM/app/slurm/slurmShuguang/rpc/slurmshuguangclient"
|
||||
"context"
|
||||
"github.com/jinzhu/copier"
|
||||
|
||||
"PCM/app/slurm/slurmCore/api/internal/svc"
|
||||
"PCM/app/slurm/slurmCore/api/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type ListDbJobsLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewListDbJobsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListDbJobsLogic {
|
||||
return &ListDbJobsLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *ListDbJobsLogic) ListDbJobs(req *types.ListDbJobsReq) (resp *types.ListDbJobsResp, err error) {
|
||||
|
||||
listDbJobsResp, err := l.svcCtx.ShuguangRpc.ListDbJobs(l.ctx, &slurmshuguangclient.ListDbJobsReq{}, nil)
|
||||
copier.Copy(&resp, &listDbJobsResp)
|
||||
|
||||
return resp, nil
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"PCM/app/slurm/slurmCore/api/internal/svc"
|
||||
"PCM/app/slurm/slurmCore/api/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type ListDomainLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewListDomainLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListDomainLogic {
|
||||
return &ListDomainLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *ListDomainLogic) ListDomain(req *types.ListDomainReq) (resp *types.ListDomainResp, err error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package svc
|
||||
|
||||
import (
|
||||
"PCM/app/slurm/slurmCore/api/internal/config"
|
||||
"PCM/app/slurm/slurmShuguang/rpc/slurmshuguangclient"
|
||||
"github.com/zeromicro/go-zero/zrpc"
|
||||
)
|
||||
|
||||
type ServiceContext struct {
|
||||
Config config.Config
|
||||
|
||||
ShuguangRpc slurmshuguangclient.SlurmShuguang
|
||||
}
|
||||
|
||||
func NewServiceContext(c config.Config) *ServiceContext {
|
||||
return &ServiceContext{
|
||||
Config: c,
|
||||
|
||||
ShuguangRpc: slurmshuguangclient.NewSlurmShuguang(zrpc.MustNewClient(c.ShuguangRpcConf)),
|
||||
}
|
||||
}
|
|
@ -0,0 +1,89 @@
|
|||
// Code generated by goctl. DO NOT EDIT.
|
||||
package types
|
||||
|
||||
type Domain struct {
|
||||
DomainName string `json:"domainName"`
|
||||
SoftStack string `json:"softStack"`
|
||||
SlurmNum int32 `json:"slurmNum"`
|
||||
InterfaceCount int32 `json:"interfaceCount"`
|
||||
RunningJobs int32 `json:"runningJobs"`
|
||||
}
|
||||
|
||||
type DomainSummary struct {
|
||||
DomainCount int32 `json:"domainCount"`
|
||||
SoftStackCount int32 `json:"softStackCount"`
|
||||
}
|
||||
|
||||
type JobInfoDbGet struct {
|
||||
AllocCPU uint32 `json:"domainName"`
|
||||
AllocNodes uint32 `json:"domainName"`
|
||||
Account string `json:"domainName"`
|
||||
AssocId uint32 `json:"domainName"`
|
||||
BlockId string `json:"domainName"`
|
||||
Cluster string `json:"domainName"`
|
||||
DerivedEc uint32 `json:"domainName"`
|
||||
DerivedEs string `json:"domainName"`
|
||||
Elapsed uint32 `json:"domainName"`
|
||||
Eligible int64 `json:"domainName"`
|
||||
End int64 `json:"domainName"`
|
||||
ExitCode uint32 `json:"domainName"`
|
||||
Gid uint32 `json:"domainName"`
|
||||
JobId uint32 `json:"domainName"`
|
||||
JobName string `json:"domainName"`
|
||||
Lft uint32 `json:"domainName"`
|
||||
Partition string `json:"domainName"`
|
||||
Nodes string `json:"domainName"`
|
||||
Priority uint32 `json:"domainName"`
|
||||
Qosid uint32 `json:"domainName"`
|
||||
ReqCpus uint32 `json:"domainName"`
|
||||
ReqMem uint32 `json:"domainName"`
|
||||
Requid uint32 `json:"domainName"`
|
||||
Resvid uint32 `json:"domainName"`
|
||||
ShowFull uint32 `json:"domainName"`
|
||||
Start int64 `json:"domainName"`
|
||||
State uint32 `json:"domainName"`
|
||||
Submit int64 `json:"domainName"`
|
||||
Suspended uint32 `json:"domainName"`
|
||||
SysCpuSec uint32 `json:"domainName"`
|
||||
SysCpuUsec uint32 `json:"domainName"`
|
||||
Timelimit uint32 `json:"domainName"`
|
||||
TotCpuSec uint32 `json:"domainName"`
|
||||
TotCpuUsec uint32 `json:"domainName"`
|
||||
TrackSteps uint32 `json:"domainName"`
|
||||
Uid uint32 `json:"domainName"`
|
||||
User string `json:"domainName"`
|
||||
UserCpuSec uint32 `json:"domainName"`
|
||||
UserCpuUsec uint32 `json:"domainName"`
|
||||
Wckey string `json:"domainName"`
|
||||
Wckeyid uint32 `json:"domainName"`
|
||||
WorkDir string `json:"domainName"`
|
||||
SlurmVersion string `json:"domainName"`
|
||||
}
|
||||
|
||||
type ListDomainReq struct {
|
||||
}
|
||||
|
||||
type ListDomainResp struct {
|
||||
Code int32 `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
Domains []Domain `json:"domains"`
|
||||
}
|
||||
|
||||
type GetDomainSummaryReq struct {
|
||||
}
|
||||
|
||||
type GetDomainSummaryResp struct {
|
||||
Code int32 `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
DomainSummary DomainSummary `json:"domainSummary"`
|
||||
}
|
||||
|
||||
type ListDbJobsReq struct {
|
||||
}
|
||||
|
||||
type ListDbJobsResp struct {
|
||||
Code int32 `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
RecordCount int32 `json:"recordCount"`
|
||||
JobInfoDbs []JobInfoDbGet `json:"jobInfoDbs"`
|
||||
}
|
|
@ -0,0 +1,111 @@
|
|||
syntax = "v1"
|
||||
|
||||
info(
|
||||
title: "slurm core"
|
||||
desc: "slurm core端微服务"
|
||||
author: "zhouqj"
|
||||
email: "450705171@qq.com"
|
||||
)
|
||||
|
||||
type Domain {
|
||||
DomainName string `json:"domainName"`
|
||||
SoftStack string `json:"softStack"`
|
||||
SlurmNum int32 `json:"slurmNum"`
|
||||
InterfaceCount int32 `json:"interfaceCount"`
|
||||
RunningJobs int32 `json:"runningJobs"`
|
||||
}
|
||||
|
||||
type DomainSummary {
|
||||
DomainCount int32 `json:"domainCount"`
|
||||
SoftStackCount int32 `json:"softStackCount"`
|
||||
}
|
||||
|
||||
type JobInfoDbGet {
|
||||
AllocCPU uint32 `json:"domainName"`
|
||||
AllocNodes uint32 `json:"domainName"`
|
||||
Account string `json:"domainName"`
|
||||
AssocId uint32 `json:"domainName"`
|
||||
BlockId string `json:"domainName"`
|
||||
Cluster string `json:"domainName"`
|
||||
DerivedEc uint32 `json:"domainName"`
|
||||
DerivedEs string `json:"domainName"`
|
||||
Elapsed uint32 `json:"domainName"`
|
||||
Eligible int64 `json:"domainName"`
|
||||
End int64 `json:"domainName"`
|
||||
ExitCode uint32 `json:"domainName"`
|
||||
Gid uint32 `json:"domainName"`
|
||||
JobId uint32 `json:"domainName"`
|
||||
JobName string `json:"domainName"`
|
||||
Lft uint32 `json:"domainName"`
|
||||
Partition string `json:"domainName"`
|
||||
Nodes string `json:"domainName"`
|
||||
Priority uint32 `json:"domainName"`
|
||||
Qosid uint32 `json:"domainName"`
|
||||
ReqCpus uint32 `json:"domainName"`
|
||||
ReqMem uint32 `json:"domainName"`
|
||||
Requid uint32 `json:"domainName"`
|
||||
Resvid uint32 `json:"domainName"`
|
||||
ShowFull uint32 `json:"domainName"`
|
||||
Start int64 `json:"domainName"`
|
||||
State uint32 `json:"domainName"`
|
||||
Submit int64 `json:"domainName"`
|
||||
Suspended uint32 `json:"domainName"`
|
||||
SysCpuSec uint32 `json:"domainName"`
|
||||
SysCpuUsec uint32 `json:"domainName"`
|
||||
Timelimit uint32 `json:"domainName"`
|
||||
TotCpuSec uint32 `json:"domainName"`
|
||||
TotCpuUsec uint32 `json:"domainName"`
|
||||
TrackSteps uint32 `json:"domainName"`
|
||||
Uid uint32 `json:"domainName"`
|
||||
User string `json:"domainName"`
|
||||
UserCpuSec uint32 `json:"domainName"`
|
||||
UserCpuUsec uint32 `json:"domainName"`
|
||||
Wckey string `json:"domainName"`
|
||||
Wckeyid uint32 `json:"domainName"`
|
||||
WorkDir string `json:"domainName"`
|
||||
SlurmVersion string `json:"domainName"`
|
||||
}
|
||||
|
||||
type (
|
||||
listDomainReq {
|
||||
}
|
||||
|
||||
listDomainResp {
|
||||
Code int32 `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
Domains []Domain `json:"domains"`
|
||||
}
|
||||
)
|
||||
|
||||
type (
|
||||
getDomainSummaryReq {
|
||||
}
|
||||
|
||||
getDomainSummaryResp {
|
||||
Code int32 `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
DomainSummary DomainSummary `json:"domainSummary"`
|
||||
}
|
||||
)
|
||||
|
||||
type (
|
||||
listDbJobsReq {
|
||||
}
|
||||
listDbJobsResp {
|
||||
Code int32 `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
RecordCount int32 `json:"recordCount"`
|
||||
JobInfoDbs []JobInfoDbGet `json:"jobInfoDbs"`
|
||||
}
|
||||
)
|
||||
|
||||
service slurmcore-api {
|
||||
@handler ListDomainHandler
|
||||
get /listDomain (listDomainReq) returns (listDomainResp)
|
||||
|
||||
@handler GetDomainSummaryHandler
|
||||
get /getDomainSummary (getDomainSummaryReq) returns (getDomainSummaryResp)
|
||||
|
||||
@handler ListDbJobsHandler
|
||||
get /listDbJobs (listDbJobsReq) returns (listDbJobsResp)
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
|
||||
"PCM/app/slurm/slurmCore/api/internal/config"
|
||||
"PCM/app/slurm/slurmCore/api/internal/handler"
|
||||
"PCM/app/slurm/slurmCore/api/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/conf"
|
||||
"github.com/zeromicro/go-zero/rest"
|
||||
)
|
||||
|
||||
// C:\Users\Administrator\GolandProjects\PCM\app\slurm\slurmShuguang\rpc
|
||||
var configFile = flag.String("f", "C:\\Users\\Administrator\\GolandProjects\\PCM\\app\\slurm\\slurmCore\\api\\etc\\slurmcore-api.yaml", "the config file")
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
var c config.Config
|
||||
conf.MustLoad(*configFile, &c)
|
||||
|
||||
server := rest.MustNewServer(c.RestConf)
|
||||
defer server.Stop()
|
||||
|
||||
ctx := svc.NewServiceContext(c)
|
||||
handler.RegisterHandlers(server, ctx)
|
||||
|
||||
fmt.Printf("Starting server at %s:%d...\n", c.Host, c.Port)
|
||||
server.Start()
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
|
||||
"PCM/app/slurm/slurmCore/rpc/domain/domain"
|
||||
"PCM/app/slurm/slurmCore/rpc/domain/internal/config"
|
||||
"PCM/app/slurm/slurmCore/rpc/domain/internal/server"
|
||||
"PCM/app/slurm/slurmCore/rpc/domain/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/conf"
|
||||
"github.com/zeromicro/go-zero/core/service"
|
||||
"github.com/zeromicro/go-zero/zrpc"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/reflection"
|
||||
)
|
||||
|
||||
var configFile = flag.String("f", "etc/domain.yaml", "the config file")
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
var c config.Config
|
||||
conf.MustLoad(*configFile, &c)
|
||||
ctx := svc.NewServiceContext(c)
|
||||
|
||||
s := zrpc.MustNewServer(c.RpcServerConf, func(grpcServer *grpc.Server) {
|
||||
domain.RegisterDomainSvcServer(grpcServer, server.NewDomainSvcServer(ctx))
|
||||
|
||||
if c.Mode == service.DevMode || c.Mode == service.TestMode {
|
||||
reflection.Register(grpcServer)
|
||||
}
|
||||
})
|
||||
defer s.Stop()
|
||||
|
||||
fmt.Printf("Starting rpc server at %s...\n", c.ListenOn)
|
||||
s.Start()
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package list;
|
||||
option go_package = "./domain";
|
||||
|
||||
message Domain {
|
||||
string domainName = 1;
|
||||
string softStack = 2;
|
||||
int32 slurmNum = 3;
|
||||
int32 interfaceCount = 4;
|
||||
int32 runningJobs = 5;
|
||||
}
|
||||
|
||||
message DomainSummary {
|
||||
int32 domainCount = 1;
|
||||
int32 softStackCount = 2;
|
||||
}
|
||||
|
||||
message listDomainRequest {
|
||||
}
|
||||
|
||||
message listDomainResponse {
|
||||
int32 code = 1;
|
||||
string msg = 2;
|
||||
repeated Domain domains = 3;
|
||||
}
|
||||
|
||||
message getDomainSummaryRequest {
|
||||
}
|
||||
|
||||
message getDomainSummaryResponse {
|
||||
int32 code = 1;
|
||||
string msg = 2;
|
||||
DomainSummary domainSummary = 3;
|
||||
}
|
||||
|
||||
service domainSvc {
|
||||
rpc listDomain(listDomainRequest) returns(listDomainResponse);
|
||||
rpc getDomainSummary(getDomainSummaryRequest) returns(getDomainSummaryResponse);
|
||||
}
|
|
@ -0,0 +1,543 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.28.1
|
||||
// protoc v3.19.4
|
||||
// source: domain.proto
|
||||
|
||||
package domain
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
type Domain struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
DomainName string `protobuf:"bytes,1,opt,name=domainName,proto3" json:"domainName,omitempty"`
|
||||
SoftStack string `protobuf:"bytes,2,opt,name=softStack,proto3" json:"softStack,omitempty"`
|
||||
SlurmNum int32 `protobuf:"varint,3,opt,name=slurmNum,proto3" json:"slurmNum,omitempty"`
|
||||
InterfaceCount int32 `protobuf:"varint,4,opt,name=interfaceCount,proto3" json:"interfaceCount,omitempty"`
|
||||
RunningJobs int32 `protobuf:"varint,5,opt,name=runningJobs,proto3" json:"runningJobs,omitempty"`
|
||||
}
|
||||
|
||||
func (x *Domain) Reset() {
|
||||
*x = Domain{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_domain_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *Domain) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Domain) ProtoMessage() {}
|
||||
|
||||
func (x *Domain) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_domain_proto_msgTypes[0]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use Domain.ProtoReflect.Descriptor instead.
|
||||
func (*Domain) Descriptor() ([]byte, []int) {
|
||||
return file_domain_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *Domain) GetDomainName() string {
|
||||
if x != nil {
|
||||
return x.DomainName
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Domain) GetSoftStack() string {
|
||||
if x != nil {
|
||||
return x.SoftStack
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Domain) GetSlurmNum() int32 {
|
||||
if x != nil {
|
||||
return x.SlurmNum
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *Domain) GetInterfaceCount() int32 {
|
||||
if x != nil {
|
||||
return x.InterfaceCount
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *Domain) GetRunningJobs() int32 {
|
||||
if x != nil {
|
||||
return x.RunningJobs
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type DomainSummary struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
DomainCount int32 `protobuf:"varint,1,opt,name=domainCount,proto3" json:"domainCount,omitempty"`
|
||||
SoftStackCount int32 `protobuf:"varint,2,opt,name=softStackCount,proto3" json:"softStackCount,omitempty"`
|
||||
}
|
||||
|
||||
func (x *DomainSummary) Reset() {
|
||||
*x = DomainSummary{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_domain_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *DomainSummary) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*DomainSummary) ProtoMessage() {}
|
||||
|
||||
func (x *DomainSummary) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_domain_proto_msgTypes[1]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use DomainSummary.ProtoReflect.Descriptor instead.
|
||||
func (*DomainSummary) Descriptor() ([]byte, []int) {
|
||||
return file_domain_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *DomainSummary) GetDomainCount() int32 {
|
||||
if x != nil {
|
||||
return x.DomainCount
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *DomainSummary) GetSoftStackCount() int32 {
|
||||
if x != nil {
|
||||
return x.SoftStackCount
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type ListDomainRequest struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
}
|
||||
|
||||
func (x *ListDomainRequest) Reset() {
|
||||
*x = ListDomainRequest{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_domain_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *ListDomainRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ListDomainRequest) ProtoMessage() {}
|
||||
|
||||
func (x *ListDomainRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_domain_proto_msgTypes[2]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use ListDomainRequest.ProtoReflect.Descriptor instead.
|
||||
func (*ListDomainRequest) Descriptor() ([]byte, []int) {
|
||||
return file_domain_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
type ListDomainResponse struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Code int32 `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"`
|
||||
Msg string `protobuf:"bytes,2,opt,name=msg,proto3" json:"msg,omitempty"`
|
||||
Domains []*Domain `protobuf:"bytes,3,rep,name=domains,proto3" json:"domains,omitempty"`
|
||||
}
|
||||
|
||||
func (x *ListDomainResponse) Reset() {
|
||||
*x = ListDomainResponse{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_domain_proto_msgTypes[3]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *ListDomainResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ListDomainResponse) ProtoMessage() {}
|
||||
|
||||
func (x *ListDomainResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_domain_proto_msgTypes[3]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use ListDomainResponse.ProtoReflect.Descriptor instead.
|
||||
func (*ListDomainResponse) Descriptor() ([]byte, []int) {
|
||||
return file_domain_proto_rawDescGZIP(), []int{3}
|
||||
}
|
||||
|
||||
func (x *ListDomainResponse) GetCode() int32 {
|
||||
if x != nil {
|
||||
return x.Code
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *ListDomainResponse) GetMsg() string {
|
||||
if x != nil {
|
||||
return x.Msg
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *ListDomainResponse) GetDomains() []*Domain {
|
||||
if x != nil {
|
||||
return x.Domains
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type GetDomainSummaryRequest struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
}
|
||||
|
||||
func (x *GetDomainSummaryRequest) Reset() {
|
||||
*x = GetDomainSummaryRequest{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_domain_proto_msgTypes[4]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *GetDomainSummaryRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GetDomainSummaryRequest) ProtoMessage() {}
|
||||
|
||||
func (x *GetDomainSummaryRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_domain_proto_msgTypes[4]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use GetDomainSummaryRequest.ProtoReflect.Descriptor instead.
|
||||
func (*GetDomainSummaryRequest) Descriptor() ([]byte, []int) {
|
||||
return file_domain_proto_rawDescGZIP(), []int{4}
|
||||
}
|
||||
|
||||
type GetDomainSummaryResponse struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Code int32 `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"`
|
||||
Msg string `protobuf:"bytes,2,opt,name=msg,proto3" json:"msg,omitempty"`
|
||||
DomainSummary *DomainSummary `protobuf:"bytes,3,opt,name=domainSummary,proto3" json:"domainSummary,omitempty"`
|
||||
}
|
||||
|
||||
func (x *GetDomainSummaryResponse) Reset() {
|
||||
*x = GetDomainSummaryResponse{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_domain_proto_msgTypes[5]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *GetDomainSummaryResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GetDomainSummaryResponse) ProtoMessage() {}
|
||||
|
||||
func (x *GetDomainSummaryResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_domain_proto_msgTypes[5]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use GetDomainSummaryResponse.ProtoReflect.Descriptor instead.
|
||||
func (*GetDomainSummaryResponse) Descriptor() ([]byte, []int) {
|
||||
return file_domain_proto_rawDescGZIP(), []int{5}
|
||||
}
|
||||
|
||||
func (x *GetDomainSummaryResponse) GetCode() int32 {
|
||||
if x != nil {
|
||||
return x.Code
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *GetDomainSummaryResponse) GetMsg() string {
|
||||
if x != nil {
|
||||
return x.Msg
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *GetDomainSummaryResponse) GetDomainSummary() *DomainSummary {
|
||||
if x != nil {
|
||||
return x.DomainSummary
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var File_domain_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_domain_proto_rawDesc = []byte{
|
||||
0x0a, 0x0c, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x04,
|
||||
0x6c, 0x69, 0x73, 0x74, 0x22, 0xac, 0x01, 0x0a, 0x06, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x12,
|
||||
0x1e, 0x0a, 0x0a, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20,
|
||||
0x01, 0x28, 0x09, 0x52, 0x0a, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x4e, 0x61, 0x6d, 0x65, 0x12,
|
||||
0x1c, 0x0a, 0x09, 0x73, 0x6f, 0x66, 0x74, 0x53, 0x74, 0x61, 0x63, 0x6b, 0x18, 0x02, 0x20, 0x01,
|
||||
0x28, 0x09, 0x52, 0x09, 0x73, 0x6f, 0x66, 0x74, 0x53, 0x74, 0x61, 0x63, 0x6b, 0x12, 0x1a, 0x0a,
|
||||
0x08, 0x73, 0x6c, 0x75, 0x72, 0x6d, 0x4e, 0x75, 0x6d, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52,
|
||||
0x08, 0x73, 0x6c, 0x75, 0x72, 0x6d, 0x4e, 0x75, 0x6d, 0x12, 0x26, 0x0a, 0x0e, 0x69, 0x6e, 0x74,
|
||||
0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28,
|
||||
0x05, 0x52, 0x0e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x43, 0x6f, 0x75, 0x6e,
|
||||
0x74, 0x12, 0x20, 0x0a, 0x0b, 0x72, 0x75, 0x6e, 0x6e, 0x69, 0x6e, 0x67, 0x4a, 0x6f, 0x62, 0x73,
|
||||
0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, 0x72, 0x75, 0x6e, 0x6e, 0x69, 0x6e, 0x67, 0x4a,
|
||||
0x6f, 0x62, 0x73, 0x22, 0x59, 0x0a, 0x0d, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x75, 0x6d,
|
||||
0x6d, 0x61, 0x72, 0x79, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x43, 0x6f,
|
||||
0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, 0x64, 0x6f, 0x6d, 0x61, 0x69,
|
||||
0x6e, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x26, 0x0a, 0x0e, 0x73, 0x6f, 0x66, 0x74, 0x53, 0x74,
|
||||
0x61, 0x63, 0x6b, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0e,
|
||||
0x73, 0x6f, 0x66, 0x74, 0x53, 0x74, 0x61, 0x63, 0x6b, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x13,
|
||||
0x0a, 0x11, 0x6c, 0x69, 0x73, 0x74, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75,
|
||||
0x65, 0x73, 0x74, 0x22, 0x62, 0x0a, 0x12, 0x6c, 0x69, 0x73, 0x74, 0x44, 0x6f, 0x6d, 0x61, 0x69,
|
||||
0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64,
|
||||
0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x10, 0x0a,
|
||||
0x03, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6d, 0x73, 0x67, 0x12,
|
||||
0x26, 0x0a, 0x07, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b,
|
||||
0x32, 0x0c, 0x2e, 0x6c, 0x69, 0x73, 0x74, 0x2e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x52, 0x07,
|
||||
0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x73, 0x22, 0x19, 0x0a, 0x17, 0x67, 0x65, 0x74, 0x44, 0x6f,
|
||||
0x6d, 0x61, 0x69, 0x6e, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65,
|
||||
0x73, 0x74, 0x22, 0x7b, 0x0a, 0x18, 0x67, 0x65, 0x74, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53,
|
||||
0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12,
|
||||
0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x63, 0x6f,
|
||||
0x64, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
|
||||
0x03, 0x6d, 0x73, 0x67, 0x12, 0x39, 0x0a, 0x0d, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x75,
|
||||
0x6d, 0x6d, 0x61, 0x72, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x6c, 0x69,
|
||||
0x73, 0x74, 0x2e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79,
|
||||
0x52, 0x0d, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x32,
|
||||
0x9f, 0x01, 0x0a, 0x09, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x76, 0x63, 0x12, 0x3f, 0x0a,
|
||||
0x0a, 0x6c, 0x69, 0x73, 0x74, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x12, 0x17, 0x2e, 0x6c, 0x69,
|
||||
0x73, 0x74, 0x2e, 0x6c, 0x69, 0x73, 0x74, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x52, 0x65, 0x71,
|
||||
0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x6c, 0x69, 0x73, 0x74, 0x2e, 0x6c, 0x69, 0x73, 0x74,
|
||||
0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x51,
|
||||
0x0a, 0x10, 0x67, 0x65, 0x74, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x75, 0x6d, 0x6d, 0x61,
|
||||
0x72, 0x79, 0x12, 0x1d, 0x2e, 0x6c, 0x69, 0x73, 0x74, 0x2e, 0x67, 0x65, 0x74, 0x44, 0x6f, 0x6d,
|
||||
0x61, 0x69, 0x6e, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
|
||||
0x74, 0x1a, 0x1e, 0x2e, 0x6c, 0x69, 0x73, 0x74, 0x2e, 0x67, 0x65, 0x74, 0x44, 0x6f, 0x6d, 0x61,
|
||||
0x69, 0x6e, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
|
||||
0x65, 0x42, 0x0a, 0x5a, 0x08, 0x2e, 0x2f, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x62, 0x06, 0x70,
|
||||
0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
file_domain_proto_rawDescOnce sync.Once
|
||||
file_domain_proto_rawDescData = file_domain_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_domain_proto_rawDescGZIP() []byte {
|
||||
file_domain_proto_rawDescOnce.Do(func() {
|
||||
file_domain_proto_rawDescData = protoimpl.X.CompressGZIP(file_domain_proto_rawDescData)
|
||||
})
|
||||
return file_domain_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_domain_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
|
||||
var file_domain_proto_goTypes = []interface{}{
|
||||
(*Domain)(nil), // 0: list.Domain
|
||||
(*DomainSummary)(nil), // 1: list.DomainSummary
|
||||
(*ListDomainRequest)(nil), // 2: list.listDomainRequest
|
||||
(*ListDomainResponse)(nil), // 3: list.listDomainResponse
|
||||
(*GetDomainSummaryRequest)(nil), // 4: list.getDomainSummaryRequest
|
||||
(*GetDomainSummaryResponse)(nil), // 5: list.getDomainSummaryResponse
|
||||
}
|
||||
var file_domain_proto_depIdxs = []int32{
|
||||
0, // 0: list.listDomainResponse.domains:type_name -> list.Domain
|
||||
1, // 1: list.getDomainSummaryResponse.domainSummary:type_name -> list.DomainSummary
|
||||
2, // 2: list.domainSvc.listDomain:input_type -> list.listDomainRequest
|
||||
4, // 3: list.domainSvc.getDomainSummary:input_type -> list.getDomainSummaryRequest
|
||||
3, // 4: list.domainSvc.listDomain:output_type -> list.listDomainResponse
|
||||
5, // 5: list.domainSvc.getDomainSummary:output_type -> list.getDomainSummaryResponse
|
||||
4, // [4:6] is the sub-list for method output_type
|
||||
2, // [2:4] is the sub-list for method input_type
|
||||
2, // [2:2] is the sub-list for extension type_name
|
||||
2, // [2:2] is the sub-list for extension extendee
|
||||
0, // [0:2] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_domain_proto_init() }
|
||||
func file_domain_proto_init() {
|
||||
if File_domain_proto != nil {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_domain_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*Domain); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_domain_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*DomainSummary); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_domain_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*ListDomainRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_domain_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*ListDomainResponse); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_domain_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*GetDomainSummaryRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_domain_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*GetDomainSummaryResponse); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_domain_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 6,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
GoTypes: file_domain_proto_goTypes,
|
||||
DependencyIndexes: file_domain_proto_depIdxs,
|
||||
MessageInfos: file_domain_proto_msgTypes,
|
||||
}.Build()
|
||||
File_domain_proto = out.File
|
||||
file_domain_proto_rawDesc = nil
|
||||
file_domain_proto_goTypes = nil
|
||||
file_domain_proto_depIdxs = nil
|
||||
}
|
|
@ -0,0 +1,141 @@
|
|||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.2.0
|
||||
// - protoc v3.19.4
|
||||
// source: domain.proto
|
||||
|
||||
package domain
|
||||
|
||||
import (
|
||||
context "context"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
// Requires gRPC-Go v1.32.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion7
|
||||
|
||||
// DomainSvcClient is the client API for DomainSvc service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
type DomainSvcClient interface {
|
||||
ListDomain(ctx context.Context, in *ListDomainRequest, opts ...grpc.CallOption) (*ListDomainResponse, error)
|
||||
GetDomainSummary(ctx context.Context, in *GetDomainSummaryRequest, opts ...grpc.CallOption) (*GetDomainSummaryResponse, error)
|
||||
}
|
||||
|
||||
type domainSvcClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewDomainSvcClient(cc grpc.ClientConnInterface) DomainSvcClient {
|
||||
return &domainSvcClient{cc}
|
||||
}
|
||||
|
||||
func (c *domainSvcClient) ListDomain(ctx context.Context, in *ListDomainRequest, opts ...grpc.CallOption) (*ListDomainResponse, error) {
|
||||
out := new(ListDomainResponse)
|
||||
err := c.cc.Invoke(ctx, "/list.domainSvc/listDomain", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *domainSvcClient) GetDomainSummary(ctx context.Context, in *GetDomainSummaryRequest, opts ...grpc.CallOption) (*GetDomainSummaryResponse, error) {
|
||||
out := new(GetDomainSummaryResponse)
|
||||
err := c.cc.Invoke(ctx, "/list.domainSvc/getDomainSummary", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// DomainSvcServer is the server API for DomainSvc service.
|
||||
// All implementations must embed UnimplementedDomainSvcServer
|
||||
// for forward compatibility
|
||||
type DomainSvcServer interface {
|
||||
ListDomain(context.Context, *ListDomainRequest) (*ListDomainResponse, error)
|
||||
GetDomainSummary(context.Context, *GetDomainSummaryRequest) (*GetDomainSummaryResponse, error)
|
||||
mustEmbedUnimplementedDomainSvcServer()
|
||||
}
|
||||
|
||||
// UnimplementedDomainSvcServer must be embedded to have forward compatible implementations.
|
||||
type UnimplementedDomainSvcServer struct {
|
||||
}
|
||||
|
||||
func (UnimplementedDomainSvcServer) ListDomain(context.Context, *ListDomainRequest) (*ListDomainResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method ListDomain not implemented")
|
||||
}
|
||||
func (UnimplementedDomainSvcServer) GetDomainSummary(context.Context, *GetDomainSummaryRequest) (*GetDomainSummaryResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetDomainSummary not implemented")
|
||||
}
|
||||
func (UnimplementedDomainSvcServer) mustEmbedUnimplementedDomainSvcServer() {}
|
||||
|
||||
// UnsafeDomainSvcServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to DomainSvcServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeDomainSvcServer interface {
|
||||
mustEmbedUnimplementedDomainSvcServer()
|
||||
}
|
||||
|
||||
func RegisterDomainSvcServer(s grpc.ServiceRegistrar, srv DomainSvcServer) {
|
||||
s.RegisterService(&DomainSvc_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _DomainSvc_ListDomain_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(ListDomainRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(DomainSvcServer).ListDomain(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/list.domainSvc/listDomain",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(DomainSvcServer).ListDomain(ctx, req.(*ListDomainRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _DomainSvc_GetDomainSummary_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetDomainSummaryRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(DomainSvcServer).GetDomainSummary(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/list.domainSvc/getDomainSummary",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(DomainSvcServer).GetDomainSummary(ctx, req.(*GetDomainSummaryRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// DomainSvc_ServiceDesc is the grpc.ServiceDesc for DomainSvc service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var DomainSvc_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "list.domainSvc",
|
||||
HandlerType: (*DomainSvcServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "listDomain",
|
||||
Handler: _DomainSvc_ListDomain_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "getDomainSummary",
|
||||
Handler: _DomainSvc_GetDomainSummary_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "domain.proto",
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
// Code generated by goctl. DO NOT EDIT.
|
||||
// Source: domain.proto
|
||||
|
||||
package domainsvc
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"PCM/app/slurm/slurmCore/rpc/domain/domain"
|
||||
|
||||
"github.com/zeromicro/go-zero/zrpc"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
type (
|
||||
Domain = domain.Domain
|
||||
DomainSummary = domain.DomainSummary
|
||||
GetDomainSummaryRequest = domain.GetDomainSummaryRequest
|
||||
GetDomainSummaryResponse = domain.GetDomainSummaryResponse
|
||||
ListDomainRequest = domain.ListDomainRequest
|
||||
ListDomainResponse = domain.ListDomainResponse
|
||||
|
||||
DomainSvc interface {
|
||||
ListDomain(ctx context.Context, in *ListDomainRequest, opts ...grpc.CallOption) (*ListDomainResponse, error)
|
||||
GetDomainSummary(ctx context.Context, in *GetDomainSummaryRequest, opts ...grpc.CallOption) (*GetDomainSummaryResponse, error)
|
||||
}
|
||||
|
||||
defaultDomainSvc struct {
|
||||
cli zrpc.Client
|
||||
}
|
||||
)
|
||||
|
||||
func NewDomainSvc(cli zrpc.Client) DomainSvc {
|
||||
return &defaultDomainSvc{
|
||||
cli: cli,
|
||||
}
|
||||
}
|
||||
|
||||
func (m *defaultDomainSvc) ListDomain(ctx context.Context, in *ListDomainRequest, opts ...grpc.CallOption) (*ListDomainResponse, error) {
|
||||
client := domain.NewDomainSvcClient(m.cli.Conn())
|
||||
return client.ListDomain(ctx, in, opts...)
|
||||
}
|
||||
|
||||
func (m *defaultDomainSvc) GetDomainSummary(ctx context.Context, in *GetDomainSummaryRequest, opts ...grpc.CallOption) (*GetDomainSummaryResponse, error) {
|
||||
client := domain.NewDomainSvcClient(m.cli.Conn())
|
||||
return client.GetDomainSummary(ctx, in, opts...)
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
Name: domain.rpc
|
||||
ListenOn: 0.0.0.0:8080
|
||||
Etcd:
|
||||
Hosts:
|
||||
- 127.0.0.1:2379
|
||||
Key: domain.rpc
|
|
@ -0,0 +1,7 @@
|
|||
package config
|
||||
|
||||
import "github.com/zeromicro/go-zero/zrpc"
|
||||
|
||||
type Config struct {
|
||||
zrpc.RpcServerConf
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"PCM/app/slurm/slurmCore/rpc/domain/domain"
|
||||
"PCM/app/slurm/slurmCore/rpc/domain/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetDomainSummaryLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewGetDomainSummaryLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetDomainSummaryLogic {
|
||||
return &GetDomainSummaryLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetDomainSummaryLogic) GetDomainSummary(in *domain.GetDomainSummaryRequest) (*domain.GetDomainSummaryResponse, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &domain.GetDomainSummaryResponse{}, nil
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"PCM/app/slurm/slurmCore/rpc/domain/domain"
|
||||
"PCM/app/slurm/slurmCore/rpc/domain/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type ListDomainLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewListDomainLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListDomainLogic {
|
||||
return &ListDomainLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
func (l *ListDomainLogic) ListDomain(in *domain.ListDomainRequest) (*domain.ListDomainResponse, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
//_, err := l.svcCtx.Insert(model.Book{
|
||||
// Book: in.Book,
|
||||
// Price: in.Price,
|
||||
//})
|
||||
//if err != nil {
|
||||
// return nil, err
|
||||
//}
|
||||
//
|
||||
//return &add.AddResp{
|
||||
// Ok: true,
|
||||
//}, nil
|
||||
return &domain.ListDomainResponse{}, nil
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
// Code generated by goctl. DO NOT EDIT.
|
||||
// Source: domain.proto
|
||||
|
||||
package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"PCM/app/slurm/slurmCore/rpc/domain/domain"
|
||||
"PCM/app/slurm/slurmCore/rpc/domain/internal/logic"
|
||||
"PCM/app/slurm/slurmCore/rpc/domain/internal/svc"
|
||||
)
|
||||
|
||||
type DomainSvcServer struct {
|
||||
svcCtx *svc.ServiceContext
|
||||
domain.UnimplementedDomainSvcServer
|
||||
}
|
||||
|
||||
func NewDomainSvcServer(svcCtx *svc.ServiceContext) *DomainSvcServer {
|
||||
return &DomainSvcServer{
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *DomainSvcServer) ListDomain(ctx context.Context, in *domain.ListDomainRequest) (*domain.ListDomainResponse, error) {
|
||||
l := logic.NewListDomainLogic(ctx, s.svcCtx)
|
||||
return l.ListDomain(in)
|
||||
}
|
||||
|
||||
func (s *DomainSvcServer) GetDomainSummary(ctx context.Context, in *domain.GetDomainSummaryRequest) (*domain.GetDomainSummaryResponse, error) {
|
||||
l := logic.NewGetDomainSummaryLogic(ctx, s.svcCtx)
|
||||
return l.GetDomainSummary(in)
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package svc
|
||||
|
||||
import "PCM/app/slurm/slurmCore/rpc/domain/internal/config"
|
||||
|
||||
type ServiceContext struct {
|
||||
Config config.Config
|
||||
}
|
||||
|
||||
func NewServiceContext(c config.Config) *ServiceContext {
|
||||
return &ServiceContext{
|
||||
Config: c,
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
Name: slurmshuguang.rpc
|
||||
ListenOn: 0.0.0.0:2001
|
||||
|
||||
ClusterUrl: "https://api01.hpccube.com:65106/hpc/openapi/v2/cluster"
|
||||
TokenUrl: "https://api01.hpccube.com:65102/ac/openapi/v2/tokens"
|
||||
StateUrl: "https://api01.hpccube.com:65102/ac/openapi/v2/tokens/state"
|
||||
User: "zhijiang"
|
||||
Password: "111111a"
|
||||
OrgId: "313ae32df03bc116255e6808949fcf57"
|
||||
Layout: "2006-01-02 15:04:05"
|
|
@ -0,0 +1,8 @@
|
|||
package config
|
||||
|
||||
import "github.com/zeromicro/go-zero/zrpc"
|
||||
|
||||
type Config struct {
|
||||
zrpc.RpcServerConf
|
||||
ShuguangConf
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package config
|
||||
|
||||
// ShuguangConf Shuguang 相关URL配置
|
||||
type ShuguangConf struct {
|
||||
ClusterUrl string `json:"ClusterUrl"`
|
||||
TokenUrl string `json:"TokenUrl"`
|
||||
StateUrl string `json:"StateUrl"`
|
||||
User string `json:"User"`
|
||||
Password string `json:"Password"`
|
||||
OrgId string `json:"OrgId"`
|
||||
Layout string `json:"Layout"`
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"PCM/app/slurm/slurmShuguang/rpc/internal/svc"
|
||||
"PCM/app/slurm/slurmShuguang/rpc/slurmShuguang"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type AddAccountLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewAddAccountLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddAccountLogic {
|
||||
return &AddAccountLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// AddAccount add account
|
||||
func (l *AddAccountLogic) AddAccount(in *slurmShuguang.AddAccountReq) (*slurmShuguang.AddAccountResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &slurmShuguang.AddAccountResp{}, nil
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"PCM/app/slurm/slurmShuguang/rpc/internal/svc"
|
||||
"PCM/app/slurm/slurmShuguang/rpc/slurmShuguang"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type AddClusterLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewAddClusterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddClusterLogic {
|
||||
return &AddClusterLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// AddCluster add new user
|
||||
func (l *AddClusterLogic) AddCluster(in *slurmShuguang.AddClusterReq) (*slurmShuguang.AddClusterResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &slurmShuguang.AddClusterResp{}, nil
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"PCM/app/slurm/slurmShuguang/rpc/internal/svc"
|
||||
"PCM/app/slurm/slurmShuguang/rpc/slurmShuguang"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type AddQosLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewAddQosLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddQosLogic {
|
||||
return &AddQosLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// AddQos add qos to slurmdb
|
||||
func (l *AddQosLogic) AddQos(in *slurmShuguang.AddQosReq) (*slurmShuguang.AddQosResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &slurmShuguang.AddQosResp{}, nil
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"PCM/app/slurm/slurmShuguang/rpc/internal/svc"
|
||||
"PCM/app/slurm/slurmShuguang/rpc/slurmShuguang"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type AddUserLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewAddUserLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddUserLogic {
|
||||
return &AddUserLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// AddUser add new user
|
||||
func (l *AddUserLogic) AddUser(in *slurmShuguang.AddUserReq) (*slurmShuguang.AddUserResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &slurmShuguang.AddUserResp{}, nil
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"PCM/app/slurm/slurmShuguang/rpc/internal/svc"
|
||||
"PCM/app/slurm/slurmShuguang/rpc/slurmShuguang"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type DeleteAccountLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewDeleteAccountLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteAccountLogic {
|
||||
return &DeleteAccountLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// DeleteAccount delete account
|
||||
func (l *DeleteAccountLogic) DeleteAccount(in *slurmShuguang.DeleteAccountReq) (*slurmShuguang.DeleteAccountResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &slurmShuguang.DeleteAccountResp{}, nil
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"PCM/app/slurm/slurmShuguang/rpc/internal/svc"
|
||||
"PCM/app/slurm/slurmShuguang/rpc/slurmShuguang"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type DeleteClusterLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewDeleteClusterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteClusterLogic {
|
||||
return &DeleteClusterLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// DeleteCluster delete specific user
|
||||
func (l *DeleteClusterLogic) DeleteCluster(in *slurmShuguang.DeleteClusterReq) (*slurmShuguang.DeleteClusterResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &slurmShuguang.DeleteClusterResp{}, nil
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"PCM/app/slurm/slurmShuguang/rpc/internal/svc"
|
||||
"PCM/app/slurm/slurmShuguang/rpc/slurmShuguang"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type DeleteJobLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewDeleteJobLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteJobLogic {
|
||||
return &DeleteJobLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// DeleteJob delete job from slurm
|
||||
func (l *DeleteJobLogic) DeleteJob(in *slurmShuguang.DeleteJobReq) (*slurmShuguang.DeleteJobResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &slurmShuguang.DeleteJobResp{}, nil
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"PCM/app/slurm/slurmShuguang/rpc/internal/svc"
|
||||
"PCM/app/slurm/slurmShuguang/rpc/slurmShuguang"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type DeleteQosLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewDeleteQosLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteQosLogic {
|
||||
return &DeleteQosLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// DeleteQos delete qos from slurmdb
|
||||
func (l *DeleteQosLogic) DeleteQos(in *slurmShuguang.DeleteQosReq) (*slurmShuguang.DeleteQosResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &slurmShuguang.DeleteQosResp{}, nil
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"PCM/app/slurm/slurmShuguang/rpc/internal/svc"
|
||||
"PCM/app/slurm/slurmShuguang/rpc/slurmShuguang"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type DeleteUserLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewDeleteUserLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteUserLogic {
|
||||
return &DeleteUserLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// DeleteUser delete specific user
|
||||
func (l *DeleteUserLogic) DeleteUser(in *slurmShuguang.DeleteUserReq) (*slurmShuguang.DeleteUserResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &slurmShuguang.DeleteUserResp{}, nil
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"PCM/app/slurm/slurmShuguang/rpc/internal/svc"
|
||||
"PCM/app/slurm/slurmShuguang/rpc/slurmShuguang"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetAccountLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewGetAccountLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetAccountLogic {
|
||||
return &GetAccountLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// GetAccount get specific account info from slurmdb
|
||||
func (l *GetAccountLogic) GetAccount(in *slurmShuguang.GetAccountReq) (*slurmShuguang.GetAccountResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &slurmShuguang.GetAccountResp{}, nil
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"PCM/app/slurm/slurmShuguang/rpc/internal/svc"
|
||||
"PCM/app/slurm/slurmShuguang/rpc/slurmShuguang"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetAssociationLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewGetAssociationLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetAssociationLogic {
|
||||
return &GetAssociationLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// GetAssociation get specific association info from slurmdb
|
||||
func (l *GetAssociationLogic) GetAssociation(in *slurmShuguang.GetAssociationReq) (*slurmShuguang.GetAssociationResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &slurmShuguang.GetAssociationResp{}, nil
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"PCM/app/slurm/slurmShuguang/rpc/internal/svc"
|
||||
"PCM/app/slurm/slurmShuguang/rpc/slurmShuguang"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetClusterLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewGetClusterLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetClusterLogic {
|
||||
return &GetClusterLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// GetCluster get specific user info from slurmdb
|
||||
func (l *GetClusterLogic) GetCluster(in *slurmShuguang.GetClusterReq) (*slurmShuguang.GetClusterResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &slurmShuguang.GetClusterResp{}, nil
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"PCM/app/slurm/slurmShuguang/rpc/internal/svc"
|
||||
"PCM/app/slurm/slurmShuguang/rpc/slurmShuguang"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetDbJobLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewGetDbJobLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetDbJobLogic {
|
||||
return &GetDbJobLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// GetDbJob get job by id from slurmdb
|
||||
func (l *GetDbJobLogic) GetDbJob(in *slurmShuguang.GetDbJobReq) (*slurmShuguang.GetDbJobResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &slurmShuguang.GetDbJobResp{}, nil
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"PCM/app/slurm/slurmShuguang/rpc/internal/svc"
|
||||
"PCM/app/slurm/slurmShuguang/rpc/slurmShuguang"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetDiagLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewGetDiagLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetDiagLogic {
|
||||
return &GetDiagLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// GetDiag list all diag from slurm
|
||||
func (l *GetDiagLogic) GetDiag(in *slurmShuguang.DiagReq) (*slurmShuguang.DiagResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &slurmShuguang.DiagResp{}, nil
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"PCM/app/slurm/slurmShuguang/rpc/internal/svc"
|
||||
"PCM/app/slurm/slurmShuguang/rpc/slurmShuguang"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetJobLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewGetJobLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetJobLogic {
|
||||
return &GetJobLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// GetJob get job by id from slurm
|
||||
func (l *GetJobLogic) GetJob(in *slurmShuguang.GetJobReq) (*slurmShuguang.GetJobResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &slurmShuguang.GetJobResp{}, nil
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"PCM/app/slurm/slurmShuguang/rpc/internal/svc"
|
||||
"PCM/app/slurm/slurmShuguang/rpc/slurmShuguang"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetNodeLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewGetNodeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetNodeLogic {
|
||||
return &GetNodeLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// GetNode get specific Node info from slurm
|
||||
func (l *GetNodeLogic) GetNode(in *slurmShuguang.GetNodeReq) (*slurmShuguang.GetNodeResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &slurmShuguang.GetNodeResp{}, nil
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"PCM/app/slurm/slurmShuguang/rpc/internal/svc"
|
||||
"PCM/app/slurm/slurmShuguang/rpc/slurmShuguang"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetPartitionLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewGetPartitionLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetPartitionLogic {
|
||||
return &GetPartitionLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// GetPartition get specific Partition info from slurm
|
||||
func (l *GetPartitionLogic) GetPartition(in *slurmShuguang.GetPartitionReq) (*slurmShuguang.GetPartitionResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &slurmShuguang.GetPartitionResp{}, nil
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"PCM/app/slurm/slurmShuguang/rpc/internal/svc"
|
||||
"PCM/app/slurm/slurmShuguang/rpc/slurmShuguang"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetQosLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewGetQosLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetQosLogic {
|
||||
return &GetQosLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// GetQos get qos by name from slurmdb
|
||||
func (l *GetQosLogic) GetQos(in *slurmShuguang.GetQosReq) (*slurmShuguang.GetQosResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &slurmShuguang.GetQosResp{}, nil
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"PCM/app/slurm/slurmShuguang/rpc/internal/svc"
|
||||
"PCM/app/slurm/slurmShuguang/rpc/slurmShuguang"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetReservationLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewGetReservationLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetReservationLogic {
|
||||
return &GetReservationLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// GetReservation get specific Reservation info from slurm
|
||||
func (l *GetReservationLogic) GetReservation(in *slurmShuguang.GetReservationReq) (*slurmShuguang.GetReservationResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &slurmShuguang.GetReservationResp{}, nil
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"PCM/app/slurm/slurmShuguang/rpc/internal/svc"
|
||||
"PCM/app/slurm/slurmShuguang/rpc/slurmShuguang"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetUserLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewGetUserLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetUserLogic {
|
||||
return &GetUserLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// GetUser get specific user info from slurmdb
|
||||
func (l *GetUserLogic) GetUser(in *slurmShuguang.GetUserReq) (*slurmShuguang.GetUserResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &slurmShuguang.GetUserResp{}, nil
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"PCM/app/slurm/slurmShuguang/rpc/internal/svc"
|
||||
"PCM/app/slurm/slurmShuguang/rpc/slurmShuguang"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetWckeyLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewGetWckeyLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetWckeyLogic {
|
||||
return &GetWckeyLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// GetWckey get specific wckey info from slurmdb
|
||||
func (l *GetWckeyLogic) GetWckey(in *slurmShuguang.GetWckeyReq) (*slurmShuguang.GetWckeyResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &slurmShuguang.GetWckeyResp{}, nil
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"PCM/app/slurm/slurmShuguang/rpc/internal/svc"
|
||||
"PCM/app/slurm/slurmShuguang/rpc/slurmShuguang"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type ListAccountsLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewListAccountsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListAccountsLogic {
|
||||
return &ListAccountsLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// ListAccounts list all accounts info from slurmdb
|
||||
func (l *ListAccountsLogic) ListAccounts(in *slurmShuguang.ListAccountsReq) (*slurmShuguang.ListAccountsResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &slurmShuguang.ListAccountsResp{}, nil
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"PCM/app/slurm/slurmShuguang/rpc/internal/svc"
|
||||
"PCM/app/slurm/slurmShuguang/rpc/slurmShuguang"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type ListAssociationsLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewListAssociationsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListAssociationsLogic {
|
||||
return &ListAssociationsLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// ListAssociations list all associations from slurmdb
|
||||
func (l *ListAssociationsLogic) ListAssociations(in *slurmShuguang.ListAssociationsReq) (*slurmShuguang.ListAssociationsResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &slurmShuguang.ListAssociationsResp{}, nil
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"PCM/app/slurm/slurmShuguang/rpc/internal/svc"
|
||||
"PCM/app/slurm/slurmShuguang/rpc/slurmShuguang"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type ListClustersLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewListClustersLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListClustersLogic {
|
||||
return &ListClustersLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// ListClusters list all Cluster from slurmdb
|
||||
func (l *ListClustersLogic) ListClusters(in *slurmShuguang.ListClustersReq) (*slurmShuguang.ListClustersResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &slurmShuguang.ListClustersResp{}, nil
|
||||
}
|
|
@ -0,0 +1,198 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"PCM/app/slurm/slurmShuguang/rpc/internal/util"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"PCM/app/slurm/slurmShuguang/rpc/internal/svc"
|
||||
"PCM/app/slurm/slurmShuguang/rpc/slurmShuguang"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
var (
|
||||
StatesMapShuguang = map[string]uint32{
|
||||
"statR": 0,
|
||||
"statQ": 1,
|
||||
"statH": 2,
|
||||
"statS": 3,
|
||||
"statE": 4,
|
||||
"statC": 5,
|
||||
"statW": 6,
|
||||
"statX": 7,
|
||||
}
|
||||
Gtoken = util.GetToken()
|
||||
ClusterId = util.GetClusterId()
|
||||
)
|
||||
|
||||
type cluster struct {
|
||||
Msg string `json:"msg"`
|
||||
Code string `json:"code"`
|
||||
Data []clusterInfo `json:"data"`
|
||||
}
|
||||
|
||||
type clusterInfo struct {
|
||||
JobManagerType string `json:"JobManagerType"`
|
||||
JobManagerAddr string `json:"JobManagerAddr"`
|
||||
Id int `json:"id"`
|
||||
Text string `json:"text"`
|
||||
JobManagerPort string `json:"JobManagerPort"`
|
||||
}
|
||||
|
||||
type stateToken struct {
|
||||
Msg string `json:"msg"`
|
||||
Code string `json:"code"`
|
||||
Data string `json:"data"`
|
||||
}
|
||||
|
||||
type resultToken struct {
|
||||
Msg string `json:"msg"`
|
||||
Code string `json:"code"`
|
||||
Data []dataToken `json:"data"`
|
||||
}
|
||||
|
||||
type dataToken struct {
|
||||
ClusterName string `json:"clusterName"`
|
||||
ClusterId string `json:"clusterId"`
|
||||
Token string `json:"token"`
|
||||
}
|
||||
|
||||
type resultJobHistory struct {
|
||||
Msg string `json:"msg"`
|
||||
Code string `json:"code"`
|
||||
Data dataList `json:"data"`
|
||||
}
|
||||
|
||||
type dataList struct {
|
||||
Total int `json:"total"`
|
||||
List []dataJobHistory `json:"list"`
|
||||
}
|
||||
|
||||
type dataJobHistory struct {
|
||||
AcctTime string `json:"acctTime"`
|
||||
AppType string `json:"appType"`
|
||||
JobEndTime string `json:"jobEndTime"`
|
||||
JobExecHost string `json:"jobExecHost"`
|
||||
JobExitStatus int `json:"jobExitStatus"`
|
||||
JobId string `json:"jobId"`
|
||||
JobName string `json:"jobName"`
|
||||
JobQueueTime string `json:"jobQueueTime"`
|
||||
JobStartTime string `json:"jobStartTime"`
|
||||
JobState string `json:"jobState"`
|
||||
JobWalltimeUsed string `json:"jobWalltimeUsed"`
|
||||
JobmanagerId int `json:"jobmanagerId"`
|
||||
Nodect int `json:"nodect"`
|
||||
Queue string `json:"queue"`
|
||||
UserName string `json:"userName"`
|
||||
Workdir string `json:"workdir"`
|
||||
}
|
||||
|
||||
type ListDbJobsLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewListDbJobsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListDbJobsLogic {
|
||||
return &ListDbJobsLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// ListDbJobs list all jobs from slurmdb
|
||||
func (l *ListDbJobsLogic) ListDbJobs(in *slurmShuguang.ListDbJobsReq) (*slurmShuguang.ListDbJobsResp, error) {
|
||||
|
||||
//tokenUrl := l.svcCtx.Config.TokenUrl
|
||||
//stateUrl = l.svcCtx.Config.StateUrl
|
||||
//clusterUrl = l.svcCtx.Config.ClusterUrl
|
||||
var resp *slurmShuguang.ListDbJobsResp
|
||||
jobHistoryUrl := "hpc/openapi/v2/historyjobs?"
|
||||
|
||||
c := http.Client{Timeout: time.Duration(3) * time.Second}
|
||||
|
||||
params := url.Values{}
|
||||
params.Add("strClusterNameList", strconv.FormatInt(int64(ClusterId), 10))
|
||||
params.Add("startTime", "2022-11-23 01:01:01")
|
||||
currentTime := time.Now()
|
||||
params.Add("endTime", currentTime.Format("2006-01-02 15:04:05"))
|
||||
params.Add("timeType", "CUSTOM")
|
||||
params.Add("start", strconv.FormatInt(0, 10))
|
||||
params.Add("limit", strconv.FormatInt(25, 10))
|
||||
params.Add("isQueryByQueueTime", "false")
|
||||
params.Add("strUser", l.svcCtx.Config.ShuguangConf.User)
|
||||
|
||||
reqUrl, err := http.NewRequest("GET", "https://api01.hpccube.com:65106/"+jobHistoryUrl+params.Encode(), nil)
|
||||
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
var token string
|
||||
if util.GetTokenState(Gtoken) {
|
||||
token = Gtoken
|
||||
} else {
|
||||
token = util.GetToken()
|
||||
Gtoken = token
|
||||
}
|
||||
|
||||
reqUrl.Header.Add("token", token)
|
||||
|
||||
respUrl, err := c.Do(reqUrl)
|
||||
|
||||
var res resultJobHistory
|
||||
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
body, err := ioutil.ReadAll(respUrl.Body)
|
||||
|
||||
err = json.Unmarshal(body, &res)
|
||||
if err != nil {
|
||||
log.Panicln(err)
|
||||
}
|
||||
|
||||
defer respUrl.Body.Close()
|
||||
|
||||
var historyJobs []*slurmShuguang.JobInfoDbGet
|
||||
|
||||
for _, e := range res.Data.List {
|
||||
var job slurmShuguang.JobInfoDbGet
|
||||
jobId, err := strconv.Atoi(e.JobId)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
job.Jobid = uint32(jobId)
|
||||
job.Jobname = e.JobName
|
||||
job.WorkDir = e.Workdir
|
||||
|
||||
job.State = StatesMapShuguang[e.JobState]
|
||||
startTime, err := time.Parse(l.svcCtx.Config.ShuguangConf.Layout, e.JobStartTime)
|
||||
if err == nil {
|
||||
job.Start = startTime.Unix()
|
||||
}
|
||||
endTime, err := time.Parse(l.svcCtx.Config.ShuguangConf.Layout, e.JobEndTime)
|
||||
if err == nil {
|
||||
job.End = endTime.Unix()
|
||||
}
|
||||
historyJobs = append(historyJobs, &job)
|
||||
}
|
||||
code, _ := strconv.ParseUint(res.Code, 10, 32)
|
||||
if code == 0 {
|
||||
resp.Code = uint32(200)
|
||||
}
|
||||
resp.Msg = res.Msg
|
||||
resp.RecordCount = uint32(res.Data.Total)
|
||||
resp.JobInfoDbs = historyJobs
|
||||
|
||||
return resp, nil
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"PCM/app/slurm/slurmShuguang/rpc/internal/svc"
|
||||
"PCM/app/slurm/slurmShuguang/rpc/slurmShuguang"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type ListJobsLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewListJobsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListJobsLogic {
|
||||
return &ListJobsLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// ListJobs list all jobs from slurm
|
||||
func (l *ListJobsLogic) ListJobs(in *slurmShuguang.ListJobsReq) (*slurmShuguang.ListJobsResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &slurmShuguang.ListJobsResp{}, nil
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"PCM/app/slurm/slurmShuguang/rpc/internal/svc"
|
||||
"PCM/app/slurm/slurmShuguang/rpc/slurmShuguang"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type ListNodesLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewListNodesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListNodesLogic {
|
||||
return &ListNodesLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// ListNodes list all Node from slurm
|
||||
func (l *ListNodesLogic) ListNodes(in *slurmShuguang.ListNodesReq) (*slurmShuguang.ListNodesResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &slurmShuguang.ListNodesResp{}, nil
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"PCM/app/slurm/slurmShuguang/rpc/internal/svc"
|
||||
"PCM/app/slurm/slurmShuguang/rpc/slurmShuguang"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type ListPartitionsLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewListPartitionsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListPartitionsLogic {
|
||||
return &ListPartitionsLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// ListPartitions list all Partition from slurm
|
||||
func (l *ListPartitionsLogic) ListPartitions(in *slurmShuguang.ListPartitionsReq) (*slurmShuguang.ListPartitionsResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &slurmShuguang.ListPartitionsResp{}, nil
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"PCM/app/slurm/slurmShuguang/rpc/internal/svc"
|
||||
"PCM/app/slurm/slurmShuguang/rpc/slurmShuguang"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type ListReservationsLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewListReservationsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListReservationsLogic {
|
||||
return &ListReservationsLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// ListReservations list all Reservation from slurm
|
||||
func (l *ListReservationsLogic) ListReservations(in *slurmShuguang.ListReservationsReq) (*slurmShuguang.ListReservationsResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &slurmShuguang.ListReservationsResp{}, nil
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"PCM/app/slurm/slurmShuguang/rpc/internal/svc"
|
||||
"PCM/app/slurm/slurmShuguang/rpc/slurmShuguang"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type ListUsersLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewListUsersLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListUsersLogic {
|
||||
return &ListUsersLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// ListUsers list all users from slurmdb
|
||||
func (l *ListUsersLogic) ListUsers(in *slurmShuguang.ListUsersReq) (*slurmShuguang.ListUsersResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &slurmShuguang.ListUsersResp{}, nil
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"PCM/app/slurm/slurmShuguang/rpc/internal/svc"
|
||||
"PCM/app/slurm/slurmShuguang/rpc/slurmShuguang"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type ListWckeysLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewListWckeysLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListWckeysLogic {
|
||||
return &ListWckeysLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// ListWckeys list all wckeys info from slurmdb
|
||||
func (l *ListWckeysLogic) ListWckeys(in *slurmShuguang.ListWckeysReq) (*slurmShuguang.ListWckeysResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &slurmShuguang.ListWckeysResp{}, nil
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"PCM/app/slurm/slurmShuguang/rpc/internal/svc"
|
||||
"PCM/app/slurm/slurmShuguang/rpc/slurmShuguang"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type SubmitJobLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewSubmitJobLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SubmitJobLogic {
|
||||
return &SubmitJobLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// SubmitJob submit job to slurm
|
||||
func (l *SubmitJobLogic) SubmitJob(in *slurmShuguang.SubmitJobReq) (*slurmShuguang.SubmitJobResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &slurmShuguang.SubmitJobResp{}, nil
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"PCM/app/slurm/slurmShuguang/rpc/internal/svc"
|
||||
"PCM/app/slurm/slurmShuguang/rpc/slurmShuguang"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type UpdateJobLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewUpdateJobLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateJobLogic {
|
||||
return &UpdateJobLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// UpdateJob update job from slurm
|
||||
func (l *UpdateJobLogic) UpdateJob(in *slurmShuguang.UpdateJobReq) (*slurmShuguang.UpdateJobResp, error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return &slurmShuguang.UpdateJobResp{}, nil
|
||||
}
|
|
@ -0,0 +1,221 @@
|
|||
// Code generated by goctl. DO NOT EDIT.
|
||||
// Source: slurmShuguang.proto
|
||||
|
||||
package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"PCM/app/slurm/slurmShuguang/rpc/internal/logic"
|
||||
"PCM/app/slurm/slurmShuguang/rpc/internal/svc"
|
||||
"PCM/app/slurm/slurmShuguang/rpc/slurmShuguang"
|
||||
)
|
||||
|
||||
type SlurmShuguangServer struct {
|
||||
svcCtx *svc.ServiceContext
|
||||
slurmShuguang.UnimplementedSlurmShuguangServer
|
||||
}
|
||||
|
||||
func NewSlurmShuguangServer(svcCtx *svc.ServiceContext) *SlurmShuguangServer {
|
||||
return &SlurmShuguangServer{
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
// ListUsers list all users from slurmdb
|
||||
func (s *SlurmShuguangServer) ListUsers(ctx context.Context, in *slurmShuguang.ListUsersReq) (*slurmShuguang.ListUsersResp, error) {
|
||||
l := logic.NewListUsersLogic(ctx, s.svcCtx)
|
||||
return l.ListUsers(in)
|
||||
}
|
||||
|
||||
// GetUser get specific user info from slurmdb
|
||||
func (s *SlurmShuguangServer) GetUser(ctx context.Context, in *slurmShuguang.GetUserReq) (*slurmShuguang.GetUserResp, error) {
|
||||
l := logic.NewGetUserLogic(ctx, s.svcCtx)
|
||||
return l.GetUser(in)
|
||||
}
|
||||
|
||||
// AddUser add new user
|
||||
func (s *SlurmShuguangServer) AddUser(ctx context.Context, in *slurmShuguang.AddUserReq) (*slurmShuguang.AddUserResp, error) {
|
||||
l := logic.NewAddUserLogic(ctx, s.svcCtx)
|
||||
return l.AddUser(in)
|
||||
}
|
||||
|
||||
// DeleteUser delete specific user
|
||||
func (s *SlurmShuguangServer) DeleteUser(ctx context.Context, in *slurmShuguang.DeleteUserReq) (*slurmShuguang.DeleteUserResp, error) {
|
||||
l := logic.NewDeleteUserLogic(ctx, s.svcCtx)
|
||||
return l.DeleteUser(in)
|
||||
}
|
||||
|
||||
// ListAssociations list all associations from slurmdb
|
||||
func (s *SlurmShuguangServer) ListAssociations(ctx context.Context, in *slurmShuguang.ListAssociationsReq) (*slurmShuguang.ListAssociationsResp, error) {
|
||||
l := logic.NewListAssociationsLogic(ctx, s.svcCtx)
|
||||
return l.ListAssociations(in)
|
||||
}
|
||||
|
||||
// GetAssociation get specific association info from slurmdb
|
||||
func (s *SlurmShuguangServer) GetAssociation(ctx context.Context, in *slurmShuguang.GetAssociationReq) (*slurmShuguang.GetAssociationResp, error) {
|
||||
l := logic.NewGetAssociationLogic(ctx, s.svcCtx)
|
||||
return l.GetAssociation(in)
|
||||
}
|
||||
|
||||
// ListAccounts list all accounts info from slurmdb
|
||||
func (s *SlurmShuguangServer) ListAccounts(ctx context.Context, in *slurmShuguang.ListAccountsReq) (*slurmShuguang.ListAccountsResp, error) {
|
||||
l := logic.NewListAccountsLogic(ctx, s.svcCtx)
|
||||
return l.ListAccounts(in)
|
||||
}
|
||||
|
||||
// GetAccount get specific account info from slurmdb
|
||||
func (s *SlurmShuguangServer) GetAccount(ctx context.Context, in *slurmShuguang.GetAccountReq) (*slurmShuguang.GetAccountResp, error) {
|
||||
l := logic.NewGetAccountLogic(ctx, s.svcCtx)
|
||||
return l.GetAccount(in)
|
||||
}
|
||||
|
||||
// AddAccount add account
|
||||
func (s *SlurmShuguangServer) AddAccount(ctx context.Context, in *slurmShuguang.AddAccountReq) (*slurmShuguang.AddAccountResp, error) {
|
||||
l := logic.NewAddAccountLogic(ctx, s.svcCtx)
|
||||
return l.AddAccount(in)
|
||||
}
|
||||
|
||||
// DeleteAccount delete account
|
||||
func (s *SlurmShuguangServer) DeleteAccount(ctx context.Context, in *slurmShuguang.DeleteAccountReq) (*slurmShuguang.DeleteAccountResp, error) {
|
||||
l := logic.NewDeleteAccountLogic(ctx, s.svcCtx)
|
||||
return l.DeleteAccount(in)
|
||||
}
|
||||
|
||||
// ListWckeys list all wckeys info from slurmdb
|
||||
func (s *SlurmShuguangServer) ListWckeys(ctx context.Context, in *slurmShuguang.ListWckeysReq) (*slurmShuguang.ListWckeysResp, error) {
|
||||
l := logic.NewListWckeysLogic(ctx, s.svcCtx)
|
||||
return l.ListWckeys(in)
|
||||
}
|
||||
|
||||
// GetWckey get specific wckey info from slurmdb
|
||||
func (s *SlurmShuguangServer) GetWckey(ctx context.Context, in *slurmShuguang.GetWckeyReq) (*slurmShuguang.GetWckeyResp, error) {
|
||||
l := logic.NewGetWckeyLogic(ctx, s.svcCtx)
|
||||
return l.GetWckey(in)
|
||||
}
|
||||
|
||||
// ListClusters list all Cluster from slurmdb
|
||||
func (s *SlurmShuguangServer) ListClusters(ctx context.Context, in *slurmShuguang.ListClustersReq) (*slurmShuguang.ListClustersResp, error) {
|
||||
l := logic.NewListClustersLogic(ctx, s.svcCtx)
|
||||
return l.ListClusters(in)
|
||||
}
|
||||
|
||||
// GetCluster get specific user info from slurmdb
|
||||
func (s *SlurmShuguangServer) GetCluster(ctx context.Context, in *slurmShuguang.GetClusterReq) (*slurmShuguang.GetClusterResp, error) {
|
||||
l := logic.NewGetClusterLogic(ctx, s.svcCtx)
|
||||
return l.GetCluster(in)
|
||||
}
|
||||
|
||||
// AddCluster add new user
|
||||
func (s *SlurmShuguangServer) AddCluster(ctx context.Context, in *slurmShuguang.AddClusterReq) (*slurmShuguang.AddClusterResp, error) {
|
||||
l := logic.NewAddClusterLogic(ctx, s.svcCtx)
|
||||
return l.AddCluster(in)
|
||||
}
|
||||
|
||||
// DeleteCluster delete specific user
|
||||
func (s *SlurmShuguangServer) DeleteCluster(ctx context.Context, in *slurmShuguang.DeleteClusterReq) (*slurmShuguang.DeleteClusterResp, error) {
|
||||
l := logic.NewDeleteClusterLogic(ctx, s.svcCtx)
|
||||
return l.DeleteCluster(in)
|
||||
}
|
||||
|
||||
// ListNodes list all Node from slurm
|
||||
func (s *SlurmShuguangServer) ListNodes(ctx context.Context, in *slurmShuguang.ListNodesReq) (*slurmShuguang.ListNodesResp, error) {
|
||||
l := logic.NewListNodesLogic(ctx, s.svcCtx)
|
||||
return l.ListNodes(in)
|
||||
}
|
||||
|
||||
// GetNode get specific Node info from slurm
|
||||
func (s *SlurmShuguangServer) GetNode(ctx context.Context, in *slurmShuguang.GetNodeReq) (*slurmShuguang.GetNodeResp, error) {
|
||||
l := logic.NewGetNodeLogic(ctx, s.svcCtx)
|
||||
return l.GetNode(in)
|
||||
}
|
||||
|
||||
// ListPartitions list all Partition from slurm
|
||||
func (s *SlurmShuguangServer) ListPartitions(ctx context.Context, in *slurmShuguang.ListPartitionsReq) (*slurmShuguang.ListPartitionsResp, error) {
|
||||
l := logic.NewListPartitionsLogic(ctx, s.svcCtx)
|
||||
return l.ListPartitions(in)
|
||||
}
|
||||
|
||||
// GetPartition get specific Partition info from slurm
|
||||
func (s *SlurmShuguangServer) GetPartition(ctx context.Context, in *slurmShuguang.GetPartitionReq) (*slurmShuguang.GetPartitionResp, error) {
|
||||
l := logic.NewGetPartitionLogic(ctx, s.svcCtx)
|
||||
return l.GetPartition(in)
|
||||
}
|
||||
|
||||
// ListReservations list all Reservation from slurm
|
||||
func (s *SlurmShuguangServer) ListReservations(ctx context.Context, in *slurmShuguang.ListReservationsReq) (*slurmShuguang.ListReservationsResp, error) {
|
||||
l := logic.NewListReservationsLogic(ctx, s.svcCtx)
|
||||
return l.ListReservations(in)
|
||||
}
|
||||
|
||||
// GetReservation get specific Reservation info from slurm
|
||||
func (s *SlurmShuguangServer) GetReservation(ctx context.Context, in *slurmShuguang.GetReservationReq) (*slurmShuguang.GetReservationResp, error) {
|
||||
l := logic.NewGetReservationLogic(ctx, s.svcCtx)
|
||||
return l.GetReservation(in)
|
||||
}
|
||||
|
||||
// ListJobs list all jobs from slurm
|
||||
func (s *SlurmShuguangServer) ListJobs(ctx context.Context, in *slurmShuguang.ListJobsReq) (*slurmShuguang.ListJobsResp, error) {
|
||||
l := logic.NewListJobsLogic(ctx, s.svcCtx)
|
||||
return l.ListJobs(in)
|
||||
}
|
||||
|
||||
// GetJob get job by id from slurm
|
||||
func (s *SlurmShuguangServer) GetJob(ctx context.Context, in *slurmShuguang.GetJobReq) (*slurmShuguang.GetJobResp, error) {
|
||||
l := logic.NewGetJobLogic(ctx, s.svcCtx)
|
||||
return l.GetJob(in)
|
||||
}
|
||||
|
||||
// SubmitJob submit job to slurm
|
||||
func (s *SlurmShuguangServer) SubmitJob(ctx context.Context, in *slurmShuguang.SubmitJobReq) (*slurmShuguang.SubmitJobResp, error) {
|
||||
l := logic.NewSubmitJobLogic(ctx, s.svcCtx)
|
||||
return l.SubmitJob(in)
|
||||
}
|
||||
|
||||
// DeleteJob delete job from slurm
|
||||
func (s *SlurmShuguangServer) DeleteJob(ctx context.Context, in *slurmShuguang.DeleteJobReq) (*slurmShuguang.DeleteJobResp, error) {
|
||||
l := logic.NewDeleteJobLogic(ctx, s.svcCtx)
|
||||
return l.DeleteJob(in)
|
||||
}
|
||||
|
||||
// UpdateJob update job from slurm
|
||||
func (s *SlurmShuguangServer) UpdateJob(ctx context.Context, in *slurmShuguang.UpdateJobReq) (*slurmShuguang.UpdateJobResp, error) {
|
||||
l := logic.NewUpdateJobLogic(ctx, s.svcCtx)
|
||||
return l.UpdateJob(in)
|
||||
}
|
||||
|
||||
// GetDiag list all diag from slurm
|
||||
func (s *SlurmShuguangServer) GetDiag(ctx context.Context, in *slurmShuguang.DiagReq) (*slurmShuguang.DiagResp, error) {
|
||||
l := logic.NewGetDiagLogic(ctx, s.svcCtx)
|
||||
return l.GetDiag(in)
|
||||
}
|
||||
|
||||
// ListDbJobs list all jobs from slurmdb
|
||||
func (s *SlurmShuguangServer) ListDbJobs(ctx context.Context, in *slurmShuguang.ListDbJobsReq) (*slurmShuguang.ListDbJobsResp, error) {
|
||||
l := logic.NewListDbJobsLogic(ctx, s.svcCtx)
|
||||
return l.ListDbJobs(in)
|
||||
}
|
||||
|
||||
// GetDbJob get job by id from slurmdb
|
||||
func (s *SlurmShuguangServer) GetDbJob(ctx context.Context, in *slurmShuguang.GetDbJobReq) (*slurmShuguang.GetDbJobResp, error) {
|
||||
l := logic.NewGetDbJobLogic(ctx, s.svcCtx)
|
||||
return l.GetDbJob(in)
|
||||
}
|
||||
|
||||
// DeleteQos delete qos from slurmdb
|
||||
func (s *SlurmShuguangServer) DeleteQos(ctx context.Context, in *slurmShuguang.DeleteQosReq) (*slurmShuguang.DeleteQosResp, error) {
|
||||
l := logic.NewDeleteQosLogic(ctx, s.svcCtx)
|
||||
return l.DeleteQos(in)
|
||||
}
|
||||
|
||||
// GetQos get qos by name from slurmdb
|
||||
func (s *SlurmShuguangServer) GetQos(ctx context.Context, in *slurmShuguang.GetQosReq) (*slurmShuguang.GetQosResp, error) {
|
||||
l := logic.NewGetQosLogic(ctx, s.svcCtx)
|
||||
return l.GetQos(in)
|
||||
}
|
||||
|
||||
// AddQos add qos to slurmdb
|
||||
func (s *SlurmShuguangServer) AddQos(ctx context.Context, in *slurmShuguang.AddQosReq) (*slurmShuguang.AddQosResp, error) {
|
||||
l := logic.NewAddQosLogic(ctx, s.svcCtx)
|
||||
return l.AddQos(in)
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package svc
|
||||
|
||||
import "PCM/app/slurm/slurmShuguang/rpc/internal/config"
|
||||
|
||||
type ServiceContext struct {
|
||||
Config config.Config
|
||||
}
|
||||
|
||||
func NewServiceContext(c config.Config) *ServiceContext {
|
||||
return &ServiceContext{
|
||||
Config: c,
|
||||
}
|
||||
}
|
|
@ -0,0 +1,192 @@
|
|||
package util
|
||||
|
||||
import (
|
||||
"PCM/app/slurm/slurmShuguang/rpc/internal/config"
|
||||
"PCM/app/slurm/slurmShuguang/rpc/internal/svc"
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"github.com/zeromicro/go-zero/core/conf"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
||||
//
|
||||
//const (
|
||||
// authenticateUrl = "https://api01.hpccube.com:65102/"
|
||||
// HpcUrls = "https://api01.hpccube.com:65106/"
|
||||
// user = "zhijiang"
|
||||
// password = "111111a"
|
||||
// orgId = "313ae32df03bc116255e6808949fcf57"
|
||||
// layout = "2006-01-02 15:04:05"
|
||||
//)
|
||||
|
||||
var (
|
||||
StatesMapShuguang = map[string]uint32{
|
||||
"statR": 0,
|
||||
"statQ": 1,
|
||||
"statH": 2,
|
||||
"statS": 3,
|
||||
"statE": 4,
|
||||
"statC": 5,
|
||||
"statW": 6,
|
||||
"statX": 7,
|
||||
}
|
||||
Gtoken = GetToken()
|
||||
ClusterId = GetClusterId()
|
||||
)
|
||||
|
||||
type cluster struct {
|
||||
Msg string `json:"msg"`
|
||||
Code string `json:"code"`
|
||||
Data []clusterInfo `json:"data"`
|
||||
}
|
||||
|
||||
type clusterInfo struct {
|
||||
JobManagerType string `json:"JobManagerType"`
|
||||
JobManagerAddr string `json:"JobManagerAddr"`
|
||||
Id int `json:"id"`
|
||||
Text string `json:"text"`
|
||||
JobManagerPort string `json:"JobManagerPort"`
|
||||
}
|
||||
|
||||
type stateToken struct {
|
||||
Msg string `json:"msg"`
|
||||
Code string `json:"code"`
|
||||
Data string `json:"data"`
|
||||
}
|
||||
|
||||
type resultToken struct {
|
||||
Msg string `json:"msg"`
|
||||
Code string `json:"code"`
|
||||
Data []dataToken `json:"data"`
|
||||
}
|
||||
|
||||
type dataToken struct {
|
||||
ClusterName string `json:"clusterName"`
|
||||
ClusterId string `json:"clusterId"`
|
||||
Token string `json:"token"`
|
||||
}
|
||||
|
||||
var configFile = flag.String("flll", "C:\\Users\\Administrator\\GolandProjects\\PCM\\app\\slurm\\slurmShuguang\\rpc\\etc\\slurmshuguang.yaml", "the config file")
|
||||
|
||||
func GetClusterId() int {
|
||||
httpClient := http.Client{Timeout: time.Duration(3) * time.Second}
|
||||
var cf config.Config
|
||||
conf.MustLoad(*configFile, &cf)
|
||||
ctx := svc.NewServiceContext(cf)
|
||||
|
||||
req, err := http.NewRequest("GET", ctx.Config.ShuguangConf.ClusterUrl, nil)
|
||||
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
var token string
|
||||
if GetTokenState(Gtoken) {
|
||||
token = Gtoken
|
||||
} else {
|
||||
token = GetToken()
|
||||
Gtoken = token
|
||||
}
|
||||
|
||||
req.Header.Add("token", token)
|
||||
resp, err := httpClient.Do(req)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
var res cluster
|
||||
err = json.Unmarshal(body, &res)
|
||||
if err != nil {
|
||||
log.Panicln(err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
var id int
|
||||
for _, datum := range res.Data {
|
||||
if datum.JobManagerType == "SLURM" {
|
||||
id = datum.Id
|
||||
}
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
func GetToken() string {
|
||||
httpClient := http.Client{Timeout: time.Duration(3) * time.Second}
|
||||
var cf config.Config
|
||||
conf.MustLoad(*configFile, &cf)
|
||||
ctx := svc.NewServiceContext(cf)
|
||||
|
||||
req, err := http.NewRequest("POST", ctx.Config.ShuguangConf.TokenUrl, nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
req.Header.Add("user", ctx.Config.ShuguangConf.User)
|
||||
req.Header.Add("password", ctx.Config.ShuguangConf.Password)
|
||||
req.Header.Add("orgId", ctx.Config.ShuguangConf.OrgId)
|
||||
|
||||
resp, err := httpClient.Do(req)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
var rd resultToken
|
||||
|
||||
err = json.Unmarshal(body, &rd)
|
||||
if err != nil {
|
||||
log.Panicln(err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
for _, datum := range rd.Data {
|
||||
if datum.ClusterId == "0" {
|
||||
return datum.Token
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func GetTokenState(token string) bool {
|
||||
httpClient := http.Client{Timeout: time.Duration(3) * time.Second}
|
||||
var cf config.Config
|
||||
conf.MustLoad(*configFile, &cf)
|
||||
ctx := svc.NewServiceContext(cf)
|
||||
|
||||
req, err := http.NewRequest("GET", ctx.Config.ShuguangConf.StateUrl, nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
req.Header.Add("token", token)
|
||||
resp, err := httpClient.Do(req)
|
||||
var res stateToken
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
err = json.Unmarshal(body, &res)
|
||||
if err != nil {
|
||||
log.Panicln(err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
if res.Code == "0" {
|
||||
return true
|
||||
} else if res.Code == "10008" {
|
||||
return false
|
||||
} else {
|
||||
log.Panicln(res.Msg)
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func GetTimeDurationString(startTime string, endTime string) string {
|
||||
var cf config.Config
|
||||
conf.MustLoad(*configFile, &cf)
|
||||
ctx := svc.NewServiceContext(cf)
|
||||
|
||||
end, _ := time.Parse(ctx.Config.ShuguangConf.Layout, endTime)
|
||||
start, _ := time.Parse(ctx.Config.ShuguangConf.Layout, startTime)
|
||||
difference := end.Sub(start)
|
||||
return difference.Truncate(time.Second).String()
|
||||
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,39 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
|
||||
"PCM/app/slurm/slurmShuguang/rpc/internal/config"
|
||||
"PCM/app/slurm/slurmShuguang/rpc/internal/server"
|
||||
"PCM/app/slurm/slurmShuguang/rpc/internal/svc"
|
||||
"PCM/app/slurm/slurmShuguang/rpc/slurmShuguang"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/conf"
|
||||
"github.com/zeromicro/go-zero/core/service"
|
||||
"github.com/zeromicro/go-zero/zrpc"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/reflection"
|
||||
)
|
||||
|
||||
var configFile = flag.String("f", "C:\\Users\\Administrator\\GolandProjects\\PCM\\app\\slurm\\slurmShuguang\\rpc\\etc\\slurmshuguang.yaml", "the config file")
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
var c config.Config
|
||||
conf.MustLoad(*configFile, &c)
|
||||
ctx := svc.NewServiceContext(c)
|
||||
|
||||
s := zrpc.MustNewServer(c.RpcServerConf, func(grpcServer *grpc.Server) {
|
||||
slurmShuguang.RegisterSlurmShuguangServer(grpcServer, server.NewSlurmShuguangServer(ctx))
|
||||
|
||||
if c.Mode == service.DevMode || c.Mode == service.TestMode {
|
||||
reflection.Register(grpcServer)
|
||||
}
|
||||
})
|
||||
defer s.Stop()
|
||||
|
||||
fmt.Printf("Starting rpc server at %s...\n", c.ListenOn)
|
||||
s.Start()
|
||||
}
|
|
@ -0,0 +1,389 @@
|
|||
// Code generated by goctl. DO NOT EDIT.
|
||||
// Source: slurmShuguang.proto
|
||||
|
||||
package slurmshuguangclient
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"PCM/app/slurm/slurmShuguang/rpc/slurmShuguang"
|
||||
|
||||
"github.com/zeromicro/go-zero/zrpc"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
type (
|
||||
AccountInfo = slurmShuguang.AccountInfo
|
||||
AccountingInfo = slurmShuguang.AccountingInfo
|
||||
AddAccountReq = slurmShuguang.AddAccountReq
|
||||
AddAccountResp = slurmShuguang.AddAccountResp
|
||||
AddClusterInfo = slurmShuguang.AddClusterInfo
|
||||
AddClusterReq = slurmShuguang.AddClusterReq
|
||||
AddClusterResp = slurmShuguang.AddClusterResp
|
||||
AddQosReq = slurmShuguang.AddQosReq
|
||||
AddQosResp = slurmShuguang.AddQosResp
|
||||
AddUserReq = slurmShuguang.AddUserReq
|
||||
AddUserResp = slurmShuguang.AddUserResp
|
||||
Argv = slurmShuguang.Argv
|
||||
AssocUsageInfo = slurmShuguang.AssocUsageInfo
|
||||
AssociationInfo = slurmShuguang.AssociationInfo
|
||||
ClusterInfo = slurmShuguang.ClusterInfo
|
||||
CoordInfo = slurmShuguang.CoordInfo
|
||||
DeleteAccountReq = slurmShuguang.DeleteAccountReq
|
||||
DeleteAccountResp = slurmShuguang.DeleteAccountResp
|
||||
DeleteClusterReq = slurmShuguang.DeleteClusterReq
|
||||
DeleteClusterResp = slurmShuguang.DeleteClusterResp
|
||||
DeleteJobReq = slurmShuguang.DeleteJobReq
|
||||
DeleteJobResp = slurmShuguang.DeleteJobResp
|
||||
DeleteQosReq = slurmShuguang.DeleteQosReq
|
||||
DeleteQosResp = slurmShuguang.DeleteQosResp
|
||||
DeleteUserReq = slurmShuguang.DeleteUserReq
|
||||
DeleteUserResp = slurmShuguang.DeleteUserResp
|
||||
DiagReq = slurmShuguang.DiagReq
|
||||
DiagResp = slurmShuguang.DiagResp
|
||||
Environment = slurmShuguang.Environment
|
||||
GetAccountReq = slurmShuguang.GetAccountReq
|
||||
GetAccountResp = slurmShuguang.GetAccountResp
|
||||
GetAssociationReq = slurmShuguang.GetAssociationReq
|
||||
GetAssociationResp = slurmShuguang.GetAssociationResp
|
||||
GetClusterReq = slurmShuguang.GetClusterReq
|
||||
GetClusterResp = slurmShuguang.GetClusterResp
|
||||
GetDbJobReq = slurmShuguang.GetDbJobReq
|
||||
GetDbJobResp = slurmShuguang.GetDbJobResp
|
||||
GetJobReq = slurmShuguang.GetJobReq
|
||||
GetJobResp = slurmShuguang.GetJobResp
|
||||
GetNodeReq = slurmShuguang.GetNodeReq
|
||||
GetNodeResp = slurmShuguang.GetNodeResp
|
||||
GetPartitionReq = slurmShuguang.GetPartitionReq
|
||||
GetPartitionResp = slurmShuguang.GetPartitionResp
|
||||
GetQosReq = slurmShuguang.GetQosReq
|
||||
GetQosResp = slurmShuguang.GetQosResp
|
||||
GetReservationReq = slurmShuguang.GetReservationReq
|
||||
GetReservationResp = slurmShuguang.GetReservationResp
|
||||
GetUserReq = slurmShuguang.GetUserReq
|
||||
GetUserResp = slurmShuguang.GetUserResp
|
||||
GetWckeyReq = slurmShuguang.GetWckeyReq
|
||||
GetWckeyResp = slurmShuguang.GetWckeyResp
|
||||
JobInfoDbGet = slurmShuguang.JobInfoDbGet
|
||||
JobInfoGet = slurmShuguang.JobInfoGet
|
||||
JobInfoSubmit = slurmShuguang.JobInfoSubmit
|
||||
ListAccountsReq = slurmShuguang.ListAccountsReq
|
||||
ListAccountsResp = slurmShuguang.ListAccountsResp
|
||||
ListAssociationsReq = slurmShuguang.ListAssociationsReq
|
||||
ListAssociationsResp = slurmShuguang.ListAssociationsResp
|
||||
ListClustersReq = slurmShuguang.ListClustersReq
|
||||
ListClustersResp = slurmShuguang.ListClustersResp
|
||||
ListDbJobsReq = slurmShuguang.ListDbJobsReq
|
||||
ListDbJobsResp = slurmShuguang.ListDbJobsResp
|
||||
ListJobsReq = slurmShuguang.ListJobsReq
|
||||
ListJobsResp = slurmShuguang.ListJobsResp
|
||||
ListNodesReq = slurmShuguang.ListNodesReq
|
||||
ListNodesResp = slurmShuguang.ListNodesResp
|
||||
ListPartitionsReq = slurmShuguang.ListPartitionsReq
|
||||
ListPartitionsResp = slurmShuguang.ListPartitionsResp
|
||||
ListQosesReq = slurmShuguang.ListQosesReq
|
||||
ListQosesResp = slurmShuguang.ListQosesResp
|
||||
ListReservationsReq = slurmShuguang.ListReservationsReq
|
||||
ListReservationsResp = slurmShuguang.ListReservationsResp
|
||||
ListUsersReq = slurmShuguang.ListUsersReq
|
||||
ListUsersResp = slurmShuguang.ListUsersResp
|
||||
ListWckeysReq = slurmShuguang.ListWckeysReq
|
||||
ListWckeysResp = slurmShuguang.ListWckeysResp
|
||||
NodeInfo = slurmShuguang.NodeInfo
|
||||
PartitionInfo = slurmShuguang.PartitionInfo
|
||||
PingInfoMsgReq = slurmShuguang.PingInfoMsgReq
|
||||
PingInfoMsgResp = slurmShuguang.PingInfoMsgResp
|
||||
QosInfo = slurmShuguang.QosInfo
|
||||
QosInfos = slurmShuguang.QosInfos
|
||||
ReservationInfo = slurmShuguang.ReservationInfo
|
||||
SlurmDbStatsT = slurmShuguang.SlurmDbStatsT
|
||||
StatsInfoResponseMsg = slurmShuguang.StatsInfoResponseMsg
|
||||
SubmitJobReq = slurmShuguang.SubmitJobReq
|
||||
SubmitJobResp = slurmShuguang.SubmitJobResp
|
||||
SubmitResponseMsg = slurmShuguang.SubmitResponseMsg
|
||||
UpdateAssociationReq = slurmShuguang.UpdateAssociationReq
|
||||
UpdateAssociationResp = slurmShuguang.UpdateAssociationResp
|
||||
UpdateJobOptions = slurmShuguang.UpdateJobOptions
|
||||
UpdateJobReq = slurmShuguang.UpdateJobReq
|
||||
UpdateJobResp = slurmShuguang.UpdateJobResp
|
||||
UserInfo = slurmShuguang.UserInfo
|
||||
UserInfoList = slurmShuguang.UserInfoList
|
||||
WckeyInfo = slurmShuguang.WckeyInfo
|
||||
|
||||
SlurmShuguang interface {
|
||||
// ListUsers list all users from slurmdb
|
||||
ListUsers(ctx context.Context, in *ListUsersReq, opts ...grpc.CallOption) (*ListUsersResp, error)
|
||||
// GetUser get specific user info from slurmdb
|
||||
GetUser(ctx context.Context, in *GetUserReq, opts ...grpc.CallOption) (*GetUserResp, error)
|
||||
// AddUser add new user
|
||||
AddUser(ctx context.Context, in *AddUserReq, opts ...grpc.CallOption) (*AddUserResp, error)
|
||||
// DeleteUser delete specific user
|
||||
DeleteUser(ctx context.Context, in *DeleteUserReq, opts ...grpc.CallOption) (*DeleteUserResp, error)
|
||||
// ListAssociations list all associations from slurmdb
|
||||
ListAssociations(ctx context.Context, in *ListAssociationsReq, opts ...grpc.CallOption) (*ListAssociationsResp, error)
|
||||
// GetAssociation get specific association info from slurmdb
|
||||
GetAssociation(ctx context.Context, in *GetAssociationReq, opts ...grpc.CallOption) (*GetAssociationResp, error)
|
||||
// ListAccounts list all accounts info from slurmdb
|
||||
ListAccounts(ctx context.Context, in *ListAccountsReq, opts ...grpc.CallOption) (*ListAccountsResp, error)
|
||||
// GetAccount get specific account info from slurmdb
|
||||
GetAccount(ctx context.Context, in *GetAccountReq, opts ...grpc.CallOption) (*GetAccountResp, error)
|
||||
// AddAccount add account
|
||||
AddAccount(ctx context.Context, in *AddAccountReq, opts ...grpc.CallOption) (*AddAccountResp, error)
|
||||
// DeleteAccount delete account
|
||||
DeleteAccount(ctx context.Context, in *DeleteAccountReq, opts ...grpc.CallOption) (*DeleteAccountResp, error)
|
||||
// ListWckeys list all wckeys info from slurmdb
|
||||
ListWckeys(ctx context.Context, in *ListWckeysReq, opts ...grpc.CallOption) (*ListWckeysResp, error)
|
||||
// GetWckey get specific wckey info from slurmdb
|
||||
GetWckey(ctx context.Context, in *GetWckeyReq, opts ...grpc.CallOption) (*GetWckeyResp, error)
|
||||
// ListClusters list all Cluster from slurmdb
|
||||
ListClusters(ctx context.Context, in *ListClustersReq, opts ...grpc.CallOption) (*ListClustersResp, error)
|
||||
// GetCluster get specific user info from slurmdb
|
||||
GetCluster(ctx context.Context, in *GetClusterReq, opts ...grpc.CallOption) (*GetClusterResp, error)
|
||||
// AddCluster add new user
|
||||
AddCluster(ctx context.Context, in *AddClusterReq, opts ...grpc.CallOption) (*AddClusterResp, error)
|
||||
// DeleteCluster delete specific user
|
||||
DeleteCluster(ctx context.Context, in *DeleteClusterReq, opts ...grpc.CallOption) (*DeleteClusterResp, error)
|
||||
// ListNodes list all Node from slurm
|
||||
ListNodes(ctx context.Context, in *ListNodesReq, opts ...grpc.CallOption) (*ListNodesResp, error)
|
||||
// GetNode get specific Node info from slurm
|
||||
GetNode(ctx context.Context, in *GetNodeReq, opts ...grpc.CallOption) (*GetNodeResp, error)
|
||||
// ListPartitions list all Partition from slurm
|
||||
ListPartitions(ctx context.Context, in *ListPartitionsReq, opts ...grpc.CallOption) (*ListPartitionsResp, error)
|
||||
// GetPartition get specific Partition info from slurm
|
||||
GetPartition(ctx context.Context, in *GetPartitionReq, opts ...grpc.CallOption) (*GetPartitionResp, error)
|
||||
// ListReservations list all Reservation from slurm
|
||||
ListReservations(ctx context.Context, in *ListReservationsReq, opts ...grpc.CallOption) (*ListReservationsResp, error)
|
||||
// GetReservation get specific Reservation info from slurm
|
||||
GetReservation(ctx context.Context, in *GetReservationReq, opts ...grpc.CallOption) (*GetReservationResp, error)
|
||||
// ListJobs list all jobs from slurm
|
||||
ListJobs(ctx context.Context, in *ListJobsReq, opts ...grpc.CallOption) (*ListJobsResp, error)
|
||||
// GetJob get job by id from slurm
|
||||
GetJob(ctx context.Context, in *GetJobReq, opts ...grpc.CallOption) (*GetJobResp, error)
|
||||
// SubmitJob submit job to slurm
|
||||
SubmitJob(ctx context.Context, in *SubmitJobReq, opts ...grpc.CallOption) (*SubmitJobResp, error)
|
||||
// DeleteJob delete job from slurm
|
||||
DeleteJob(ctx context.Context, in *DeleteJobReq, opts ...grpc.CallOption) (*DeleteJobResp, error)
|
||||
// UpdateJob update job from slurm
|
||||
UpdateJob(ctx context.Context, in *UpdateJobReq, opts ...grpc.CallOption) (*UpdateJobResp, error)
|
||||
// GetDiag list all diag from slurm
|
||||
GetDiag(ctx context.Context, in *DiagReq, opts ...grpc.CallOption) (*DiagResp, error)
|
||||
// ListDbJobs list all jobs from slurmdb
|
||||
ListDbJobs(ctx context.Context, in *ListDbJobsReq, opts ...grpc.CallOption) (*ListDbJobsResp, error)
|
||||
// GetDbJob get job by id from slurmdb
|
||||
GetDbJob(ctx context.Context, in *GetDbJobReq, opts ...grpc.CallOption) (*GetDbJobResp, error)
|
||||
// DeleteQos delete qos from slurmdb
|
||||
DeleteQos(ctx context.Context, in *DeleteQosReq, opts ...grpc.CallOption) (*DeleteQosResp, error)
|
||||
// GetQos get qos by name from slurmdb
|
||||
GetQos(ctx context.Context, in *GetQosReq, opts ...grpc.CallOption) (*GetQosResp, error)
|
||||
// AddQos add qos to slurmdb
|
||||
AddQos(ctx context.Context, in *AddQosReq, opts ...grpc.CallOption) (*AddQosResp, error)
|
||||
}
|
||||
|
||||
defaultSlurmShuguang struct {
|
||||
cli zrpc.Client
|
||||
}
|
||||
)
|
||||
|
||||
func NewSlurmShuguang(cli zrpc.Client) SlurmShuguang {
|
||||
return &defaultSlurmShuguang{
|
||||
cli: cli,
|
||||
}
|
||||
}
|
||||
|
||||
// ListUsers list all users from slurmdb
|
||||
func (m *defaultSlurmShuguang) ListUsers(ctx context.Context, in *ListUsersReq, opts ...grpc.CallOption) (*ListUsersResp, error) {
|
||||
client := slurmShuguang.NewSlurmShuguangClient(m.cli.Conn())
|
||||
return client.ListUsers(ctx, in, opts...)
|
||||
}
|
||||
|
||||
// GetUser get specific user info from slurmdb
|
||||
func (m *defaultSlurmShuguang) GetUser(ctx context.Context, in *GetUserReq, opts ...grpc.CallOption) (*GetUserResp, error) {
|
||||
client := slurmShuguang.NewSlurmShuguangClient(m.cli.Conn())
|
||||
return client.GetUser(ctx, in, opts...)
|
||||
}
|
||||
|
||||
// AddUser add new user
|
||||
func (m *defaultSlurmShuguang) AddUser(ctx context.Context, in *AddUserReq, opts ...grpc.CallOption) (*AddUserResp, error) {
|
||||
client := slurmShuguang.NewSlurmShuguangClient(m.cli.Conn())
|
||||
return client.AddUser(ctx, in, opts...)
|
||||
}
|
||||
|
||||
// DeleteUser delete specific user
|
||||
func (m *defaultSlurmShuguang) DeleteUser(ctx context.Context, in *DeleteUserReq, opts ...grpc.CallOption) (*DeleteUserResp, error) {
|
||||
client := slurmShuguang.NewSlurmShuguangClient(m.cli.Conn())
|
||||
return client.DeleteUser(ctx, in, opts...)
|
||||
}
|
||||
|
||||
// ListAssociations list all associations from slurmdb
|
||||
func (m *defaultSlurmShuguang) ListAssociations(ctx context.Context, in *ListAssociationsReq, opts ...grpc.CallOption) (*ListAssociationsResp, error) {
|
||||
client := slurmShuguang.NewSlurmShuguangClient(m.cli.Conn())
|
||||
return client.ListAssociations(ctx, in, opts...)
|
||||
}
|
||||
|
||||
// GetAssociation get specific association info from slurmdb
|
||||
func (m *defaultSlurmShuguang) GetAssociation(ctx context.Context, in *GetAssociationReq, opts ...grpc.CallOption) (*GetAssociationResp, error) {
|
||||
client := slurmShuguang.NewSlurmShuguangClient(m.cli.Conn())
|
||||
return client.GetAssociation(ctx, in, opts...)
|
||||
}
|
||||
|
||||
// ListAccounts list all accounts info from slurmdb
|
||||
func (m *defaultSlurmShuguang) ListAccounts(ctx context.Context, in *ListAccountsReq, opts ...grpc.CallOption) (*ListAccountsResp, error) {
|
||||
client := slurmShuguang.NewSlurmShuguangClient(m.cli.Conn())
|
||||
return client.ListAccounts(ctx, in, opts...)
|
||||
}
|
||||
|
||||
// GetAccount get specific account info from slurmdb
|
||||
func (m *defaultSlurmShuguang) GetAccount(ctx context.Context, in *GetAccountReq, opts ...grpc.CallOption) (*GetAccountResp, error) {
|
||||
client := slurmShuguang.NewSlurmShuguangClient(m.cli.Conn())
|
||||
return client.GetAccount(ctx, in, opts...)
|
||||
}
|
||||
|
||||
// AddAccount add account
|
||||
func (m *defaultSlurmShuguang) AddAccount(ctx context.Context, in *AddAccountReq, opts ...grpc.CallOption) (*AddAccountResp, error) {
|
||||
client := slurmShuguang.NewSlurmShuguangClient(m.cli.Conn())
|
||||
return client.AddAccount(ctx, in, opts...)
|
||||
}
|
||||
|
||||
// DeleteAccount delete account
|
||||
func (m *defaultSlurmShuguang) DeleteAccount(ctx context.Context, in *DeleteAccountReq, opts ...grpc.CallOption) (*DeleteAccountResp, error) {
|
||||
client := slurmShuguang.NewSlurmShuguangClient(m.cli.Conn())
|
||||
return client.DeleteAccount(ctx, in, opts...)
|
||||
}
|
||||
|
||||
// ListWckeys list all wckeys info from slurmdb
|
||||
func (m *defaultSlurmShuguang) ListWckeys(ctx context.Context, in *ListWckeysReq, opts ...grpc.CallOption) (*ListWckeysResp, error) {
|
||||
client := slurmShuguang.NewSlurmShuguangClient(m.cli.Conn())
|
||||
return client.ListWckeys(ctx, in, opts...)
|
||||
}
|
||||
|
||||
// GetWckey get specific wckey info from slurmdb
|
||||
func (m *defaultSlurmShuguang) GetWckey(ctx context.Context, in *GetWckeyReq, opts ...grpc.CallOption) (*GetWckeyResp, error) {
|
||||
client := slurmShuguang.NewSlurmShuguangClient(m.cli.Conn())
|
||||
return client.GetWckey(ctx, in, opts...)
|
||||
}
|
||||
|
||||
// ListClusters list all Cluster from slurmdb
|
||||
func (m *defaultSlurmShuguang) ListClusters(ctx context.Context, in *ListClustersReq, opts ...grpc.CallOption) (*ListClustersResp, error) {
|
||||
client := slurmShuguang.NewSlurmShuguangClient(m.cli.Conn())
|
||||
return client.ListClusters(ctx, in, opts...)
|
||||
}
|
||||
|
||||
// GetCluster get specific user info from slurmdb
|
||||
func (m *defaultSlurmShuguang) GetCluster(ctx context.Context, in *GetClusterReq, opts ...grpc.CallOption) (*GetClusterResp, error) {
|
||||
client := slurmShuguang.NewSlurmShuguangClient(m.cli.Conn())
|
||||
return client.GetCluster(ctx, in, opts...)
|
||||
}
|
||||
|
||||
// AddCluster add new user
|
||||
func (m *defaultSlurmShuguang) AddCluster(ctx context.Context, in *AddClusterReq, opts ...grpc.CallOption) (*AddClusterResp, error) {
|
||||
client := slurmShuguang.NewSlurmShuguangClient(m.cli.Conn())
|
||||
return client.AddCluster(ctx, in, opts...)
|
||||
}
|
||||
|
||||
// DeleteCluster delete specific user
|
||||
func (m *defaultSlurmShuguang) DeleteCluster(ctx context.Context, in *DeleteClusterReq, opts ...grpc.CallOption) (*DeleteClusterResp, error) {
|
||||
client := slurmShuguang.NewSlurmShuguangClient(m.cli.Conn())
|
||||
return client.DeleteCluster(ctx, in, opts...)
|
||||
}
|
||||
|
||||
// ListNodes list all Node from slurm
|
||||
func (m *defaultSlurmShuguang) ListNodes(ctx context.Context, in *ListNodesReq, opts ...grpc.CallOption) (*ListNodesResp, error) {
|
||||
client := slurmShuguang.NewSlurmShuguangClient(m.cli.Conn())
|
||||
return client.ListNodes(ctx, in, opts...)
|
||||
}
|
||||
|
||||
// GetNode get specific Node info from slurm
|
||||
func (m *defaultSlurmShuguang) GetNode(ctx context.Context, in *GetNodeReq, opts ...grpc.CallOption) (*GetNodeResp, error) {
|
||||
client := slurmShuguang.NewSlurmShuguangClient(m.cli.Conn())
|
||||
return client.GetNode(ctx, in, opts...)
|
||||
}
|
||||
|
||||
// ListPartitions list all Partition from slurm
|
||||
func (m *defaultSlurmShuguang) ListPartitions(ctx context.Context, in *ListPartitionsReq, opts ...grpc.CallOption) (*ListPartitionsResp, error) {
|
||||
client := slurmShuguang.NewSlurmShuguangClient(m.cli.Conn())
|
||||
return client.ListPartitions(ctx, in, opts...)
|
||||
}
|
||||
|
||||
// GetPartition get specific Partition info from slurm
|
||||
func (m *defaultSlurmShuguang) GetPartition(ctx context.Context, in *GetPartitionReq, opts ...grpc.CallOption) (*GetPartitionResp, error) {
|
||||
client := slurmShuguang.NewSlurmShuguangClient(m.cli.Conn())
|
||||
return client.GetPartition(ctx, in, opts...)
|
||||
}
|
||||
|
||||
// ListReservations list all Reservation from slurm
|
||||
func (m *defaultSlurmShuguang) ListReservations(ctx context.Context, in *ListReservationsReq, opts ...grpc.CallOption) (*ListReservationsResp, error) {
|
||||
client := slurmShuguang.NewSlurmShuguangClient(m.cli.Conn())
|
||||
return client.ListReservations(ctx, in, opts...)
|
||||
}
|
||||
|
||||
// GetReservation get specific Reservation info from slurm
|
||||
func (m *defaultSlurmShuguang) GetReservation(ctx context.Context, in *GetReservationReq, opts ...grpc.CallOption) (*GetReservationResp, error) {
|
||||
client := slurmShuguang.NewSlurmShuguangClient(m.cli.Conn())
|
||||
return client.GetReservation(ctx, in, opts...)
|
||||
}
|
||||
|
||||
// ListJobs list all jobs from slurm
|
||||
func (m *defaultSlurmShuguang) ListJobs(ctx context.Context, in *ListJobsReq, opts ...grpc.CallOption) (*ListJobsResp, error) {
|
||||
client := slurmShuguang.NewSlurmShuguangClient(m.cli.Conn())
|
||||
return client.ListJobs(ctx, in, opts...)
|
||||
}
|
||||
|
||||
// GetJob get job by id from slurm
|
||||
func (m *defaultSlurmShuguang) GetJob(ctx context.Context, in *GetJobReq, opts ...grpc.CallOption) (*GetJobResp, error) {
|
||||
client := slurmShuguang.NewSlurmShuguangClient(m.cli.Conn())
|
||||
return client.GetJob(ctx, in, opts...)
|
||||
}
|
||||
|
||||
// SubmitJob submit job to slurm
|
||||
func (m *defaultSlurmShuguang) SubmitJob(ctx context.Context, in *SubmitJobReq, opts ...grpc.CallOption) (*SubmitJobResp, error) {
|
||||
client := slurmShuguang.NewSlurmShuguangClient(m.cli.Conn())
|
||||
return client.SubmitJob(ctx, in, opts...)
|
||||
}
|
||||
|
||||
// DeleteJob delete job from slurm
|
||||
func (m *defaultSlurmShuguang) DeleteJob(ctx context.Context, in *DeleteJobReq, opts ...grpc.CallOption) (*DeleteJobResp, error) {
|
||||
client := slurmShuguang.NewSlurmShuguangClient(m.cli.Conn())
|
||||
return client.DeleteJob(ctx, in, opts...)
|
||||
}
|
||||
|
||||
// UpdateJob update job from slurm
|
||||
func (m *defaultSlurmShuguang) UpdateJob(ctx context.Context, in *UpdateJobReq, opts ...grpc.CallOption) (*UpdateJobResp, error) {
|
||||
client := slurmShuguang.NewSlurmShuguangClient(m.cli.Conn())
|
||||
return client.UpdateJob(ctx, in, opts...)
|
||||
}
|
||||
|
||||
// GetDiag list all diag from slurm
|
||||
func (m *defaultSlurmShuguang) GetDiag(ctx context.Context, in *DiagReq, opts ...grpc.CallOption) (*DiagResp, error) {
|
||||
client := slurmShuguang.NewSlurmShuguangClient(m.cli.Conn())
|
||||
return client.GetDiag(ctx, in, opts...)
|
||||
}
|
||||
|
||||
// ListDbJobs list all jobs from slurmdb
|
||||
func (m *defaultSlurmShuguang) ListDbJobs(ctx context.Context, in *ListDbJobsReq, opts ...grpc.CallOption) (*ListDbJobsResp, error) {
|
||||
client := slurmShuguang.NewSlurmShuguangClient(m.cli.Conn())
|
||||
return client.ListDbJobs(ctx, in, opts...)
|
||||
}
|
||||
|
||||
// GetDbJob get job by id from slurmdb
|
||||
func (m *defaultSlurmShuguang) GetDbJob(ctx context.Context, in *GetDbJobReq, opts ...grpc.CallOption) (*GetDbJobResp, error) {
|
||||
client := slurmShuguang.NewSlurmShuguangClient(m.cli.Conn())
|
||||
return client.GetDbJob(ctx, in, opts...)
|
||||
}
|
||||
|
||||
// DeleteQos delete qos from slurmdb
|
||||
func (m *defaultSlurmShuguang) DeleteQos(ctx context.Context, in *DeleteQosReq, opts ...grpc.CallOption) (*DeleteQosResp, error) {
|
||||
client := slurmShuguang.NewSlurmShuguangClient(m.cli.Conn())
|
||||
return client.DeleteQos(ctx, in, opts...)
|
||||
}
|
||||
|
||||
// GetQos get qos by name from slurmdb
|
||||
func (m *defaultSlurmShuguang) GetQos(ctx context.Context, in *GetQosReq, opts ...grpc.CallOption) (*GetQosResp, error) {
|
||||
client := slurmShuguang.NewSlurmShuguangClient(m.cli.Conn())
|
||||
return client.GetQos(ctx, in, opts...)
|
||||
}
|
||||
|
||||
// AddQos add qos to slurmdb
|
||||
func (m *defaultSlurmShuguang) AddQos(ctx context.Context, in *AddQosReq, opts ...grpc.CallOption) (*AddQosResp, error) {
|
||||
client := slurmShuguang.NewSlurmShuguangClient(m.cli.Conn())
|
||||
return client.AddQos(ctx, in, opts...)
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
package result
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"PCM/common/xerr"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// http返回
|
||||
func HttpResult(r *http.Request, w http.ResponseWriter, resp interface{}, err error) {
|
||||
|
||||
if err == nil {
|
||||
//成功返回
|
||||
r := Success(resp)
|
||||
httpx.WriteJson(w, http.StatusOK, r)
|
||||
} else {
|
||||
//错误返回
|
||||
errcode := xerr.SERVER_COMMON_ERROR
|
||||
errmsg := "服务器开小差啦,稍后再来试一试"
|
||||
|
||||
causeErr := errors.Cause(err) // err类型
|
||||
if e, ok := causeErr.(*xerr.CodeError); ok { //自定义错误类型
|
||||
//自定义CodeError
|
||||
errcode = e.GetErrCode()
|
||||
errmsg = e.GetErrMsg()
|
||||
} else {
|
||||
if gstatus, ok := status.FromError(causeErr); ok { // grpc err错误
|
||||
grpcCode := uint32(gstatus.Code())
|
||||
if xerr.IsCodeErr(grpcCode) { //区分自定义错误跟系统底层、db等错误,底层、db错误不能返回给前端
|
||||
errcode = grpcCode
|
||||
errmsg = gstatus.Message()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
logx.WithContext(r.Context()).Errorf("【API-ERR】 : %+v ", err)
|
||||
|
||||
httpx.WriteJson(w, http.StatusBadRequest, Error(errcode, errmsg))
|
||||
}
|
||||
}
|
||||
|
||||
// 授权的http方法
|
||||
func AuthHttpResult(r *http.Request, w http.ResponseWriter, resp interface{}, err error) {
|
||||
|
||||
if err == nil {
|
||||
//成功返回
|
||||
r := Success(resp)
|
||||
httpx.WriteJson(w, http.StatusOK, r)
|
||||
} else {
|
||||
//错误返回
|
||||
errcode := xerr.SERVER_COMMON_ERROR
|
||||
errmsg := "服务器开小差啦,稍后再来试一试"
|
||||
|
||||
causeErr := errors.Cause(err) // err类型
|
||||
if e, ok := causeErr.(*xerr.CodeError); ok { //自定义错误类型
|
||||
//自定义CodeError
|
||||
errcode = e.GetErrCode()
|
||||
errmsg = e.GetErrMsg()
|
||||
} else {
|
||||
if gstatus, ok := status.FromError(causeErr); ok { // grpc err错误
|
||||
grpcCode := uint32(gstatus.Code())
|
||||
if xerr.IsCodeErr(grpcCode) { //区分自定义错误跟系统底层、db等错误,底层、db错误不能返回给前端
|
||||
errcode = grpcCode
|
||||
errmsg = gstatus.Message()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
logx.WithContext(r.Context()).Errorf("【GATEWAY-ERR】 : %+v ", err)
|
||||
|
||||
httpx.WriteJson(w, http.StatusUnauthorized, Error(errcode, errmsg))
|
||||
}
|
||||
}
|
||||
|
||||
// http 参数错误返回
|
||||
func ParamErrorResult(r *http.Request, w http.ResponseWriter, err error) {
|
||||
errMsg := fmt.Sprintf("%s ,%s", xerr.MapErrMsg(xerr.REUQEST_PARAM_ERROR), err.Error())
|
||||
httpx.WriteJson(w, http.StatusBadRequest, Error(xerr.REUQEST_PARAM_ERROR, errMsg))
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
package result
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"PCM/common/xerr"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// job返回
|
||||
func JobResult(ctx context.Context, resp interface{}, err error) {
|
||||
if err == nil {
|
||||
// 成功返回 ,只有dev环境下才会打印info,线上不显示
|
||||
if resp != nil {
|
||||
logx.Infof("resp: %+v", resp)
|
||||
}
|
||||
return
|
||||
} else {
|
||||
errCode := xerr.SERVER_COMMON_ERROR
|
||||
errMsg := "服务器开小差啦,稍后再来试一试"
|
||||
|
||||
// 错误返回
|
||||
causeErr := errors.Cause(err) // err类型
|
||||
if e, ok := causeErr.(*xerr.CodeError); ok { // 自定义错误类型
|
||||
// 自定义CodeError
|
||||
errCode = e.GetErrCode()
|
||||
errMsg = e.GetErrMsg()
|
||||
} else {
|
||||
if gstatus, ok := status.FromError(causeErr); ok { // grpc err错误
|
||||
grpcCode := uint32(gstatus.Code())
|
||||
if xerr.IsCodeErr(grpcCode) { // 区分自定义错误跟系统底层、db等错误,底层、db错误不能返回给前端
|
||||
errCode = grpcCode
|
||||
errMsg = gstatus.Message()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
logx.WithContext(ctx).Errorf("【JOB-ERR】 : %+v ,errCode:%d , errMsg:%s ", err, errCode, errMsg)
|
||||
return
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package result
|
||||
|
||||
type ResponseSuccessBean struct {
|
||||
Code uint32 `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
Data interface{} `json:"data"`
|
||||
}
|
||||
type NullJson struct{}
|
||||
|
||||
func Success(data interface{}) *ResponseSuccessBean {
|
||||
return &ResponseSuccessBean{200, "OK", data}
|
||||
}
|
||||
|
||||
type ResponseErrorBean struct {
|
||||
Code uint32 `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
}
|
||||
|
||||
func Error(errCode uint32, errMsg string) *ResponseErrorBean {
|
||||
return &ResponseErrorBean{errCode, errMsg}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package tool
|
||||
|
||||
import "github.com/shopspring/decimal"
|
||||
|
||||
var oneHundredDecimal decimal.Decimal = decimal.NewFromInt(100)
|
||||
|
||||
// 分转元
|
||||
func Fen2Yuan(fen int64) float64 {
|
||||
y, _ := decimal.NewFromInt(fen).Div(oneHundredDecimal).Truncate(2).Float64()
|
||||
return y
|
||||
}
|
||||
|
||||
// 元转分
|
||||
func Yuan2Fen(yuan float64) int64 {
|
||||
|
||||
f, _ := decimal.NewFromFloat(yuan).Mul(oneHundredDecimal).Truncate(0).Float64()
|
||||
return int64(f)
|
||||
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package tool
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
"fmt"
|
||||
"io"
|
||||
)
|
||||
|
||||
/** 加密方式 **/
|
||||
|
||||
func Md5ByString(str string) string {
|
||||
m := md5.New()
|
||||
_, err := io.WriteString(m, str)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
arr := m.Sum(nil)
|
||||
return fmt.Sprintf("%x", arr)
|
||||
}
|
||||
|
||||
func Md5ByBytes(b []byte) string {
|
||||
return fmt.Sprintf("%x", md5.Sum(b))
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package tool
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
KC_RAND_KIND_NUM = 0 // 纯数字
|
||||
KC_RAND_KIND_LOWER = 1 // 小写字母
|
||||
KC_RAND_KIND_UPPER = 2 // 大写字母
|
||||
KC_RAND_KIND_ALL = 3 // 数字、大小写字母
|
||||
)
|
||||
|
||||
// 随机字符串
|
||||
func Krand(size int, kind int) string {
|
||||
ikind, kinds, result := kind, [][]int{[]int{10, 48}, []int{26, 97}, []int{26, 65}}, make([]byte, size)
|
||||
is_all := kind > 2 || kind < 0
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
for i := 0; i < size; i++ {
|
||||
if is_all { // random ikind
|
||||
ikind = rand.Intn(3)
|
||||
}
|
||||
scope, base := kinds[ikind][0], kinds[ikind][1]
|
||||
result[i] = uint8(base + rand.Intn(scope))
|
||||
}
|
||||
return string(result)
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package tool
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestMd5ByString(t *testing.T) {
|
||||
s := Md5ByString("AAA")
|
||||
t.Log(s)
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package tool
|
||||
|
||||
import "strings"
|
||||
|
||||
// 替换
|
||||
func InPlaceholders(n int) string {
|
||||
var b strings.Builder
|
||||
for i := 0; i < n-1; i++ {
|
||||
b.WriteString("?,")
|
||||
}
|
||||
if n > 0 {
|
||||
b.WriteString("?")
|
||||
}
|
||||
return b.String()
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package uniqueid
|
||||
|
||||
import (
|
||||
"github.com/sony/sonyflake"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
var flake *sonyflake.Sonyflake
|
||||
|
||||
func init() {
|
||||
flake = sonyflake.NewSonyflake(sonyflake.Settings{})
|
||||
}
|
||||
|
||||
func GenId() int64 {
|
||||
|
||||
id, err := flake.NextID()
|
||||
if err != nil {
|
||||
logx.Severef("flake NextID failed with %s \n", err)
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return int64(id)
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package xerr
|
||||
|
||||
// 成功返回
|
||||
const OK uint32 = 200
|
||||
|
||||
/**(前3位代表业务,后三位代表具体功能)**/
|
||||
|
||||
// 全局错误码
|
||||
const SERVER_COMMON_ERROR uint32 = 100001
|
||||
const REUQEST_PARAM_ERROR uint32 = 100002
|
||||
const TOKEN_EXPIRE_ERROR uint32 = 100003
|
||||
const TOKEN_GENERATE_ERROR uint32 = 100004
|
||||
const DB_ERROR uint32 = 100005
|
||||
const DB_UPDATE_AFFECTED_ZERO_ERROR uint32 = 100006
|
||||
|
||||
//用户模块
|
|
@ -0,0 +1,30 @@
|
|||
package xerr
|
||||
|
||||
var message map[uint32]string
|
||||
|
||||
func init() {
|
||||
message = make(map[uint32]string)
|
||||
message[OK] = "SUCCESS"
|
||||
message[SERVER_COMMON_ERROR] = "服务器开小差啦,稍后再来试一试"
|
||||
message[REUQEST_PARAM_ERROR] = "参数错误"
|
||||
message[TOKEN_EXPIRE_ERROR] = "token失效,请重新登陆"
|
||||
message[TOKEN_GENERATE_ERROR] = "生成token失败"
|
||||
message[DB_ERROR] = "数据库繁忙,请稍后再试"
|
||||
message[DB_UPDATE_AFFECTED_ZERO_ERROR] = "更新数据影响行数为0"
|
||||
}
|
||||
|
||||
func MapErrMsg(errcode uint32) string {
|
||||
if msg, ok := message[errcode]; ok {
|
||||
return msg
|
||||
} else {
|
||||
return "服务器开小差啦,稍后再来试一试"
|
||||
}
|
||||
}
|
||||
|
||||
func IsCodeErr(errcode uint32) bool {
|
||||
if _, ok := message[errcode]; ok {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package xerr
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
/**
|
||||
常用通用固定错误
|
||||
*/
|
||||
|
||||
type CodeError struct {
|
||||
errCode uint32
|
||||
errMsg string
|
||||
}
|
||||
|
||||
// 返回给前端的错误码
|
||||
func (e *CodeError) GetErrCode() uint32 {
|
||||
return e.errCode
|
||||
}
|
||||
|
||||
// 返回给前端显示端错误信息
|
||||
func (e *CodeError) GetErrMsg() string {
|
||||
return e.errMsg
|
||||
}
|
||||
|
||||
func (e *CodeError) Error() string {
|
||||
return fmt.Sprintf("ErrCode:%d,ErrMsg:%s", e.errCode, e.errMsg)
|
||||
}
|
||||
|
||||
func NewErrCodeMsg(errCode uint32, errMsg string) *CodeError {
|
||||
return &CodeError{errCode: errCode, errMsg: errMsg}
|
||||
}
|
||||
func NewErrCode(errCode uint32) *CodeError {
|
||||
return &CodeError{errCode: errCode, errMsg: MapErrMsg(errCode)}
|
||||
}
|
||||
|
||||
func NewErrMsg(errMsg string) *CodeError {
|
||||
return &CodeError{errCode: SERVER_COMMON_ERROR, errMsg: errMsg}
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
module PCM
|
||||
|
||||
go 1.19
|
||||
|
||||
require (
|
||||
github.com/jinzhu/copier v0.3.5
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/shopspring/decimal v1.3.1
|
||||
github.com/sony/sonyflake v1.1.0
|
||||
github.com/zeromicro/go-zero v1.4.4
|
||||
google.golang.org/grpc v1.50.1
|
||||
google.golang.org/protobuf v1.28.1
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/cenkalti/backoff/v4 v4.1.3 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.1.2 // indirect
|
||||
github.com/coreos/go-semver v0.3.0 // indirect
|
||||
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
||||
github.com/fatih/color v1.13.0 // indirect
|
||||
github.com/felixge/fgprof v0.9.3 // indirect
|
||||
github.com/go-logr/logr v1.2.3 // indirect
|
||||
github.com/go-logr/stdr v1.2.2 // indirect
|
||||
github.com/go-redis/redis/v8 v8.11.5 // indirect
|
||||
github.com/gogo/protobuf v1.3.2 // indirect
|
||||
github.com/golang-jwt/jwt/v4 v4.4.3 // indirect
|
||||
github.com/golang/mock v1.6.0 // indirect
|
||||
github.com/golang/protobuf v1.5.2 // indirect
|
||||
github.com/google/go-cmp v0.5.9 // indirect
|
||||
github.com/google/gofuzz v1.2.0 // indirect
|
||||
github.com/google/pprof v0.0.0-20211214055906-6f57359322fd // indirect
|
||||
github.com/google/uuid v1.3.0 // indirect
|
||||
github.com/googleapis/gnostic v0.5.5 // indirect
|
||||
github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/mattn/go-colorable v0.1.9 // indirect
|
||||
github.com/mattn/go-isatty v0.0.14 // indirect
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/openzipkin/zipkin-go v0.4.0 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
|
||||
github.com/prometheus/client_golang v1.13.0 // indirect
|
||||
github.com/prometheus/client_model v0.2.0 // indirect
|
||||
github.com/prometheus/common v0.37.0 // indirect
|
||||
github.com/prometheus/procfs v0.8.0 // indirect
|
||||
github.com/spaolacci/murmur3 v1.1.0 // indirect
|
||||
go.etcd.io/etcd/api/v3 v3.5.5 // indirect
|
||||
go.etcd.io/etcd/client/pkg/v3 v3.5.5 // indirect
|
||||
go.etcd.io/etcd/client/v3 v3.5.5 // indirect
|
||||
go.opentelemetry.io/otel v1.10.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/jaeger v1.10.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.10.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.10.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.10.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.10.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/zipkin v1.10.0 // indirect
|
||||
go.opentelemetry.io/otel/sdk v1.10.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.10.0 // indirect
|
||||
go.opentelemetry.io/proto/otlp v0.19.0 // indirect
|
||||
go.uber.org/atomic v1.9.0 // indirect
|
||||
go.uber.org/automaxprocs v1.5.1 // indirect
|
||||
go.uber.org/multierr v1.8.0 // indirect
|
||||
go.uber.org/zap v1.21.0 // indirect
|
||||
golang.org/x/net v0.0.0-20221014081412-f15817d10f9b // indirect
|
||||
golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783 // indirect
|
||||
golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10 // indirect
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
|
||||
golang.org/x/text v0.4.0 // indirect
|
||||
golang.org/x/time v0.3.0 // indirect
|
||||
google.golang.org/appengine v1.6.7 // indirect
|
||||
google.golang.org/genproto v0.0.0-20221111202108-142d8a6fa32e // indirect
|
||||
gopkg.in/inf.v0 v0.9.1 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
k8s.io/api v0.22.9 // indirect
|
||||
k8s.io/apimachinery v0.22.9 // indirect
|
||||
k8s.io/client-go v0.22.9 // indirect
|
||||
k8s.io/klog/v2 v2.80.1 // indirect
|
||||
k8s.io/utils v0.0.0-20221108210102-8e77b1f39fe2 // indirect
|
||||
sigs.k8s.io/structured-merge-diff/v4 v4.2.1 // indirect
|
||||
sigs.k8s.io/yaml v1.2.0 // indirect
|
||||
)
|
Loading…
Reference in New Issue