Browse Source

优化数据结构名称

gitlink
Sydonian 2 years ago
parent
commit
21f42e5280
5 changed files with 23 additions and 23 deletions
  1. +3
    -3
      models/models.go
  2. +7
    -7
      pkgs/mq/message/agent/storage.go
  3. +3
    -3
      pkgs/mq/message/coordinator/object.go
  4. +5
    -5
      pkgs/mq/message/coordinator/storage.go
  5. +5
    -5
      pkgs/mq/message/publics.go

+ 3
- 3
models/models.go View File

@@ -2,9 +2,9 @@ package models


/// TODO 将分散在各处的公共结构体定义集中到这里来 /// TODO 将分散在各处的公共结构体定义集中到这里来


type RedundancyDataTypes interface{}
type RedundancyDataTypesConst interface {
RepRedundancyData | ECRedundancyData
type RedundancyData interface{}
type RedundancyDataConst interface {
RepRedundancyData | ECRedundancyData | RedundancyData
} }
type RepRedundancyData struct { type RepRedundancyData struct {
FileHash string `json:"fileHash"` FileHash string `json:"fileHash"`


+ 7
- 7
pkgs/mq/message/agent/storage.go View File

@@ -8,15 +8,15 @@ import (


// 客户端发给代理端,告知要调度多副本冗余的数据,以及要调度数据的详情 // 客户端发给代理端,告知要调度多副本冗余的数据,以及要调度数据的详情
type StartStorageMoveObject struct { type StartStorageMoveObject struct {
UserID int64 `json:"userID"`
ObjectID int64 `json:"objectID"`
ObjectName string `json:"objectName"`
Directory string `json:"directory"`
FileSize int64 `json:"fileSize,string"`
Redundancy models.RedundancyDataTypes `json:"redundancy"`
UserID int64 `json:"userID"`
ObjectID int64 `json:"objectID"`
ObjectName string `json:"objectName"`
Directory string `json:"directory"`
FileSize int64 `json:"fileSize,string"`
Redundancy models.RedundancyData `json:"redundancy"`
} }


func NewStartStorageMoveObject[T models.RedundancyDataTypes](dir string, objectID int64, objectName string, userID int64, fileSize int64, redundancy T) StartStorageMoveObject {
func NewStartStorageMoveObject[T models.RedundancyDataConst](dir string, objectID int64, objectName string, userID int64, fileSize int64, redundancy T) StartStorageMoveObject {
return StartStorageMoveObject{ return StartStorageMoveObject{
Directory: dir, Directory: dir,
ObjectID: objectID, ObjectID: objectID,


+ 3
- 3
pkgs/mq/message/coordinator/object.go View File

@@ -47,11 +47,11 @@ func NewPreDownloadObject(objectID int64, userID int64, clientExternalIP string)


// 协调端告知客户端,待读取数据的元数据 // 协调端告知客户端,待读取数据的元数据
type PreDownloadObjectResp struct { type PreDownloadObjectResp struct {
FileSize int64 `json:"fileSize,string"`
Redundancy ramsg.RespRedundancyDataTypes `json:"redundancy"`
FileSize int64 `json:"fileSize,string"`
Redundancy ramsg.RespRedundancyData `json:"redundancy"`
} }


func NewPreDownloadObjectResp[T ramsg.RespRedundancyDataTypesConst](fileSize int64, redundancy T) PreDownloadObjectResp {
func NewPreDownloadObjectResp[T ramsg.RespRedundancyDataConst](fileSize int64, redundancy T) PreDownloadObjectResp {
return PreDownloadObjectResp{ return PreDownloadObjectResp{
Redundancy: redundancy, Redundancy: redundancy,
FileSize: fileSize, FileSize: fileSize,


+ 5
- 5
pkgs/mq/message/coordinator/storage.go View File

@@ -51,13 +51,13 @@ func NewPreMoveObjectToStorage(objectID int64, stgID int64, userID int64) PreMov


// 协调端发给客户端,告知要调度数据的详情 // 协调端发给客户端,告知要调度数据的详情
type PreMoveObjectToStorageResp struct { type PreMoveObjectToStorageResp struct {
NodeID int64 `json:"nodeID"`
Directory string `json:"directory"`
Object model.Object `json:"object"`
Redundancy models.RedundancyDataTypes `json:"redundancy"`
NodeID int64 `json:"nodeID"`
Directory string `json:"directory"`
Object model.Object `json:"object"`
Redundancy models.RedundancyData `json:"redundancy"`
} }


func NewPreMoveObjectToStorageRespBody[T models.RedundancyDataTypes](nodeID int64, dir string, object model.Object, redundancy T) PreMoveObjectToStorageResp {
func NewPreMoveObjectToStorageRespBody[T models.RedundancyData](nodeID int64, dir string, object model.Object, redundancy T) PreMoveObjectToStorageResp {
return PreMoveObjectToStorageResp{ return PreMoveObjectToStorageResp{
NodeID: nodeID, NodeID: nodeID,
Directory: dir, Directory: dir,


+ 5
- 5
pkgs/mq/message/publics.go View File

@@ -38,11 +38,11 @@ func NewRespNode(id int64, externalIP string, localIP string, isSameLocation boo
} }


// Resp开头的RedundancyData与RedundancyData的区别在于,多了Nodes等字段。需要一个更好的名称。 // Resp开头的RedundancyData与RedundancyData的区别在于,多了Nodes等字段。需要一个更好的名称。
type RespRedundancyDataTypesConst interface {
type RespRedundancyDataConst interface {
RespRepRedundancyData | RespEcRedundancyData RespRepRedundancyData | RespEcRedundancyData
} }


type RespRedundancyDataTypes interface{}
type RespRedundancyData interface{}


type RespRepRedundancyData struct { type RespRepRedundancyData struct {
mymodels.RepRedundancyData mymodels.RepRedundancyData
@@ -105,9 +105,9 @@ func NewEc(id int, name string, k int, n int) Ec {
} }


func init() { func init() {
mq.RegisterTypeSet[models.RedundancyConfigTypes](myreflect.TypeOf[models.RepRedundancyConfig](), myreflect.TypeOf[models.ECRedundancyConfig]())
mq.RegisterTypeSet[models.RedundancyInfo](myreflect.TypeOf[models.RepRedundancyInfo](), myreflect.TypeOf[models.ECRedundancyInfo]())


mq.RegisterTypeSet[mymodels.RedundancyDataTypes](myreflect.TypeOf[mymodels.RepRedundancyData](), myreflect.TypeOf[mymodels.ECRedundancyData]())
mq.RegisterTypeSet[mymodels.RedundancyData](myreflect.TypeOf[mymodels.RepRedundancyData](), myreflect.TypeOf[mymodels.ECRedundancyData]())


mq.RegisterTypeSet[RespRedundancyDataTypes](myreflect.TypeOf[RespRepRedundancyData](), myreflect.TypeOf[RespEcRedundancyData]())
mq.RegisterTypeSet[RespRedundancyData](myreflect.TypeOf[RespRepRedundancyData](), myreflect.TypeOf[RespEcRedundancyData]())
} }

Loading…
Cancel
Save