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.

models.go 1.1 kB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package models
  2. /// TODO 将分散在各处的公共结构体定义集中到这里来
  3. type RedundancyData interface{}
  4. type RedundancyDataConst interface {
  5. RepRedundancyData | ECRedundancyData | RedundancyData
  6. }
  7. type RepRedundancyData struct {
  8. FileHash string `json:"fileHash"`
  9. }
  10. func NewRedundancyRepData(fileHash string) RepRedundancyData {
  11. return RepRedundancyData{
  12. FileHash: fileHash,
  13. }
  14. }
  15. type ECRedundancyData struct {
  16. Ec EC `json:"ec"`
  17. Blocks []ObjectBlock `json:"blocks"`
  18. }
  19. func NewRedundancyEcData(ec EC, blocks []ObjectBlock) ECRedundancyData {
  20. return ECRedundancyData{
  21. Ec: ec,
  22. Blocks: blocks,
  23. }
  24. }
  25. type EC struct {
  26. ID int `json:"id"`
  27. Name string `json:"name"`
  28. EcK int `json:"ecK"`
  29. EcN int `json:"ecN"`
  30. }
  31. type ObjectBlock struct {
  32. Index int `json:"index"`
  33. FileHash string `json:"fileHash"`
  34. }
  35. func NewObjectBlock(index int, fileHash string) ObjectBlock {
  36. return ObjectBlock{
  37. Index: index,
  38. FileHash: fileHash,
  39. }
  40. }
  41. func NewEc(id int, name string, ecK int, ecN int) EC {
  42. return EC{
  43. ID: id,
  44. Name: name,
  45. EcK: ecK,
  46. EcN: ecN,
  47. }
  48. }

本项目旨在将云际存储公共基础设施化,使个人及企业可低门槛使用高效的云际存储服务(安装开箱即用云际存储客户端即可,无需关注其他组件的部署),同时支持用户灵活便捷定制云际存储的功能细节。