feat listParticipant impl

Signed-off-by: devad <cossjie@foxmail.com>
This commit is contained in:
devad 2023-08-14 17:37:25 +08:00
parent f72f8b9f6f
commit daab8da594
16 changed files with 988 additions and 470 deletions

View File

@ -712,7 +712,7 @@ type DeleteServiceResp {
/******************Delete Service End*************************/
/******************List Services Start*************************/
/******************ClientList Services Start*************************/
type (
ListServicesReq {
ProjectId string `path:"projectId"`
@ -757,7 +757,7 @@ type ListServices {
IsFree bool `json:"isFree,omitempty" copier:"IsFree"`
AdditionalProperties map[string]string `json:"additionalProperties,omitempty" copier:"AdditionalProperties"`
}
/******************List Service End*************************/
/******************ClientList Service End*************************/
/******************Show Service Start*************************/
type (
@ -835,7 +835,7 @@ type QueryServiceConfig {
}
/******************Show Service End*************************/
/******************List Clusters Start*************************/
/******************ClientList Clusters Start*************************/
type (
ListClustersReq {
ProjectId string `json:"projectId" copier:"ProjectId"`
@ -884,7 +884,7 @@ type Cluster {
PeriodType string `json:"periodType,omitempty" copier:"PeriodType"`
OrderId string `json:"orderId,omitempty" copier:"OrderId"`
}
/******************List Clusters End*************************/
/******************ClientList Clusters End*************************/
/******************ListAlgorithms start*************************/
type AlgorithmResponse {

15
go.mod
View File

@ -4,9 +4,10 @@ go 1.18
require (
github.com/Masterminds/squirrel v1.5.4
github.com/aws/aws-sdk-go v1.44.300
github.com/docker/docker v24.0.4+incompatible
github.com/aws/aws-sdk-go v1.44.322
github.com/docker/docker v24.0.5+incompatible
github.com/go-redis/redis v6.15.9+incompatible
github.com/go-redis/redis/v8 v8.11.5
github.com/go-sql-driver/mysql v1.7.1
github.com/jinzhu/copier v0.3.5
github.com/pkg/errors v0.9.1
@ -14,16 +15,11 @@ require (
github.com/shopspring/decimal v1.3.1
github.com/zeromicro/go-queue v1.1.8
github.com/zeromicro/go-zero v1.5.3
gitlink.org.cn/jcce-pcm/pcm-participant-ac v0.0.0-20230714010248-294dcad12511
gitlink.org.cn/jcce-pcm/pcm-participant-ceph v0.0.0-20230714015715-9098b752beff
gitlink.org.cn/jcce-pcm/pcm-participant-modelarts v0.0.0-20230714013255-149a9b428b28
gitlink.org.cn/jcce-pcm/pcm-participant-octopus v0.0.0-20230714012611-c66005610d0c
gitlink.org.cn/jcce-pcm/pcm-participant-slurm v0.0.0-20230714015940-004100bfa168
gitlink.org.cn/jcce-pcm/utils v0.0.0-20230725025032-ac218fa4db06
gitlink.org.cn/jcce-pcm/utils v0.0.0-20230814014928-a705f3bb3eae
google.golang.org/grpc v1.56.2
google.golang.org/protobuf v1.31.0
gorm.io/driver/mysql v1.5.1
gorm.io/gorm v1.25.2
gorm.io/gorm v1.25.3
k8s.io/api v0.26.3
k8s.io/apimachinery v0.27.3
)
@ -51,7 +47,6 @@ require (
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.1 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/go-redis/redis/v8 v8.11.5 // indirect
github.com/go-resty/resty/v2 v2.7.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect

40
go.sum
View File

@ -431,8 +431,8 @@ github.com/aliyun/alibaba-cloud-sdk-go v1.61.1704/go.mod h1:RcDobYh8k5VP6TNybz9m
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY=
github.com/aws/aws-sdk-go v1.44.300 h1:Zn+3lqgYahIf9yfrwZ+g+hq/c3KzUBaQ8wqY/ZXiAbY=
github.com/aws/aws-sdk-go v1.44.300/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI=
github.com/aws/aws-sdk-go v1.44.322 h1:7JfwifGRGQMHd99PvfXqxBaZsjuRaOF6e3X9zRx2uYo=
github.com/aws/aws-sdk-go v1.44.322/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI=
github.com/beanstalkd/go-beanstalk v0.2.0/go.mod h1:/G8YTyChOtpOArwLTQPY1CHB+i212+av35bkPXXj56Y=
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
@ -491,8 +491,8 @@ github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/r
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8=
github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
github.com/docker/docker v24.0.4+incompatible h1:s/LVDftw9hjblvqIeTiGYXBCD95nOEEl7qRsRrIOuQI=
github.com/docker/docker v24.0.4+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/docker v24.0.5+incompatible h1:WmgcE4fxyI6EEXxBRxsHnZXrO1pQ3smi0k/jho4HLeY=
github.com/docker/docker v24.0.5+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ=
github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec=
github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4=
@ -1027,18 +1027,22 @@ github.com/zeromicro/go-zero v1.4.3/go.mod h1:UmDjuW7LHd9j7+nnnPBcXF0HLNmjJw6OjH
github.com/zeromicro/go-zero v1.5.1/go.mod h1:bGYm4XWsGN9GhDsO2O2BngpVoWjf3Eog2a5hUOMhlXs=
github.com/zeromicro/go-zero v1.5.3 h1:9poyd+raeL7gSMUu6P19N7bssTppieR2j7Oos2j1yFQ=
github.com/zeromicro/go-zero v1.5.3/go.mod h1:dmoBpgJTxt9KWmgrNGpv06XxZRPXMakrxUVgROFAR3g=
gitlink.org.cn/jcce-pcm/pcm-participant-ac v0.0.0-20230714010248-294dcad12511 h1:KF6qN2K04bTZiOwU6XxfC4MoeMrDC/X+ep89CoepEB0=
gitlink.org.cn/jcce-pcm/pcm-participant-ac v0.0.0-20230714010248-294dcad12511/go.mod h1:LI9P/qnLTALG711SFKLea+i78vNQWx45xlHImJwt0E4=
gitlink.org.cn/jcce-pcm/pcm-participant-ceph v0.0.0-20230714015715-9098b752beff h1:hUwUMdlPEK3HQRBVQBEnzDqw3FqeVHjBVhXooNhlmkI=
gitlink.org.cn/jcce-pcm/pcm-participant-ceph v0.0.0-20230714015715-9098b752beff/go.mod h1:XpssaA6VJ1IQxZV6IJ/CFpFCqid0XsE13FBH57oKXkQ=
gitlink.org.cn/jcce-pcm/pcm-participant-modelarts v0.0.0-20230714013255-149a9b428b28 h1:Qj2rKy8V1Cmy5tH0OiS4q9PrQvvmImAtyBTcx8l1Czk=
gitlink.org.cn/jcce-pcm/pcm-participant-modelarts v0.0.0-20230714013255-149a9b428b28/go.mod h1:u+TB7q6AgVgOixZHDdWxtVTtCn50IYayNrscwe0AY6w=
gitlink.org.cn/jcce-pcm/pcm-participant-octopus v0.0.0-20230714012611-c66005610d0c h1:ZrXRa3N8nT5lGfyvSBjrZkwPRzTWQ77O/bTb5z6ORzM=
gitlink.org.cn/jcce-pcm/pcm-participant-octopus v0.0.0-20230714012611-c66005610d0c/go.mod h1:9Ad9vxCPGbY1yF1NhHWL2EhxsXJBB6bzz9i7PeSfKG4=
gitlink.org.cn/jcce-pcm/pcm-participant-slurm v0.0.0-20230714015940-004100bfa168 h1:BgTVUqJMOhdm6mNPx1ti5ClTnyMjZlCvH0avI1dz1xg=
gitlink.org.cn/jcce-pcm/pcm-participant-slurm v0.0.0-20230714015940-004100bfa168/go.mod h1:lY3jXmmMvC7j4Q2ogliThURWp9c1XCToSCnRkdc1aW8=
gitlink.org.cn/jcce-pcm/utils v0.0.0-20230725025032-ac218fa4db06 h1:mjt1ynoyzyowzm+pUXZKptoSHqjGyzw6uNCQzeHo1/g=
gitlink.org.cn/jcce-pcm/utils v0.0.0-20230725025032-ac218fa4db06/go.mod h1:u8PTlBpzUyOlbQJgfSiutq91q/JtrJIQiPNDe4S/pGs=
gitlink.org.cn/jcce-pcm/pcm-participant-ac v0.0.0-20230719012340-05049e43b869 h1:P0k0QqANY+Odhihyo4IZvhm4dd0a8BTlyaHiLHDKKyM=
gitlink.org.cn/jcce-pcm/pcm-participant-ac v0.0.0-20230719012340-05049e43b869/go.mod h1:fpj6MlFgDoGv5R0ETSg+Mni4VoykKXNrvNJAOkV9cvU=
gitlink.org.cn/jcce-pcm/pcm-participant-ceph v0.0.0-20230811110436-43ae93ec1796 h1:NxIT12DfQW3ff8fUwrEhHFwe/c9sIlxUG3g0XUh7v90=
gitlink.org.cn/jcce-pcm/pcm-participant-ceph v0.0.0-20230811110436-43ae93ec1796/go.mod h1:Jk4srb1NAFSn/kMWeo71/I02luZ8OrmVnUFWb8abr7I=
gitlink.org.cn/jcce-pcm/pcm-participant-modelarts v0.0.0-20230719015658-08a29549d86a h1:eSniMdLizPV3RNrz7/URgjT3Kpv1cTZ05jrWfxRJxHs=
gitlink.org.cn/jcce-pcm/pcm-participant-modelarts v0.0.0-20230719015658-08a29549d86a/go.mod h1:BhOgwM1LC+BD46DjTaQyYQVZs1CikwI5Pl/6qzKUexc=
gitlink.org.cn/jcce-pcm/pcm-participant-octopus v0.0.0-20230714030856-601935bc30e2 h1:RcGSqhsod6VXLksSLqNjV0q/SCeoUv6CbThKmV9NTZE=
gitlink.org.cn/jcce-pcm/pcm-participant-octopus v0.0.0-20230714030856-601935bc30e2/go.mod h1:uyvpVqG1jHDXX+ubXI0RBwnWXzVykD/mliqGQIDvRoo=
gitlink.org.cn/jcce-pcm/pcm-participant-slurm v0.0.0-20230714030125-a52fa198ddf4 h1:r2hBP5G/bbkPpDTPk3ENnQxD82vkoYMSeNHYhNAVRX4=
gitlink.org.cn/jcce-pcm/pcm-participant-slurm v0.0.0-20230714030125-a52fa198ddf4/go.mod h1:zRdVJiv4r4jgBli2xpYGmV0n6Gmz8fkZ5pJaNK2MbTU=
gitlink.org.cn/jcce-pcm/utils v0.0.0-20230814014928-a705f3bb3eae h1:oJxnyOJ6Ps/uPqwSEumXcUYm7dkF08r4gHhfy7NRn4s=
gitlink.org.cn/jcce-pcm/utils v0.0.0-20230814014928-a705f3bb3eae/go.mod h1:zTa+selMe02jZ3u6Ij1rTF2CrGd2ZqzqyMQ/FwhdpvY=
gitlink.org.cn/jcce-pcm/utils v0.0.1 h1:3PH93Z/JFTH5JRO9MFf3dD1Gnd12aGiIIViWBlQGuhE=
gitlink.org.cn/jcce-pcm/utils v0.0.1/go.mod h1:5cwaaqM0+HK5GXVbYozGlWvgwoUby0KytdvhbwQW1ks=
gitlink.org.cn/jcce-pcm/utils v0.0.2 h1:Stif8W9C9TOCS2hw4g+OlOywDrsVYNrkiyKfBrWkT0w=
gitlink.org.cn/jcce-pcm/utils v0.0.2/go.mod h1:u8PTlBpzUyOlbQJgfSiutq91q/JtrJIQiPNDe4S/pGs=
go.etcd.io/etcd/api/v3 v3.5.5/go.mod h1:KFtNaxGDw4Yx/BA4iPPwevUTAuqcsPxzyX8PHydchN8=
go.etcd.io/etcd/api/v3 v3.5.7/go.mod h1:9qew1gCdDDLu+VwmeG+iFpL+QlpHTo7iubavdVDgCAA=
go.etcd.io/etcd/api/v3 v3.5.9 h1:4wSsluwyTbGGmyjJktOf3wFQoTBIURXHnq9n/G/JQHs=
@ -1790,8 +1794,8 @@ gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gorm.io/driver/mysql v1.5.1 h1:WUEH5VF9obL/lTtzjmML/5e6VfFR/788coz2uaVCAZw=
gorm.io/driver/mysql v1.5.1/go.mod h1:Jo3Xu7mMhCyj8dlrb3WoCaRd1FhsVh+yMXb1jUInf5o=
gorm.io/gorm v1.25.1/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k=
gorm.io/gorm v1.25.2 h1:gs1o6Vsa+oVKG/a9ElL3XgyGfghFfkKA2SInQaCyMho=
gorm.io/gorm v1.25.2/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k=
gorm.io/gorm v1.25.3 h1:zi4rHZj1anhZS2EuEODMhDisGy+Daq9jtPrNGgbQYD8=
gorm.io/gorm v1.25.3/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k=
gotest.tools/v3 v3.5.0 h1:Ljk6PdHdOhAb5aDMWXjDLMMhph+BpztA4v1QdqEW2eY=
gotest.tools/v3 v3.5.0/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=

View File

@ -19,6 +19,8 @@ type (
HpcInfo = pcmCore.HpcInfo
InfoListReq = pcmCore.InfoListReq
InfoListResp = pcmCore.InfoListResp
ListParticipantAvailResp = pcmCore.ListParticipantAvailResp
ListParticipantPhyResp = pcmCore.ListParticipantPhyResp
NodeAvailInfo = pcmCore.NodeAvailInfo
NodePhyInfo = pcmCore.NodePhyInfo
ParticipantAvailReq = pcmCore.ParticipantAvailReq
@ -38,6 +40,12 @@ type (
ReportHeartbeat(ctx context.Context, in *ParticipantHeartbeatReq, opts ...grpc.CallOption) (*HealthCheckResp, error)
// reportAvailable 监控数据上报
ReportAvailable(ctx context.Context, in *ParticipantAvailReq, opts ...grpc.CallOption) (*ParticipantResp, error)
// listParticipant 服务列表
ListParticipant(ctx context.Context, in *ParticipantTenant, opts ...grpc.CallOption) (*ParticipantResp, error)
// listAvailable 集群动态信息列表
ListPhyAvailable(ctx context.Context, in *ParticipantTenant, opts ...grpc.CallOption) (*ListParticipantAvailResp, error)
// listPhyInformation 集群静态信息列表
ListPhyInformation(ctx context.Context, in *ParticipantTenant, opts ...grpc.CallOption) (*ListParticipantPhyResp, error)
}
defaultParticipantService struct {
@ -68,3 +76,21 @@ func (m *defaultParticipantService) ReportAvailable(ctx context.Context, in *Par
client := pcmCore.NewParticipantServiceClient(m.cli.Conn())
return client.ReportAvailable(ctx, in, opts...)
}
// listParticipant 服务列表
func (m *defaultParticipantService) ListParticipant(ctx context.Context, in *ParticipantTenant, opts ...grpc.CallOption) (*ParticipantResp, error) {
client := pcmCore.NewParticipantServiceClient(m.cli.Conn())
return client.ListParticipant(ctx, in, opts...)
}
// listAvailable 集群动态信息列表
func (m *defaultParticipantService) ListPhyAvailable(ctx context.Context, in *ParticipantTenant, opts ...grpc.CallOption) (*ListParticipantAvailResp, error) {
client := pcmCore.NewParticipantServiceClient(m.cli.Conn())
return client.ListPhyAvailable(ctx, in, opts...)
}
// listPhyInformation 集群静态信息列表
func (m *defaultParticipantService) ListPhyInformation(ctx context.Context, in *ParticipantTenant, opts ...grpc.CallOption) (*ListParticipantPhyResp, error) {
client := pcmCore.NewParticipantServiceClient(m.cli.Conn())
return client.ListPhyInformation(ctx, in, opts...)
}

View File

@ -19,6 +19,8 @@ type (
HpcInfo = pcmCore.HpcInfo
InfoListReq = pcmCore.InfoListReq
InfoListResp = pcmCore.InfoListResp
ListParticipantAvailResp = pcmCore.ListParticipantAvailResp
ListParticipantPhyResp = pcmCore.ListParticipantPhyResp
NodeAvailInfo = pcmCore.NodeAvailInfo
NodePhyInfo = pcmCore.NodePhyInfo
ParticipantAvailReq = pcmCore.ParticipantAvailReq

View File

@ -2,6 +2,7 @@ package config
import (
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/core/stores/redis"
"github.com/zeromicro/go-zero/zrpc"
)
@ -12,6 +13,7 @@ type Config struct {
}
LogConf logx.LogConf
SnowflakeConf SnowflakeConf
RedisConf redis.RedisConf
}
// SnowflakeConf 雪花算法机器id配置

View File

@ -24,7 +24,7 @@ var (
)
func SendHeartbeat(host string, port string, participantID int64) {
key := fmt.Sprintf("%s:%d-%d", host, port, participantID)
key := fmt.Sprintf("%s:%s-%d", host, port, participantID)
clientsMutex.Lock()
defer clientsMutex.Unlock()
@ -57,3 +57,10 @@ func CheckHealth() {
}
}
}
// ClientList 列出监控的客户端列表
func ClientList() (Clients map[string]*Client) {
clientsMutex.Lock()
defer clientsMutex.Unlock()
return ParticipantClients
}

View File

@ -0,0 +1,33 @@
package participantservicelogic
import (
"context"
"fmt"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/rpc/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/rpc/pcmCore"
"github.com/zeromicro/go-zero/core/logx"
)
type ListParticipantLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewListParticipantLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListParticipantLogic {
return &ListParticipantLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// listParticipant 服务列表
func (l *ListParticipantLogic) ListParticipant(in *pcmCore.ParticipantTenant) (*pcmCore.ParticipantResp, error) {
// todo: add your logic here and delete this line
clients := ClientList()
fmt.Println(clients)
return &pcmCore.ParticipantResp{}, nil
}

View File

@ -0,0 +1,37 @@
package participantservicelogic
import (
"context"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/model"
"gitlink.org.cn/jcce-pcm/utils/tool"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/rpc/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/rpc/pcmCore"
"github.com/zeromicro/go-zero/core/logx"
)
type ListPhyAvailableLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewListPhyAvailableLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListPhyAvailableLogic {
return &ListPhyAvailableLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// listAvailable 集群动态信息列表
func (l *ListPhyAvailableLogic) ListPhyAvailable(in *pcmCore.ParticipantTenant) (*pcmCore.ListParticipantAvailResp, error) {
// todo: add your logic here and delete this line
resp := &pcmCore.ListParticipantAvailResp{}
var scParticipantPhyInfoS []model.ScParticipantAvailInfo
//查询集群静态信息列表
l.svcCtx.DbEngin.Find(&scParticipantPhyInfoS)
tool.Convert(scParticipantPhyInfoS, &resp.ParticipantAvails)
return resp, nil
}

View File

@ -0,0 +1,37 @@
package participantservicelogic
import (
"context"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/model"
"gitlink.org.cn/jcce-pcm/utils/tool"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/rpc/internal/svc"
"gitlink.org.cn/jcce-pcm/pcm-coordinator/rpc/pcmCore"
"github.com/zeromicro/go-zero/core/logx"
)
type ListPhyInformationLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewListPhyInformationLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListPhyInformationLogic {
return &ListPhyInformationLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// listPhyInformation 集群静态信息列表
func (l *ListPhyInformationLogic) ListPhyInformation(in *pcmCore.ParticipantTenant) (*pcmCore.ListParticipantPhyResp, error) {
// todo: add your logic here and delete this line
resp := &pcmCore.ListParticipantPhyResp{}
var scParticipantPhyInfoS []model.ScParticipantPhyInfo
//查询集群静态信息列表
l.svcCtx.DbEngin.Find(&scParticipantPhyInfoS)
tool.Convert(scParticipantPhyInfoS, &resp.ParticipantPhys)
return resp, nil
}

View File

@ -48,6 +48,12 @@ func (l *ReportAvailableLogic) ReportAvailable(in *pcmCore.ParticipantAvailReq)
//判断Participant静态信息是否存在
participantPhyInfo := &model.ScParticipantPhyInfo{}
participantPhyInfo.Id = in.ParticipantId
if in.ParticipantId == 0 {
return &pcmCore.ParticipantResp{
Code: 500,
Msg: fmt.Sprintf("ParticipantInfo Does not exist, please check participantPhyId: %d", in.ParticipantId),
}, nil
}
if errors.Is(db.Take(&participantPhyInfo).Error, gorm.ErrRecordNotFound) {
return &pcmCore.ParticipantResp{
Code: 500,

View File

@ -39,3 +39,21 @@ func (s *ParticipantServiceServer) ReportAvailable(ctx context.Context, in *pcmC
l := participantservicelogic.NewReportAvailableLogic(ctx, s.svcCtx)
return l.ReportAvailable(in)
}
// listParticipant 服务列表
func (s *ParticipantServiceServer) ListParticipant(ctx context.Context, in *pcmCore.ParticipantTenant) (*pcmCore.ParticipantResp, error) {
l := participantservicelogic.NewListParticipantLogic(ctx, s.svcCtx)
return l.ListParticipant(in)
}
// listAvailable 集群动态信息列表
func (s *ParticipantServiceServer) ListPhyAvailable(ctx context.Context, in *pcmCore.ParticipantTenant) (*pcmCore.ListParticipantAvailResp, error) {
l := participantservicelogic.NewListPhyAvailableLogic(ctx, s.svcCtx)
return l.ListPhyAvailable(in)
}
// listPhyInformation 集群静态信息列表
func (s *ParticipantServiceServer) ListPhyInformation(ctx context.Context, in *pcmCore.ParticipantTenant) (*pcmCore.ListParticipantPhyResp, error) {
l := participantservicelogic.NewListPhyInformationLogic(ctx, s.svcCtx)
return l.ListPhyInformation(in)
}

View File

@ -1,6 +1,7 @@
package svc
import (
"github.com/go-redis/redis/v8"
_ "github.com/go-sql-driver/mysql"
"github.com/robfig/cron/v3"
"github.com/zeromicro/go-zero/core/logx"
@ -16,6 +17,7 @@ type ServiceContext struct {
Config config.Config
DbEngin *gorm.DB
Cron *cron.Cron
RedisClient *redis.Client
}
func NewServiceContext(c config.Config) *ServiceContext {
@ -24,7 +26,7 @@ func NewServiceContext(c config.Config) *ServiceContext {
NamingStrategy: schema.NamingStrategy{
SingularTable: true, // 使用单数表名,启用该选项,此时,`User` 的表名应该是 `t_user`
},
Logger: logger.Default.LogMode(logger.Error),
Logger: logger.Default.LogMode(logger.Info),
})
//添加snowflake支持
err := tool.InitSnowflake(c.SnowflakeConf.MachineId)
@ -36,5 +38,10 @@ func NewServiceContext(c config.Config) *ServiceContext {
Cron: cron.New(cron.WithSeconds()),
Config: c,
DbEngin: dbEngin,
RedisClient: redis.NewClient(&redis.Options{
Addr: c.RedisConf.Host,
Password: c.RedisConf.Pass,
DB: 0, // use default DB
}),
}
}

View File

@ -124,6 +124,13 @@ message ParticipantPhyResp {
int64 participantId = 3; //participant
}
//
message ListParticipantPhyResp {
int64 code = 1;
string msg = 2;
repeated ParticipantPhyReq ParticipantPhys=3;
}
//participantPhy
message ParticipantPhyReq {
string name = 1; //
@ -141,6 +148,7 @@ message ParticipantPhyReq {
repeated NodePhyInfo nodeInfo = 13; //
int64 participantId = 14; //participant id
repeated ParticipantLabel labelInfo = 15; //
int64 id =16; //id
}
// NodePhyInfo
@ -187,6 +195,13 @@ message NodeAvailInfo{
int64 participantAvailId = 11; //id
}
//
message ListParticipantAvailResp{
int64 code = 1;
string msg = 2;
repeated ParticipantAvailReq ParticipantAvails=3;
}
message ParticipantResp{
int64 code = 1;
string msg = 2;
@ -204,4 +219,12 @@ service participantService {
// reportAvailable
rpc reportAvailable (ParticipantAvailReq) returns(ParticipantResp){}
// listParticipant
rpc listParticipant (ParticipantTenant) returns(ParticipantResp){}
// listAvailable
rpc listPhyAvailable (ParticipantTenant) returns(ListParticipantAvailResp){}
// listPhyInformation
rpc listPhyInformation (ParticipantTenant) returns (ListParticipantPhyResp) {};
}

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,8 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.3.0
// - protoc v3.19.4
// source: pcmCore.proto
// - protoc v4.23.4
// source: pb/pcmCore.proto
package pcmCore
@ -146,13 +146,16 @@ var PcmCore_ServiceDesc = grpc.ServiceDesc{
},
},
Streams: []grpc.StreamDesc{},
Metadata: "pcmCore.proto",
Metadata: "pb/pcmCore.proto",
}
const (
ParticipantService_RegisterParticipant_FullMethodName = "/pcmCore.participantService/registerParticipant"
ParticipantService_ReportHeartbeat_FullMethodName = "/pcmCore.participantService/reportHeartbeat"
ParticipantService_ReportAvailable_FullMethodName = "/pcmCore.participantService/reportAvailable"
ParticipantService_ListParticipant_FullMethodName = "/pcmCore.participantService/listParticipant"
ParticipantService_ListPhyAvailable_FullMethodName = "/pcmCore.participantService/listPhyAvailable"
ParticipantService_ListPhyInformation_FullMethodName = "/pcmCore.participantService/listPhyInformation"
)
// ParticipantServiceClient is the client API for ParticipantService service.
@ -165,6 +168,12 @@ type ParticipantServiceClient interface {
ReportHeartbeat(ctx context.Context, in *ParticipantHeartbeatReq, opts ...grpc.CallOption) (*HealthCheckResp, error)
// reportAvailable 监控数据上报
ReportAvailable(ctx context.Context, in *ParticipantAvailReq, opts ...grpc.CallOption) (*ParticipantResp, error)
// listParticipant 服务列表
ListParticipant(ctx context.Context, in *ParticipantTenant, opts ...grpc.CallOption) (*ParticipantResp, error)
// listAvailable 集群动态信息列表
ListPhyAvailable(ctx context.Context, in *ParticipantTenant, opts ...grpc.CallOption) (*ListParticipantAvailResp, error)
// listPhyInformation 集群静态信息列表
ListPhyInformation(ctx context.Context, in *ParticipantTenant, opts ...grpc.CallOption) (*ListParticipantPhyResp, error)
}
type participantServiceClient struct {
@ -202,6 +211,33 @@ func (c *participantServiceClient) ReportAvailable(ctx context.Context, in *Part
return out, nil
}
func (c *participantServiceClient) ListParticipant(ctx context.Context, in *ParticipantTenant, opts ...grpc.CallOption) (*ParticipantResp, error) {
out := new(ParticipantResp)
err := c.cc.Invoke(ctx, ParticipantService_ListParticipant_FullMethodName, in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *participantServiceClient) ListPhyAvailable(ctx context.Context, in *ParticipantTenant, opts ...grpc.CallOption) (*ListParticipantAvailResp, error) {
out := new(ListParticipantAvailResp)
err := c.cc.Invoke(ctx, ParticipantService_ListPhyAvailable_FullMethodName, in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *participantServiceClient) ListPhyInformation(ctx context.Context, in *ParticipantTenant, opts ...grpc.CallOption) (*ListParticipantPhyResp, error) {
out := new(ListParticipantPhyResp)
err := c.cc.Invoke(ctx, ParticipantService_ListPhyInformation_FullMethodName, in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// ParticipantServiceServer is the server API for ParticipantService service.
// All implementations must embed UnimplementedParticipantServiceServer
// for forward compatibility
@ -212,6 +248,12 @@ type ParticipantServiceServer interface {
ReportHeartbeat(context.Context, *ParticipantHeartbeatReq) (*HealthCheckResp, error)
// reportAvailable 监控数据上报
ReportAvailable(context.Context, *ParticipantAvailReq) (*ParticipantResp, error)
// listParticipant 服务列表
ListParticipant(context.Context, *ParticipantTenant) (*ParticipantResp, error)
// listAvailable 集群动态信息列表
ListPhyAvailable(context.Context, *ParticipantTenant) (*ListParticipantAvailResp, error)
// listPhyInformation 集群静态信息列表
ListPhyInformation(context.Context, *ParticipantTenant) (*ListParticipantPhyResp, error)
mustEmbedUnimplementedParticipantServiceServer()
}
@ -228,6 +270,15 @@ func (UnimplementedParticipantServiceServer) ReportHeartbeat(context.Context, *P
func (UnimplementedParticipantServiceServer) ReportAvailable(context.Context, *ParticipantAvailReq) (*ParticipantResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method ReportAvailable not implemented")
}
func (UnimplementedParticipantServiceServer) ListParticipant(context.Context, *ParticipantTenant) (*ParticipantResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method ListParticipant not implemented")
}
func (UnimplementedParticipantServiceServer) ListPhyAvailable(context.Context, *ParticipantTenant) (*ListParticipantAvailResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method ListPhyAvailable not implemented")
}
func (UnimplementedParticipantServiceServer) ListPhyInformation(context.Context, *ParticipantTenant) (*ListParticipantPhyResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method ListPhyInformation not implemented")
}
func (UnimplementedParticipantServiceServer) mustEmbedUnimplementedParticipantServiceServer() {}
// UnsafeParticipantServiceServer may be embedded to opt out of forward compatibility for this service.
@ -295,6 +346,60 @@ func _ParticipantService_ReportAvailable_Handler(srv interface{}, ctx context.Co
return interceptor(ctx, in, info, handler)
}
func _ParticipantService_ListParticipant_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ParticipantTenant)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ParticipantServiceServer).ListParticipant(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: ParticipantService_ListParticipant_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ParticipantServiceServer).ListParticipant(ctx, req.(*ParticipantTenant))
}
return interceptor(ctx, in, info, handler)
}
func _ParticipantService_ListPhyAvailable_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ParticipantTenant)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ParticipantServiceServer).ListPhyAvailable(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: ParticipantService_ListPhyAvailable_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ParticipantServiceServer).ListPhyAvailable(ctx, req.(*ParticipantTenant))
}
return interceptor(ctx, in, info, handler)
}
func _ParticipantService_ListPhyInformation_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ParticipantTenant)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ParticipantServiceServer).ListPhyInformation(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: ParticipantService_ListPhyInformation_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ParticipantServiceServer).ListPhyInformation(ctx, req.(*ParticipantTenant))
}
return interceptor(ctx, in, info, handler)
}
// ParticipantService_ServiceDesc is the grpc.ServiceDesc for ParticipantService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
@ -314,7 +419,19 @@ var ParticipantService_ServiceDesc = grpc.ServiceDesc{
MethodName: "reportAvailable",
Handler: _ParticipantService_ReportAvailable_Handler,
},
{
MethodName: "listParticipant",
Handler: _ParticipantService_ListParticipant_Handler,
},
{
MethodName: "listPhyAvailable",
Handler: _ParticipantService_ListPhyAvailable_Handler,
},
{
MethodName: "listPhyInformation",
Handler: _ParticipantService_ListPhyInformation_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "pcmCore.proto",
Metadata: "pb/pcmCore.proto",
}