Files

48 lines
1.2 KiB
Go

package example
import (
"context"
"git.gorlug.de/code/ersteller/queue"
"git.gorlug.de/code/ersteller/schema/ent"
. "git.gorlug.de/code/ersteller/workflow"
)
func CreateExampleWorkflow(client *ent.Client) *Workflow {
lastStep := NewStep(&StepParams{
Name: "Last step",
Identifier: "last_step",
Description: "Last step",
Client: client,
MaxRetries: 3,
Handler: func(ctx context.Context, currentStep *Step, job queue.GeneralQueueJob) (queue.GeneralQueueHandlerResult, *Step, error) {
return queue.GeneralQueueHandlerResult{
ResultPayload: map[string]interface{}{
"lastStep": "hello",
},
}, nil, nil
},
})
firstStep := NewStep(&StepParams{
Name: "Initial step",
Identifier: "initial_step",
Description: "Initial step",
Client: client,
MaxRetries: 3,
Handler: func(ctx context.Context, currentStep *Step, job queue.GeneralQueueJob) (queue.GeneralQueueHandlerResult, *Step, error) {
return queue.GeneralQueueHandlerResult{
ResultPayload: map[string]interface{}{
"firstStep": "hello",
},
}, lastStep, nil
},
})
w := NewWorkflow("Example", "example", firstStep, []*Step{firstStep, lastStep})
return w
}
//type name struct {
//
//}