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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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. Result exec.ExecutorResult
  21. }
  22. var _ = TokenAuth(Hub_ExecuteIOPlan_FullMethodName)
  23. func (c *Client) ExecuteIOPlan(ctx context.Context, req *ExecuteIOPlan) (*ExecuteIOPlanResp, *rpc.CodeError) {
  24. if c.fusedErr != nil {
  25. return nil, c.fusedErr
  26. }
  27. return rpc.UnaryClient[*ExecuteIOPlanResp](c.cli.ExecuteIOPlan, ctx, req)
  28. }
  29. func (s *Server) ExecuteIOPlan(ctx context.Context, req *rpc.Request) (*rpc.Response, error) {
  30. return rpc.UnaryServer(s.svrImpl.ExecuteIOPlan, ctx, req)
  31. }
  32. // 发送IO流
  33. type SendIOStream struct {
  34. PlanID exec.PlanID
  35. VarID exec.VarID
  36. Stream io.Reader `json:"-"`
  37. }
  38. func (s *SendIOStream) GetStream() io.Reader {
  39. return s.Stream
  40. }
  41. func (s *SendIOStream) SetStream(str io.Reader) {
  42. s.Stream = str
  43. }
  44. type SendIOStreamResp struct{}
  45. var _ = TokenAuth(Hub_SendIOStream_FullMethodName)
  46. func (c *Client) SendIOStream(ctx context.Context, req *SendIOStream) (*SendIOStreamResp, *rpc.CodeError) {
  47. if c.fusedErr != nil {
  48. return nil, c.fusedErr
  49. }
  50. return rpc.UploadStreamClient[*SendIOStreamResp](c.cli.SendIOStream, ctx, req)
  51. }
  52. func (s *Server) SendIOStream(req Hub_SendIOStreamServer) error {
  53. return rpc.UploadStreamServer(s.svrImpl.SendIOStream, req)
  54. }
  55. // 获取IO流
  56. type GetIOStream struct {
  57. PlanID exec.PlanID
  58. VarID exec.VarID
  59. SignalID exec.VarID
  60. Signal exec.VarValue
  61. }
  62. type GetIOStreamResp struct {
  63. Stream io.ReadCloser `json:"-"`
  64. }
  65. var _ = TokenAuth(Hub_GetIOStream_FullMethodName)
  66. func (r *GetIOStreamResp) GetStream() io.ReadCloser {
  67. return r.Stream
  68. }
  69. func (r *GetIOStreamResp) SetStream(str io.ReadCloser) {
  70. r.Stream = str
  71. }
  72. func (c *Client) GetIOStream(ctx context.Context, req *GetIOStream) (*GetIOStreamResp, *rpc.CodeError) {
  73. if c.fusedErr != nil {
  74. return nil, c.fusedErr
  75. }
  76. return rpc.DownloadStreamClient[*GetIOStreamResp](c.cli.GetIOStream, ctx, req)
  77. }
  78. func (s *Server) GetIOStream(req *rpc.Request, ret Hub_GetIOStreamServer) error {
  79. return rpc.DownloadStreamServer(s.svrImpl.GetIOStream, req, ret)
  80. }
  81. // 发送IO变量
  82. type SendIOVar struct {
  83. PlanID exec.PlanID
  84. VarID exec.VarID
  85. Value exec.VarValue
  86. }
  87. type SendIOVarResp struct{}
  88. var _ = TokenAuth(Hub_SendIOVar_FullMethodName)
  89. func (c *Client) SendIOVar(ctx context.Context, req *SendIOVar) (*SendIOVarResp, *rpc.CodeError) {
  90. if c.fusedErr != nil {
  91. return nil, c.fusedErr
  92. }
  93. return rpc.UnaryClient[*SendIOVarResp](c.cli.SendIOVar, ctx, req)
  94. }
  95. func (s *Server) SendIOVar(ctx context.Context, req *rpc.Request) (*rpc.Response, error) {
  96. return rpc.UnaryServer(s.svrImpl.SendIOVar, ctx, req)
  97. }
  98. // 获取IO变量
  99. type GetIOVar struct {
  100. PlanID exec.PlanID
  101. VarID exec.VarID
  102. SignalID exec.VarID
  103. Signal exec.VarValue
  104. }
  105. type GetIOVarResp struct {
  106. Value exec.VarValue
  107. }
  108. var _ = TokenAuth(Hub_GetIOVar_FullMethodName)
  109. func (c *Client) GetIOVar(ctx context.Context, req *GetIOVar) (*GetIOVarResp, *rpc.CodeError) {
  110. if c.fusedErr != nil {
  111. return nil, c.fusedErr
  112. }
  113. return rpc.UnaryClient[*GetIOVarResp](c.cli.GetIOVar, ctx, req)
  114. }
  115. func (s *Server) GetIOVar(ctx context.Context, req *rpc.Request) (*rpc.Response, error) {
  116. return rpc.UnaryServer(s.svrImpl.GetIOVar, ctx, req)
  117. }

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