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.
|
|
package pipelines
import ( "encoding/json" "errors" )
type StepType int
const ( TypeResizeImageStep StepType = iota TypeRotateImageStep TypeFlipImageStep TypeGrayscaleImageStep )
type Step struct { Name string `json:"name" faker:"name"` Type StepType `json:"type" faker:"-"` Options json.RawMessage `json:"options"` }
func (s Step) GetExecutable() (IExecutableStep, error) { switch s.GetType() {
case TypeResizeImageStep: step := ResizeImageStep{} if err := json.Unmarshal(s.Options, &step.Options); err != nil { return nil, err } return step, nil
case TypeRotateImageStep: step := RotateImageStep{} if err := json.Unmarshal(s.Options, &step.Options); err != nil { return nil, err } return step, nil
case TypeFlipImageStep: step := FlipImageStep{} if err := json.Unmarshal(s.Options, &step.Options); err != nil { return nil, err } return step, nil
case TypeGrayscaleImageStep: return GrayscaleImageStep{}, nil }
return nil, errors.New("invalid type") }
func (s Step) GetType() StepType { return s.Type }
func (s Step) GetName() string { return s.Name }
|