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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. GetShardStoreType() string
  10. // 输出调试用的字符串,不要包含敏感信息
  11. String() string
  12. }
  13. var _ = serder.UseTypeUnionInternallyTagged(types.Ref(types.NewTypeUnion[ShardStoreConfig](
  14. (*LocalShardStorage)(nil),
  15. (*S3ShardStorage)(nil),
  16. )), "type")
  17. type LocalShardStorage struct {
  18. serder.Metadata `union:"Local"`
  19. Type string `json:"type"`
  20. Root string `json:"root"`
  21. MaxSize int64 `json:"maxSize"`
  22. }
  23. func (s *LocalShardStorage) GetShardStoreType() string {
  24. return "Local"
  25. }
  26. func (s *LocalShardStorage) String() string {
  27. return fmt.Sprintf("Local[root=%s, maxSize=%d]", s.Root, s.MaxSize)
  28. }
  29. type S3ShardStorage struct {
  30. serder.Metadata `union:"S3"`
  31. Type string `json:"type"`
  32. Root string `json:"root"`
  33. }
  34. func (s *S3ShardStorage) GetShardStoreType() string {
  35. return "S3"
  36. }
  37. func (s *S3ShardStorage) String() string {
  38. return fmt.Sprintf("S3[root=%s]", s.Root)
  39. }