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.

fromto.go 2.9 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. package ioswitchlrc
  2. import (
  3. "gitlink.org.cn/cloudream/common/pkgs/ioswitch/exec"
  4. "gitlink.org.cn/cloudream/common/utils/math2"
  5. clitypes "gitlink.org.cn/cloudream/jcs-pub/client/types"
  6. )
  7. type From interface {
  8. GetDataIndex() int
  9. }
  10. type To interface {
  11. // To所需要的文件流的范围。具体含义与DataIndex有关系:
  12. // 如果DataIndex == -1,则表示在整个文件的范围。
  13. // 如果DataIndex >= 0,则表示在文件的某个分片的范围。
  14. GetRange() math2.Range
  15. GetDataIndex() int
  16. }
  17. type FromDriver struct {
  18. Handle *exec.DriverWriteStream
  19. DataIndex int
  20. }
  21. func NewFromDriver(dataIndex int) (*FromDriver, *exec.DriverWriteStream) {
  22. handle := &exec.DriverWriteStream{
  23. RangeHint: &math2.Range{},
  24. }
  25. return &FromDriver{
  26. Handle: handle,
  27. DataIndex: dataIndex,
  28. }, handle
  29. }
  30. func (f *FromDriver) GetDataIndex() int {
  31. return f.DataIndex
  32. }
  33. type FromNode struct {
  34. FileHash clitypes.FileHash
  35. Space clitypes.UserSpaceDetail
  36. DataIndex int
  37. }
  38. func NewFromStorage(fileHash clitypes.FileHash, space clitypes.UserSpaceDetail, dataIndex int) *FromNode {
  39. return &FromNode{
  40. FileHash: fileHash,
  41. DataIndex: dataIndex,
  42. Space: space,
  43. }
  44. }
  45. func (f *FromNode) GetDataIndex() int {
  46. return f.DataIndex
  47. }
  48. type ToDriver struct {
  49. Handle *exec.DriverReadStream
  50. DataIndex int
  51. Range math2.Range
  52. }
  53. func NewToDriver(dataIndex int) (*ToDriver, *exec.DriverReadStream) {
  54. str := exec.DriverReadStream{}
  55. return &ToDriver{
  56. Handle: &str,
  57. DataIndex: dataIndex,
  58. }, &str
  59. }
  60. func NewToDriverWithRange(dataIndex int, rng math2.Range) (*ToDriver, *exec.DriverReadStream) {
  61. str := exec.DriverReadStream{}
  62. return &ToDriver{
  63. Handle: &str,
  64. DataIndex: dataIndex,
  65. Range: rng,
  66. }, &str
  67. }
  68. func (t *ToDriver) GetDataIndex() int {
  69. return t.DataIndex
  70. }
  71. func (t *ToDriver) GetRange() math2.Range {
  72. return t.Range
  73. }
  74. type ToNode struct {
  75. Space clitypes.UserSpaceDetail
  76. DataIndex int
  77. Range math2.Range
  78. FileHashStoreKey string
  79. }
  80. func NewToStorage(space clitypes.UserSpaceDetail, dataIndex int, fileHashStoreKey string) *ToNode {
  81. return &ToNode{
  82. Space: space,
  83. DataIndex: dataIndex,
  84. FileHashStoreKey: fileHashStoreKey,
  85. }
  86. }
  87. func NewToStorageWithRange(space clitypes.UserSpaceDetail, dataIndex int, fileHashStoreKey string, rng math2.Range) *ToNode {
  88. return &ToNode{
  89. Space: space,
  90. DataIndex: dataIndex,
  91. FileHashStoreKey: fileHashStoreKey,
  92. Range: rng,
  93. }
  94. }
  95. func (t *ToNode) GetDataIndex() int {
  96. return t.DataIndex
  97. }
  98. func (t *ToNode) GetRange() math2.Range {
  99. return t.Range
  100. }
  101. // type ToStorage struct {
  102. // Storage cdssdk.Storage
  103. // DataIndex int
  104. // }
  105. // func NewToStorage(storage cdssdk.Storage, dataIndex int) *ToStorage {
  106. // return &ToStorage{
  107. // Storage: storage,
  108. // DataIndex: dataIndex,
  109. // }
  110. // }
  111. // func (t *ToStorage) GetDataIndex() int {
  112. // return t.DataIndex
  113. // }

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