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.

ioswitch.go 3.8 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. package hubrpc
  2. import (
  3. context "context"
  4. "io"
  5. "gitlink.org.cn/cloudream/jcs-pub/common/pkgs/ioswitch/exec"
  6. rpc "gitlink.org.cn/cloudream/jcs-pub/common/pkgs/rpc"
  7. )
  8. type IOSwitchSvc interface {
  9. ExecuteIOPlan(ctx context.Context, req *ExecuteIOPlan) (*ExecuteIOPlanResp, *rpc.CodeError)
  10. SendIOStream(ctx context.Context, req *SendIOStream) (*SendIOStreamResp, *rpc.CodeError)
  11. GetIOStream(ctx context.Context, req *GetIOStream) (*GetIOStreamResp, *rpc.CodeError)
  12. SendIOVar(ctx context.Context, req *SendIOVar) (*SendIOVarResp, *rpc.CodeError)
  13. GetIOVar(ctx context.Context, req *GetIOVar) (*GetIOVarResp, *rpc.CodeError)
  14. }
  15. // 执行IO计划
  16. type ExecuteIOPlan struct {
  17. Plan exec.Plan
  18. }
  19. type ExecuteIOPlanResp struct{}
  20. var _ = TokenAuth(Hub_ExecuteIOPlan_FullMethodName)
  21. func (c *Client) ExecuteIOPlan(ctx context.Context, req *ExecuteIOPlan) (*ExecuteIOPlanResp, *rpc.CodeError) {
  22. if c.fusedErr != nil {
  23. return nil, c.fusedErr
  24. }
  25. return rpc.UnaryClient[*ExecuteIOPlanResp](c.cli.ExecuteIOPlan, ctx, req)
  26. }
  27. func (s *Server) ExecuteIOPlan(ctx context.Context, req *rpc.Request) (*rpc.Response, error) {
  28. return rpc.UnaryServer(s.svrImpl.ExecuteIOPlan, ctx, req)
  29. }
  30. // 发送IO流
  31. type SendIOStream struct {
  32. PlanID exec.PlanID
  33. VarID exec.VarID
  34. Stream io.Reader `json:"-"`
  35. }
  36. func (s *SendIOStream) GetStream() io.Reader {
  37. return s.Stream
  38. }
  39. func (s *SendIOStream) SetStream(str io.Reader) {
  40. s.Stream = str
  41. }
  42. type SendIOStreamResp struct{}
  43. var _ = TokenAuth(Hub_SendIOStream_FullMethodName)
  44. func (c *Client) SendIOStream(ctx context.Context, req *SendIOStream) (*SendIOStreamResp, *rpc.CodeError) {
  45. if c.fusedErr != nil {
  46. return nil, c.fusedErr
  47. }
  48. return rpc.UploadStreamClient[*SendIOStreamResp](c.cli.SendIOStream, ctx, req)
  49. }
  50. func (s *Server) SendIOStream(req Hub_SendIOStreamServer) error {
  51. return rpc.UploadStreamServer(s.svrImpl.SendIOStream, req)
  52. }
  53. // 获取IO流
  54. type GetIOStream struct {
  55. PlanID exec.PlanID
  56. VarID exec.VarID
  57. SignalID exec.VarID
  58. Signal exec.VarValue
  59. }
  60. type GetIOStreamResp struct {
  61. Stream io.ReadCloser `json:"-"`
  62. }
  63. var _ = TokenAuth(Hub_GetIOStream_FullMethodName)
  64. func (r *GetIOStreamResp) GetStream() io.ReadCloser {
  65. return r.Stream
  66. }
  67. func (r *GetIOStreamResp) SetStream(str io.ReadCloser) {
  68. r.Stream = str
  69. }
  70. func (c *Client) GetIOStream(ctx context.Context, req *GetIOStream) (*GetIOStreamResp, *rpc.CodeError) {
  71. if c.fusedErr != nil {
  72. return nil, c.fusedErr
  73. }
  74. return rpc.DownloadStreamClient[*GetIOStreamResp](c.cli.GetIOStream, ctx, req)
  75. }
  76. func (s *Server) GetIOStream(req *rpc.Request, ret Hub_GetIOStreamServer) error {
  77. return rpc.DownloadStreamServer(s.svrImpl.GetIOStream, req, ret)
  78. }
  79. // 发送IO变量
  80. type SendIOVar struct {
  81. PlanID exec.PlanID
  82. VarID exec.VarID
  83. Value exec.VarValue
  84. }
  85. type SendIOVarResp struct{}
  86. var _ = TokenAuth(Hub_SendIOVar_FullMethodName)
  87. func (c *Client) SendIOVar(ctx context.Context, req *SendIOVar) (*SendIOVarResp, *rpc.CodeError) {
  88. if c.fusedErr != nil {
  89. return nil, c.fusedErr
  90. }
  91. return rpc.UnaryClient[*SendIOVarResp](c.cli.SendIOVar, ctx, req)
  92. }
  93. func (s *Server) SendIOVar(ctx context.Context, req *rpc.Request) (*rpc.Response, error) {
  94. return rpc.UnaryServer(s.svrImpl.SendIOVar, ctx, req)
  95. }
  96. // 获取IO变量
  97. type GetIOVar struct {
  98. PlanID exec.PlanID
  99. VarID exec.VarID
  100. SignalID exec.VarID
  101. Signal exec.VarValue
  102. }
  103. type GetIOVarResp struct {
  104. Value exec.VarValue
  105. }
  106. var _ = TokenAuth(Hub_GetIOVar_FullMethodName)
  107. func (c *Client) GetIOVar(ctx context.Context, req *GetIOVar) (*GetIOVarResp, *rpc.CodeError) {
  108. if c.fusedErr != nil {
  109. return nil, c.fusedErr
  110. }
  111. return rpc.UnaryClient[*GetIOVarResp](c.cli.GetIOVar, ctx, req)
  112. }
  113. func (s *Server) GetIOVar(ctx context.Context, req *rpc.Request) (*rpc.Response, error) {
  114. return rpc.UnaryServer(s.svrImpl.GetIOVar, ctx, req)
  115. }

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