Micro-service for file storage and processing written in Go
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
683 B

  1. package pipelines
  2. import (
  3. "encoding/json"
  4. "errors"
  5. )
  6. type StepType int
  7. const (
  8. TypeResizeImageStep StepType = iota
  9. )
  10. type Step struct {
  11. Name string `json:"name" faker:"name"`
  12. Type StepType `json:"type" faker:"-"`
  13. Options json.RawMessage `json:"options"`
  14. }
  15. func (s Step) GetExecutable() (IExecutableStep, error) {
  16. switch s.GetType() {
  17. case TypeResizeImageStep:
  18. step := ResizeImageStep{}
  19. if err := json.Unmarshal(s.Options, &step.Options); err != nil {
  20. return nil, err
  21. }
  22. return step, nil
  23. }
  24. return nil, errors.New("invalid type")
  25. }
  26. func (s Step) GetType() StepType {
  27. return s.Type
  28. }
  29. func (s Step) GetName() string {
  30. return s.Name
  31. }