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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. (*SignalVar)(nil),
  21. (*StreamVar)(nil),
  22. )
  23. var _ = serder.UseTypeUnionExternallyTagged(&VarUnion)
  24. type StreamVar struct {
  25. ID VarID `json:"id"`
  26. Stream io.ReadCloser `json:"-"`
  27. }
  28. func (v *StreamVar) GetID() VarID {
  29. return v.ID
  30. }
  31. type IntVar struct {
  32. ID VarID `json:"id"`
  33. Value string `json:"value"`
  34. }
  35. func (v *IntVar) GetID() VarID {
  36. return v.ID
  37. }
  38. type StringVar struct {
  39. ID VarID `json:"id"`
  40. Value string `json:"value"`
  41. }
  42. func (v *StringVar) GetID() VarID {
  43. return v.ID
  44. }
  45. type SignalVar struct {
  46. ID VarID `json:"id"`
  47. }
  48. func (v *SignalVar) GetID() VarID {
  49. return v.ID
  50. }
  51. type Op interface {
  52. Execute(ctx context.Context, sw *Switch) error
  53. }

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