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

1 year ago
1 year ago
1 year ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. Type string `json:"type"`
  19. }
  20. func (a *LocalStorageAddress) GetType() string {
  21. return "Local"
  22. }
  23. func (a *LocalStorageAddress) String() string {
  24. return "Local"
  25. }
  26. type Storage struct {
  27. StorageID StorageID `json:"storageID" gorm:"column:StorageID; primaryKey; type:bigint; autoIncrement;"`
  28. Name string `json:"name" gorm:"column:Name; type:varchar(256); not null"`
  29. // 完全管理此存储服务的Hub的ID
  30. MasterHub NodeID `json:"masterHub" gorm:"column:MasterHub; type:bigint; not null"`
  31. // 存储服务的地址,包含鉴权所需数据
  32. Address StorageAddress `json:"address" gorm:"column:Address; type:json; not null; serializer:union"`
  33. // 存储服务拥有的特别功能
  34. Features []StorageFeature `json:"features" gorm:"column:Features; type:json; serializer:union"`
  35. }
  36. func (Storage) TableName() string {
  37. return "Storage"
  38. }
  39. func (s *Storage) String() string {
  40. return fmt.Sprintf("%v(%v)", s.Name, s.StorageID)
  41. }
  42. // 共享存储服务的配置数据
  43. type SharedStorage struct {
  44. StorageID StorageID `json:"storageID" gorm:"column:StorageID; primaryKey; type:bigint"`
  45. // 调度文件时保存文件的根路径
  46. LoadBase string `json:"loadBase" gorm:"column:LoadBase; type:varchar(1024); not null"`
  47. // 回源数据时数据存放位置的根路径
  48. DataReturnBase string `json:"dataReturnBase" gorm:"column:DataReturnBase; type:varchar(1024); not null"`
  49. }
  50. func (SharedStorage) TableName() string {
  51. return "SharedStorage"
  52. }