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.

storage.go 1.7 kB

1 year ago
1 year ago
1 year ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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 StorageAddress interface {
  9. GetType() string
  10. // 输出调试用的字符串,不要包含敏感信息
  11. String() string
  12. }
  13. var _ = serder.UseTypeUnionInternallyTagged(types.Ref(types.NewTypeUnion[StorageAddress](
  14. (*LocalStorageAddress)(nil),
  15. )), "type")
  16. type LocalStorageAddress struct {
  17. serder.Metadata `union:"Local"`
  18. }
  19. func (a *LocalStorageAddress) GetType() string {
  20. return "Local"
  21. }
  22. func (a *LocalStorageAddress) String() string {
  23. return "Local"
  24. }
  25. type Storage struct {
  26. StorageID StorageID `json:"storageID" gorm:"column:StorageID; primaryKey; autoIncrement;"`
  27. Name string `json:"name" gorm:"column:Name; not null"`
  28. // 完全管理此存储服务的Hub的ID
  29. MasterHub NodeID `json:"masterHub" gorm:"column:MasterHub; not null"`
  30. // 存储服务的地址,包含鉴权所需数据
  31. Address StorageAddress `json:"address" gorm:"column:Address; type:json; not null; serializer:union"`
  32. // 存储服务拥有的特别功能
  33. Features []StorageFeature `json:"features" gorm:"column:Features; type:json; serializer:union"`
  34. }
  35. func (s *Storage) String() string {
  36. return fmt.Sprintf("%v(%v)", s.Name, s.StorageID)
  37. }
  38. // 共享存储服务的配置数据
  39. type SharedStorage struct {
  40. StorageID StorageID `json:"storageID" gorm:"column:StorageID; primaryKey"`
  41. // 调度文件时保存文件的根路径
  42. LoadBase string `json:"loadBase" gorm:"column:LoadBase; not null"`
  43. // 回源数据时数据存放位置的根路径
  44. DataReturnBase string `json:"dataReturnBase" gorm:"column:DataReturnBase; not null"`
  45. }