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.

length.go 915 B

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package ops2
  2. import (
  3. "fmt"
  4. "io"
  5. "gitlink.org.cn/cloudream/common/pkgs/future"
  6. "gitlink.org.cn/cloudream/common/utils/io2"
  7. "gitlink.org.cn/cloudream/jcs-pub/common/pkgs/ioswitch/exec"
  8. )
  9. func init() {
  10. // OpUnion.AddT((*Length)(nil))
  11. }
  12. type Length struct {
  13. Input exec.VarID `json:"input"`
  14. Output exec.VarID `json:"output"`
  15. Length int64 `json:"length"`
  16. }
  17. func (o *Length) Execute(ctx *exec.ExecContext, e *exec.Executor) error {
  18. str, err := exec.BindVar[*exec.StreamValue](e, ctx.Context, o.Input)
  19. if err != nil {
  20. return err
  21. }
  22. defer str.Stream.Close()
  23. fut := future.NewSetVoid()
  24. e.PutVar(o.Output, &exec.StreamValue{
  25. Stream: io2.AfterReadClosedOnce(io2.Length(str.Stream, o.Length), func(closer io.ReadCloser) {
  26. fut.SetVoid()
  27. }),
  28. })
  29. return fut.Wait(ctx.Context)
  30. }
  31. func (o *Length) String() string {
  32. return fmt.Sprintf("Length(length=%v) %v->%v", o.Length, o.Input, o.Output)
  33. }

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