flow.go 962 B

123456789101112131415161718192021222324252627282930
  1. package flow
  2. import (
  3. "errors"
  4. "git.sxidc.com/go-tools/utils/pipeline/component"
  5. "git.sxidc.com/go-tools/utils/strutils"
  6. )
  7. type SubComponentBuildParams struct {
  8. Type string `mapstructure:"type" structs:"type"`
  9. Name string `mapstructure:"name" structs:"name"`
  10. BuildParams map[string]any `mapstructure:"build_params" structs:"build_params"`
  11. RunParams map[string]any `mapstructure:"run_params" structs:"run_params"`
  12. }
  13. func (params *SubComponentBuildParams) Check(parentNodeType string) error {
  14. if strutils.IsStringEmpty(params.Type) {
  15. return errors.New(parentNodeType + "没有传递子节点类型")
  16. }
  17. if strutils.IsStringEmpty(params.Name) {
  18. return errors.New(parentNodeType + "没有传递子节点名称")
  19. }
  20. return nil
  21. }
  22. func (params *SubComponentBuildParams) BuildComponent() (component.Component, error) {
  23. return component.BuildComponent(params.Type, params.Name, params.BuildParams, params.RunParams)
  24. }