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.

exec.go 493 B

12345678910111213141516171819202122232425
  1. package exec
  2. import (
  3. "gitlink.org.cn/cloudream/common/pkgs/types"
  4. "gitlink.org.cn/cloudream/common/utils/reflect2"
  5. "gitlink.org.cn/cloudream/common/utils/serder"
  6. )
  7. type PlanID string
  8. type Plan struct {
  9. ID PlanID `json:"id"`
  10. Ops []Op `json:"ops"`
  11. }
  12. var opUnion = serder.UseTypeUnionExternallyTagged(types.Ref(types.NewTypeUnion[Op]()))
  13. type Op interface {
  14. Execute(ctx *ExecContext, e *Executor) error
  15. String() string
  16. }
  17. func UseOp[T Op]() {
  18. opUnion.Add(reflect2.TypeOf[T]())
  19. }