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.1 kB

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