| @@ -5,14 +5,10 @@ package model | |||
| import ( | |||
| "context" | |||
| "database/sql" | |||
| "fmt" | |||
| "strings" | |||
| "time" | |||
| "github.com/zeromicro/go-zero/core/stores/builder" | |||
| "github.com/zeromicro/go-zero/core/stores/cache" | |||
| "github.com/zeromicro/go-zero/core/stores/sqlc" | |||
| "github.com/zeromicro/go-zero/core/stores/sqlx" | |||
| "github.com/zeromicro/go-zero/core/stringx" | |||
| ) | |||
| @@ -39,74 +35,17 @@ type ( | |||
| } | |||
| ScParticipantPhyInfo struct { | |||
| Id int64 `db:"id"` // id | |||
| Name string `db:"name"` // 名称 | |||
| Address string `db:"address"` // 集群地址 | |||
| NetworkType string `db:"network_type"` // 集群网络类型 | |||
| NetworkBandwidth string `db:"network_bandwidth"` // 集群网络带宽 | |||
| StorageType string `db:"storage_type"` // 集群存储类型 | |||
| StorageSpace string `db:"storage_space"` // 集群存储空间 | |||
| StorageAvailSpace string `db:"storage_avail_space"` // 集群存储可用空间 | |||
| StorageBandwidth string `db:"storage_bandwidth"` // 集群存储带宽 | |||
| TenantId int64 `db:"tenant_id"` // 租户信息id | |||
| Type int64 `db:"type"` // 类型:0-数算集群;1-智算集群;2-超算集群 | |||
| DeletedFlag int64 `db:"deleted_flag"` // 是否删除 | |||
| CreatedBy sql.NullInt64 `db:"created_by"` // 创建人 | |||
| CreatedTime time.Time `db:"created_time"` // 创建时间 | |||
| UpdatedBy sql.NullInt64 `db:"updated_by"` // 更新人 | |||
| UpdatedTime sql.NullTime `db:"updated_time"` // 更新时间 | |||
| Id int64 `db:"id"` // id | |||
| Name string `db:"name"` // 名称 | |||
| Address string `db:"address"` // 集群地址 | |||
| MetricsUrl string `db:"metrics_url"` // 监控url | |||
| NetworkType string `db:"network_type"` // 集群网络类型 | |||
| NetworkBandwidth string `db:"network_bandwidth"` // 集群网络带宽 | |||
| StorageType string `db:"storage_type"` // 集群存储类型 | |||
| StorageSpace string `db:"storage_space"` // 集群存储空间 | |||
| StorageAvailSpace string `db:"storage_avail_space"` // 集群存储可用空间 | |||
| StorageBandwidth string `db:"storage_bandwidth"` // 集群存储带宽 | |||
| TenantId int64 `db:"tenant_id"` // 租户信息id | |||
| Type int64 `db:"type"` // 类型:0-数算集群;1-智算集群;2-超算集群 | |||
| } | |||
| ) | |||
| func newScParticipantPhyInfoModel(conn sqlx.SqlConn, c cache.CacheConf, opts ...cache.Option) *defaultScParticipantPhyInfoModel { | |||
| return &defaultScParticipantPhyInfoModel{ | |||
| CachedConn: sqlc.NewConn(conn, c, opts...), | |||
| table: "`sc_participant_phy_info`", | |||
| } | |||
| } | |||
| func (m *defaultScParticipantPhyInfoModel) withSession(session sqlx.Session) *defaultScParticipantPhyInfoModel { | |||
| return &defaultScParticipantPhyInfoModel{ | |||
| CachedConn: m.CachedConn.WithSession(session), | |||
| table: "`sc_participant_phy_info`", | |||
| } | |||
| } | |||
| func (m *defaultScParticipantPhyInfoModel) Delete(ctx context.Context, id int64) error { | |||
| pcmScParticipantPhyInfoIdKey := fmt.Sprintf("%s%v", cachePcmScParticipantPhyInfoIdPrefix, id) | |||
| _, err := m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) { | |||
| query := fmt.Sprintf("delete from %s where `id` = ?", m.table) | |||
| return conn.ExecCtx(ctx, query, id) | |||
| }, pcmScParticipantPhyInfoIdKey) | |||
| return err | |||
| } | |||
| func (m *defaultScParticipantPhyInfoModel) FindOne(ctx context.Context, id int64) (*ScParticipantPhyInfo, error) { | |||
| pcmScParticipantPhyInfoIdKey := fmt.Sprintf("%s%v", cachePcmScParticipantPhyInfoIdPrefix, id) | |||
| var resp ScParticipantPhyInfo | |||
| err := m.QueryRowCtx(ctx, &resp, pcmScParticipantPhyInfoIdKey, func(ctx context.Context, conn sqlx.SqlConn, v any) error { | |||
| query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", scParticipantPhyInfoRows, m.table) | |||
| return conn.QueryRowCtx(ctx, v, query, id) | |||
| }) | |||
| switch err { | |||
| case nil: | |||
| return &resp, nil | |||
| case sqlc.ErrNotFound: | |||
| return nil, ErrNotFound | |||
| default: | |||
| return nil, err | |||
| } | |||
| } | |||
| func (m *defaultScParticipantPhyInfoModel) formatPrimary(primary any) string { | |||
| return fmt.Sprintf("%s%v", cachePcmScParticipantPhyInfoIdPrefix, primary) | |||
| } | |||
| func (m *defaultScParticipantPhyInfoModel) queryPrimary(ctx context.Context, conn sqlx.SqlConn, v, primary any) error { | |||
| query := fmt.Sprintf("select %s from %s where `id` = ? limit 1", scParticipantPhyInfoRows, m.table) | |||
| return conn.QueryRowCtx(ctx, v, query, primary) | |||
| } | |||
| func (m *defaultScParticipantPhyInfoModel) tableName() string { | |||
| return m.table | |||
| } | |||
| @@ -52,7 +52,6 @@ func (l *RegisterParticipantLogic) RegisterParticipant(in *pcmCore.ParticipantPh | |||
| } else { | |||
| participantInfo.Id = in.ParticipantId | |||
| } | |||
| participantInfo.CreatedTime = time.Now() | |||
| //保存participant静态信息 | |||
| result := db.Save(&participantInfo) | |||
| //保存节点信息 | |||
| @@ -154,6 +154,7 @@ message ParticipantPhyReq { | |||
| repeated ParticipantLabel labelInfo = 15; // 标签信息 | |||
| repeated QueuePhyInfo queueInfo = 16; // 队列信息 | |||
| int64 id = 17; // id | |||
| string MetricsUrl = 18; //监控url | |||
| } | |||
| // NodePhyInfo 节点信息 | |||
| @@ -1,7 +1,7 @@ | |||
| // Code generated by protoc-gen-go. DO NOT EDIT. | |||
| // versions: | |||
| // protoc-gen-go v1.30.0 | |||
| // protoc v4.23.4 | |||
| // protoc v3.19.4 | |||
| // source: pb/pcmCore.proto | |||
| package pcmCore | |||
| @@ -1186,6 +1186,7 @@ type ParticipantPhyReq struct { | |||
| LabelInfo []*ParticipantLabel `protobuf:"bytes,15,rep,name=labelInfo,proto3" json:"labelInfo,omitempty"` // 标签信息 | |||
| QueueInfo []*QueuePhyInfo `protobuf:"bytes,16,rep,name=queueInfo,proto3" json:"queueInfo,omitempty"` // 队列信息 | |||
| Id int64 `protobuf:"varint,17,opt,name=id,proto3" json:"id,omitempty"` // id | |||
| MetricsUrl string `protobuf:"bytes,18,opt,name=MetricsUrl,proto3" json:"MetricsUrl,omitempty"` //监控url | |||
| } | |||
| func (x *ParticipantPhyReq) Reset() { | |||
| @@ -1332,6 +1333,13 @@ func (x *ParticipantPhyReq) GetId() int64 { | |||
| return 0 | |||
| } | |||
| func (x *ParticipantPhyReq) GetMetricsUrl() string { | |||
| if x != nil { | |||
| return x.MetricsUrl | |||
| } | |||
| return "" | |||
| } | |||
| // NodePhyInfo 节点信息 | |||
| type NodePhyInfo struct { | |||
| state protoimpl.MessageState | |||
| @@ -2095,10 +2103,10 @@ type ClientInfo struct { | |||
| sizeCache protoimpl.SizeCache | |||
| unknownFields protoimpl.UnknownFields | |||
| Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty" redis:"address"` | |||
| ParticipantId int64 `protobuf:"varint,2,opt,name=participantId,proto3" json:"participantId,omitempty" redis:"participantId"` | |||
| ClientState string `protobuf:"bytes,3,opt,name=clientState,proto3" json:"clientState,omitempty" redis:"clientState"` | |||
| LastHeartbeat int64 `protobuf:"varint,4,opt,name=lastHeartbeat,proto3" json:"lastHeartbeat,omitempty" redis:"lastHeartbeat"` | |||
| Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` // @gotags: redis:"address" | |||
| ParticipantId int64 `protobuf:"varint,2,opt,name=participantId,proto3" json:"participantId,omitempty"` // @gotags: redis:"participantId" | |||
| ClientState string `protobuf:"bytes,3,opt,name=clientState,proto3" json:"clientState,omitempty"` // @gotags: redis:"clientState" | |||
| LastHeartbeat int64 `protobuf:"varint,4,opt,name=lastHeartbeat,proto3" json:"lastHeartbeat,omitempty"` // @gotags: redis:"lastHeartbeat" | |||
| } | |||
| func (x *ClientInfo) Reset() { | |||
| @@ -2513,7 +2521,7 @@ var file_pb_pcmCore_proto_rawDesc = []byte{ | |||
| 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x70, 0x63, 0x6d, 0x43, 0x6f, 0x72, | |||
| 0x65, 0x2e, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, 0x50, 0x68, 0x79, | |||
| 0x52, 0x65, 0x71, 0x52, 0x0f, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, 0x70, 0x61, 0x6e, 0x74, | |||
| 0x50, 0x68, 0x79, 0x73, 0x22, 0xd5, 0x04, 0x0a, 0x11, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, | |||
| 0x50, 0x68, 0x79, 0x73, 0x22, 0xf5, 0x04, 0x0a, 0x11, 0x50, 0x61, 0x72, 0x74, 0x69, 0x63, 0x69, | |||
| 0x70, 0x61, 0x6e, 0x74, 0x50, 0x68, 0x79, 0x52, 0x65, 0x71, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, | |||
| 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x18, | |||
| 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, | |||
| @@ -2550,7 +2558,9 @@ var file_pb_pcmCore_proto_rawDesc = []byte{ | |||
| 0x49, 0x6e, 0x66, 0x6f, 0x18, 0x10, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x70, 0x63, 0x6d, | |||
| 0x43, 0x6f, 0x72, 0x65, 0x2e, 0x51, 0x75, 0x65, 0x75, 0x65, 0x50, 0x68, 0x79, 0x49, 0x6e, 0x66, | |||
| 0x6f, 0x52, 0x09, 0x71, 0x75, 0x65, 0x75, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x0e, 0x0a, 0x02, | |||
| 0x69, 0x64, 0x18, 0x11, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x22, 0xc3, 0x01, 0x0a, | |||
| 0x69, 0x64, 0x18, 0x11, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1e, 0x0a, 0x0a, | |||
| 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x55, 0x72, 0x6c, 0x18, 0x12, 0x20, 0x01, 0x28, 0x09, | |||
| 0x52, 0x0a, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x55, 0x72, 0x6c, 0x22, 0xc3, 0x01, 0x0a, | |||
| 0x0b, 0x4e, 0x6f, 0x64, 0x65, 0x50, 0x68, 0x79, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x0e, 0x0a, 0x02, | |||
| 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, | |||
| 0x6e, 0x6f, 0x64, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, | |||
| @@ -1,7 +1,7 @@ | |||
| // Code generated by protoc-gen-go-grpc. DO NOT EDIT. | |||
| // versions: | |||
| // - protoc-gen-go-grpc v1.3.0 | |||
| // - protoc v4.23.4 | |||
| // - protoc v3.19.4 | |||
| // source: pb/pcmCore.proto | |||
| package pcmCore | |||