Create example workflow
This commit is contained in:
@@ -1,21 +1,44 @@
|
||||
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) {
|
||||
step := NewStep(&StepParams{
|
||||
Name: "Initial step",
|
||||
Identifier: "initial_step",
|
||||
Description: "Initial step",
|
||||
Client: client,
|
||||
MaxRetries: 3,
|
||||
Handler: ,
|
||||
|
||||
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
|
||||
},
|
||||
})
|
||||
//w := NewWorkflow("Example", "example")
|
||||
|
||||
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
|
||||
},
|
||||
})
|
||||
NewWorkflow("Example", "example", firstStep)
|
||||
}
|
||||
|
||||
//type name struct {
|
||||
|
||||
@@ -7,8 +7,10 @@ import (
|
||||
"time"
|
||||
|
||||
. "git.gorlug.de/code/ersteller"
|
||||
erstellerEnt "git.gorlug.de/code/ersteller/schema/ent"
|
||||
"git.gorlug.de/code/ersteller/starter/ent"
|
||||
"git.gorlug.de/code/ersteller/starter/env"
|
||||
"git.gorlug.de/code/ersteller/starter/example"
|
||||
"git.gorlug.de/code/ersteller/starter/routes"
|
||||
)
|
||||
|
||||
@@ -24,6 +26,21 @@ func main() {
|
||||
}
|
||||
log.Println("client", client)
|
||||
defer client.Close()
|
||||
err = client.Schema.Create(context.Background())
|
||||
if err != nil {
|
||||
log.Fatalf("failed creating schema resources: %v", err)
|
||||
}
|
||||
|
||||
entClient, err := erstellerEnt.Open("sqlite3", environment.DatabaseUrl)
|
||||
if err != nil {
|
||||
log.Fatalf("failed opening connection to sqlite: %v", err)
|
||||
}
|
||||
defer entClient.Close()
|
||||
err = entClient.Schema.Create(context.Background())
|
||||
if err != nil {
|
||||
log.Fatalf("failed creating schema resources: %v", err)
|
||||
}
|
||||
example.CreateExampleWorkflow(entClient)
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Minute*5)
|
||||
defer cancel()
|
||||
|
||||
Reference in New Issue
Block a user