diff --git a/models/models.go b/models/models.go index 37aa7d5..9143280 100644 --- a/models/models.go +++ b/models/models.go @@ -2,9 +2,9 @@ package models /// TODO 将分散在各处的公共结构体定义集中到这里来 -type RedundancyDataTypes interface{} -type RedundancyDataTypesConst interface { - RepRedundancyData | ECRedundancyData +type RedundancyData interface{} +type RedundancyDataConst interface { + RepRedundancyData | ECRedundancyData | RedundancyData } type RepRedundancyData struct { FileHash string `json:"fileHash"` diff --git a/pkgs/mq/message/agent/storage.go b/pkgs/mq/message/agent/storage.go index 0629afa..51e46cf 100644 --- a/pkgs/mq/message/agent/storage.go +++ b/pkgs/mq/message/agent/storage.go @@ -8,15 +8,15 @@ import ( // 客户端发给代理端,告知要调度多副本冗余的数据,以及要调度数据的详情 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{ Directory: dir, ObjectID: objectID, diff --git a/pkgs/mq/message/coordinator/object.go b/pkgs/mq/message/coordinator/object.go index 8629d80..1f2c8ca 100644 --- a/pkgs/mq/message/coordinator/object.go +++ b/pkgs/mq/message/coordinator/object.go @@ -47,11 +47,11 @@ func NewPreDownloadObject(objectID int64, userID int64, clientExternalIP string) // 协调端告知客户端,待读取数据的元数据 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{ Redundancy: redundancy, FileSize: fileSize, diff --git a/pkgs/mq/message/coordinator/storage.go b/pkgs/mq/message/coordinator/storage.go index 809a312..aec452d 100644 --- a/pkgs/mq/message/coordinator/storage.go +++ b/pkgs/mq/message/coordinator/storage.go @@ -51,13 +51,13 @@ func NewPreMoveObjectToStorage(objectID int64, stgID int64, userID int64) PreMov // 协调端发给客户端,告知要调度数据的详情 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{ NodeID: nodeID, Directory: dir, diff --git a/pkgs/mq/message/publics.go b/pkgs/mq/message/publics.go index bfe2fd2..e2960a3 100644 --- a/pkgs/mq/message/publics.go +++ b/pkgs/mq/message/publics.go @@ -38,11 +38,11 @@ func NewRespNode(id int64, externalIP string, localIP string, isSameLocation boo } // Resp开头的RedundancyData与RedundancyData的区别在于,多了Nodes等字段。需要一个更好的名称。 -type RespRedundancyDataTypesConst interface { +type RespRedundancyDataConst interface { RespRepRedundancyData | RespEcRedundancyData } -type RespRedundancyDataTypes interface{} +type RespRedundancyData interface{} type RespRepRedundancyData struct { mymodels.RepRedundancyData @@ -105,9 +105,9 @@ func NewEc(id int, name string, k int, n int) Ec { } 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]()) }