Browse Source

ShardStorage和SharedStorage合并到Storage中

gitlink
Sydonian 1 year ago
parent
commit
04a27ab8f3
3 changed files with 19 additions and 23 deletions
  1. +0
    -10
      sdks/storage/shard_storage.go
  2. +14
    -0
      sdks/storage/shared_storage.go
  3. +5
    -13
      sdks/storage/storage.go

+ 0
- 10
sdks/storage/shard_storage.go View File

@@ -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"`


+ 14
- 0
sdks/storage/shared_storage.go View File

@@ -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")

+ 5
- 13
sdks/storage/storage.go View File

@@ -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


Loading…
Cancel
Save