diff --git a/sdks/storage/shard_storage.go b/sdks/storage/shard_storage.go index 1c5dab0..1aeba6e 100644 --- a/sdks/storage/shard_storage.go +++ b/sdks/storage/shard_storage.go @@ -18,16 +18,6 @@ var _ = serder.UseTypeUnionInternallyTagged(types.Ref(types.NewTypeUnion[ShardSt (*LocalShardStorage)(nil), )), "type") -type ShardStorage struct { - StorageID StorageID `json:"storageID" gorm:"column:StorageID; primaryKey; type:bigint"` - // ShardStore配置数据 - Config ShardStoreConfig `json:"config" gorm:"column:Config; type:json; not null; serializer:union"` -} - -func (ShardStorage) TableName() string { - return "ShardStorage" -} - type LocalShardStorage struct { serder.Metadata `union:"Local"` Type string `json:"type"` diff --git a/sdks/storage/shared_storage.go b/sdks/storage/shared_storage.go new file mode 100644 index 0000000..ec1c67c --- /dev/null +++ b/sdks/storage/shared_storage.go @@ -0,0 +1,14 @@ +package cdssdk + +import ( + "gitlink.org.cn/cloudream/common/pkgs/types" + "gitlink.org.cn/cloudream/common/utils/serder" +) + +type SharedStoreConfig interface { + GetType() string + // 输出调试用的字符串,不要包含敏感信息 + String() string +} + +var _ = serder.UseTypeUnionInternallyTagged(types.Ref(types.NewTypeUnion[SharedStoreConfig]()), "type") diff --git a/sdks/storage/storage.go b/sdks/storage/storage.go index b90f810..cd20b86 100644 --- a/sdks/storage/storage.go +++ b/sdks/storage/storage.go @@ -14,6 +14,11 @@ type Storage struct { MasterHub HubID `json:"masterHub" gorm:"column:MasterHub; type:bigint; not null"` // 存储服务的地址,包含鉴权所需数据 Address StorageAddress `json:"address" gorm:"column:Address; type:json; not null; serializer:union"` + // 分片存储服务的配置数据 + ShardStore ShardStoreConfig `json:"shardStore" gorm:"column:ShardStore; type:json; serializer:union"` + // 共享存储服务的配置数据 + SharedStore SharedStoreConfig `json:"sharedStore" gorm:"column:SharedStore; type:json; serializer:union"` + // SharedStore // 存储服务拥有的特别功能 Features []StorageFeature `json:"features" gorm:"column:Features; type:json; serializer:union"` } @@ -26,19 +31,6 @@ func (s *Storage) String() string { return fmt.Sprintf("%v(%v)", s.Name, s.StorageID) } -// 共享存储服务的配置数据 -type SharedStorage struct { - StorageID StorageID `json:"storageID" gorm:"column:StorageID; primaryKey; type:bigint"` - // 调度文件时保存文件的根路径 - LoadBase string `json:"loadBase" gorm:"column:LoadBase; type:varchar(1024); not null"` - // 回源数据时数据存放位置的根路径 - DataReturnBase string `json:"dataReturnBase" gorm:"column:DataReturnBase; type:varchar(1024); not null"` -} - -func (SharedStorage) TableName() string { - return "SharedStorage" -} - // 存储服务地址 type StorageAddress interface { GetType() string