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.

store.go 1.8 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. package ops
  2. import (
  3. "fmt"
  4. "gitlink.org.cn/cloudream/jcs-pub/common/pkgs/ioswitch/dag"
  5. "gitlink.org.cn/cloudream/jcs-pub/common/pkgs/ioswitch/exec"
  6. )
  7. type Store struct {
  8. Var exec.VarID
  9. Key string
  10. }
  11. func (o *Store) Execute(ctx *exec.ExecContext, e *exec.Executor) error {
  12. v, err := e.BindVar(ctx.Context, o.Var)
  13. if err != nil {
  14. return err
  15. }
  16. e.Store(o.Key, v)
  17. return nil
  18. }
  19. func (o *Store) String() string {
  20. return fmt.Sprintf("Store %v as \"%v\"", o.Var, o.Key)
  21. }
  22. type StoreConst struct {
  23. Key string
  24. Value exec.VarValue
  25. }
  26. func (o *StoreConst) Execute(ctx *exec.ExecContext, e *exec.Executor) error {
  27. e.Store(o.Key, o.Value)
  28. return nil
  29. }
  30. func (o *StoreConst) String() string {
  31. return fmt.Sprintf("StoreConst %v: %v", o.Key, o.Value)
  32. }
  33. type StoreNode struct {
  34. dag.NodeBase
  35. Key string
  36. }
  37. func (b *GraphNodeBuilder) NewStore() *StoreNode {
  38. node := &StoreNode{}
  39. b.AddNode(node)
  40. return node
  41. }
  42. func (t *StoreNode) Store(key string, v *dag.ValueVar) {
  43. t.Key = key
  44. t.InputValues().Init(1)
  45. v.To(t, 0)
  46. }
  47. func (t *StoreNode) GenerateOp() (exec.Op, error) {
  48. return &Store{
  49. Var: t.InputValues().Get(0).VarID,
  50. Key: t.Key,
  51. }, nil
  52. }
  53. // func (t *StoreType) String() string {
  54. // return fmt.Sprintf("Store[%s]%v%v", t.StoreKey, formatStreamIO(node), formatValueIO(node))
  55. // }
  56. type StoreConstNode struct {
  57. dag.NodeBase
  58. Key string
  59. Value exec.VarValue
  60. }
  61. func (b *GraphNodeBuilder) NewStoreConst(key string, value exec.VarValue) *StoreConstNode {
  62. node := &StoreConstNode{
  63. Key: key,
  64. Value: value,
  65. }
  66. b.AddNode(node)
  67. return node
  68. }
  69. func (t *StoreConstNode) GenerateOp() (exec.Op, error) {
  70. return &StoreConst{
  71. Key: t.Key,
  72. Value: t.Value,
  73. }, nil
  74. }
  75. // func (t *StoreConstType) String() string {
  76. // return fmt.Sprintf("StoreConst[%s]%v%v", t.StoreKey, formatStreamIO(node), formatValueIO(node))

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