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 491 B

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