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.

cache.go 2.0 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. package coordinator
  2. import (
  3. "gitlink.org.cn/cloudream/common/pkgs/mq"
  4. cdssdk "gitlink.org.cn/cloudream/common/sdks/storage"
  5. )
  6. type CacheService interface {
  7. CachePackageMoved(msg *CachePackageMoved) (*CachePackageMovedResp, *mq.CodeMessage)
  8. GetPackageObjectCacheInfos(msg *GetPackageObjectCacheInfos) (*GetPackageObjectCacheInfosResp, *mq.CodeMessage)
  9. }
  10. // Package的Object移动到了节点的Cache中
  11. var _ = Register(Service.CachePackageMoved)
  12. type CachePackageMoved struct {
  13. mq.MessageBodyBase
  14. PackageID int64 `json:"packageID"`
  15. NodeID int64 `json:"nodeID"`
  16. FileHashes []string `json:"fileHashes"`
  17. }
  18. type CachePackageMovedResp struct {
  19. mq.MessageBodyBase
  20. }
  21. func NewCachePackageMoved(packageID int64, nodeID int64, fileHashes []string) *CachePackageMoved {
  22. return &CachePackageMoved{
  23. PackageID: packageID,
  24. NodeID: nodeID,
  25. FileHashes: fileHashes,
  26. }
  27. }
  28. func NewCachePackageMovedResp() *CachePackageMovedResp {
  29. return &CachePackageMovedResp{}
  30. }
  31. func (client *Client) CachePackageMoved(msg *CachePackageMoved) (*CachePackageMovedResp, error) {
  32. return mq.Request(Service.CachePackageMoved, client.rabbitCli, msg)
  33. }
  34. // 获取Package中所有Object的FileHash
  35. var _ = Register(Service.GetPackageObjectCacheInfos)
  36. type GetPackageObjectCacheInfos struct {
  37. mq.MessageBodyBase
  38. UserID int64 `json:"userID"`
  39. PackageID int64 `json:"packageID"`
  40. }
  41. type GetPackageObjectCacheInfosResp struct {
  42. mq.MessageBodyBase
  43. Infos []cdssdk.ObjectCacheInfo
  44. }
  45. func NewGetPackageObjectCacheInfos(userID int64, packageID int64) *GetPackageObjectCacheInfos {
  46. return &GetPackageObjectCacheInfos{
  47. UserID: userID,
  48. PackageID: packageID,
  49. }
  50. }
  51. func NewGetPackageObjectCacheInfosResp(infos []cdssdk.ObjectCacheInfo) *GetPackageObjectCacheInfosResp {
  52. return &GetPackageObjectCacheInfosResp{
  53. Infos: infos,
  54. }
  55. }
  56. func (client *Client) GetPackageObjectCacheInfos(msg *GetPackageObjectCacheInfos) (*GetPackageObjectCacheInfosResp, error) {
  57. return mq.Request(Service.GetPackageObjectCacheInfos, client.rabbitCli, msg)
  58. }

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