You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

shard_storage.go 1.2 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package cdssdk
  2. import (
  3. "fmt"
  4. "gitlink.org.cn/cloudream/common/pkgs/types"
  5. "gitlink.org.cn/cloudream/common/utils/serder"
  6. )
  7. // 分片存储服务的配置数据
  8. type ShardStoreConfig interface {
  9. GetType() string
  10. // 输出调试用的字符串,不要包含敏感信息
  11. String() string
  12. }
  13. var _ = serder.UseTypeUnionInternallyTagged(types.Ref(types.NewTypeUnion[ShardStoreConfig](
  14. (*LocalShardStorage)(nil),
  15. )), "type")
  16. type ShardStorage struct {
  17. StorageID StorageID `json:"storageID" gorm:"column:StorageID; primaryKey"`
  18. // 完全管理此存储服务的Hub的ID
  19. MasterHub NodeID `json:"masterHub" gorm:"column:MasterHub; not null"`
  20. // Shard存储空间在存储服务的目录
  21. Root string `json:"root" gorm:"column:Root; not null"`
  22. // ShardStore配置数据
  23. Config ShardStoreConfig `json:"config" gorm:"column:Config; type:json; not null; serializer:union"`
  24. }
  25. type LocalShardStorage struct {
  26. serder.Metadata `union:"Local"`
  27. Root string `json:"root"`
  28. MaxSize int64 `json:"maxSize"`
  29. }
  30. func (s *LocalShardStorage) GetType() string {
  31. return "Local"
  32. }
  33. func (s *LocalShardStorage) String() string {
  34. return fmt.Sprintf("Local[root=%s, maxSize=%d]", s.Root, s.MaxSize)
  35. }