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 1.0 kB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. package ioswitch
  2. import (
  3. "context"
  4. "io"
  5. "gitlink.org.cn/cloudream/common/pkgs/types"
  6. "gitlink.org.cn/cloudream/common/utils/serder"
  7. )
  8. type PlanID string
  9. type VarID int
  10. type Plan struct {
  11. ID PlanID `json:"id"`
  12. Ops []Op `json:"ops"`
  13. }
  14. type Var interface {
  15. GetID() VarID
  16. }
  17. var VarUnion = types.NewTypeUnion[Var](
  18. (*IntVar)(nil),
  19. (*StringVar)(nil),
  20. )
  21. var _ = serder.UseTypeUnionExternallyTagged(&VarUnion)
  22. type StreamVar struct {
  23. ID VarID `json:"id"`
  24. Stream io.ReadCloser `json:"-"`
  25. }
  26. func (v *StreamVar) GetID() VarID {
  27. return v.ID
  28. }
  29. type IntVar struct {
  30. ID VarID `json:"id"`
  31. Value string `json:"value"`
  32. }
  33. func (v *IntVar) GetID() VarID {
  34. return v.ID
  35. }
  36. type StringVar struct {
  37. ID VarID `json:"id"`
  38. Value string `json:"value"`
  39. }
  40. func (v *StringVar) GetID() VarID {
  41. return v.ID
  42. }
  43. type SignalVar struct {
  44. ID VarID `json:"id"`
  45. }
  46. func (v *SignalVar) GetID() VarID {
  47. return v.ID
  48. }
  49. type Op interface {
  50. Execute(ctx context.Context, sw *Switch) error
  51. }

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