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

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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; type:bigint"`
  18. // Shard存储空间在存储服务的目录
  19. Root string `json:"root" gorm:"column:Root; type:varchar(1024); not null"`
  20. // ShardStore配置数据
  21. Config ShardStoreConfig `json:"config" gorm:"column:Config; type:json; not null; serializer:union"`
  22. }
  23. func (ShardStorage) TableName() string {
  24. return "ShardStorage"
  25. }
  26. type LocalShardStorage struct {
  27. serder.Metadata `union:"Local"`
  28. Root string `json:"root"`
  29. MaxSize int64 `json:"maxSize"`
  30. }
  31. func (s *LocalShardStorage) GetType() string {
  32. return "Local"
  33. }
  34. func (s *LocalShardStorage) String() string {
  35. return fmt.Sprintf("Local[root=%s, maxSize=%d]", s.Root, s.MaxSize)
  36. }