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

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 []ObjectBlockData `json:"blocks"`
  18. }
  19. func NewRedundancyEcData(ec EC, blocks []ObjectBlockData) 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 ObjectBlockData struct {
  32. Index int `json:"index"`
  33. FileHash string `json:"fileHash"`
  34. NodeIDs []int64 `json:"nodeIDs"`
  35. }
  36. func NewObjectBlockData(index int, fileHash string, nodeIDs []int64) ObjectBlockData {
  37. return ObjectBlockData{
  38. Index: index,
  39. FileHash: fileHash,
  40. NodeIDs: nodeIDs,
  41. }
  42. }
  43. func NewEc(id int, name string, ecK int, ecN int) EC {
  44. return EC{
  45. ID: id,
  46. Name: name,
  47. EcK: ecK,
  48. EcN: ecN,
  49. }
  50. }
  51. type ObjectRepData struct {
  52. ObjectID int64 `json:"objectID"`
  53. FileHash string `json:"fileHash"`
  54. NodeIDs []int64 `json:"nodeIDs"`
  55. }
  56. func NewObjectRepData(objectID int64, fileHash string, nodeIDs []int64) ObjectRepData {
  57. return ObjectRepData{
  58. ObjectID: objectID,
  59. FileHash: fileHash,
  60. NodeIDs: nodeIDs,
  61. }
  62. }
  63. type ObjectECData struct {
  64. Blocks []ObjectBlockData `json:"blocks"`
  65. }
  66. func NewObjectECData(blocks []ObjectBlockData) ObjectECData {
  67. return ObjectECData{
  68. Blocks: blocks,
  69. }
  70. }
  71. type LocalMachineInfo struct {
  72. NodeID *int64 `json:"nodeID"`
  73. ExternalIP string `json:"externalIP"`
  74. LocalIP string `json:"localIP"`
  75. }

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