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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. package models
  2. /// TODO 将分散在各处的公共结构体定义集中到这里来
  3. const (
  4. RedundancyRep = "rep"
  5. RedundancyEC = "ec"
  6. )
  7. type RedundancyConfigTypes interface{}
  8. type RedundancyConfigTypesConst interface {
  9. RepRedundancyConfig | ECRedundancyConfig
  10. }
  11. type RepRedundancyConfig struct {
  12. RepCount int `json:"repCount"`
  13. }
  14. type ECRedundancyConfig struct {
  15. }
  16. type RedundancyDataTypes interface{}
  17. type RedundancyDataTypesConst interface {
  18. RepRedundancyData | ECRedundancyData
  19. }
  20. type RepRedundancyData struct {
  21. FileHash string `json:"fileHash"`
  22. }
  23. func NewRedundancyRepData(fileHash string) RepRedundancyData {
  24. return RepRedundancyData{
  25. FileHash: fileHash,
  26. }
  27. }
  28. type ECRedundancyData struct {
  29. Blocks []ObjectBlock `json:"blocks"`
  30. }
  31. func NewECRedundancyData(blocks []ObjectBlock) ECRedundancyData {
  32. return ECRedundancyData{
  33. Blocks: blocks,
  34. }
  35. }
  36. type ObjectBlock struct {
  37. Index int `json:"index"`
  38. FileHash string `json:"fileHash"`
  39. }
  40. func NewObjectBlock(index int, fileHash string) ObjectBlock {
  41. return ObjectBlock{
  42. Index: index,
  43. FileHash: fileHash,
  44. }
  45. }

公共库