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.

join.go 931 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package ops2
  2. import (
  3. "context"
  4. "io"
  5. "gitlink.org.cn/cloudream/common/pkgs/future"
  6. "gitlink.org.cn/cloudream/common/pkgs/ioswitch/exec"
  7. "gitlink.org.cn/cloudream/common/utils/io2"
  8. )
  9. func init() {
  10. // OpUnion.AddT((*Join)(nil))
  11. }
  12. type Join struct {
  13. Inputs []*exec.StreamVar `json:"inputs"`
  14. Output *exec.StreamVar `json:"output"`
  15. Length int64 `json:"length"`
  16. }
  17. func (o *Join) Execute(ctx context.Context, e *exec.Executor) error {
  18. err := exec.BindArrayVars(e, ctx, o.Inputs)
  19. if err != nil {
  20. return err
  21. }
  22. var strReaders []io.Reader
  23. for _, s := range o.Inputs {
  24. strReaders = append(strReaders, s.Stream)
  25. }
  26. defer func() {
  27. for _, str := range o.Inputs {
  28. str.Stream.Close()
  29. }
  30. }()
  31. fut := future.NewSetVoid()
  32. o.Output.Stream = io2.AfterReadClosedOnce(io2.Length(io2.Join(strReaders), o.Length), func(closer io.ReadCloser) {
  33. fut.SetVoid()
  34. })
  35. e.PutVars(o.Output)
  36. return fut.Wait(ctx)
  37. }

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