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

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