You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.0 KiB
Go
42 lines
1.0 KiB
Go
9 months ago
|
package commands
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"log"
|
||
|
|
||
|
grabber "git.cheetah.cat/archivinator-ng/workerclient/downloader"
|
||
|
"github.com/pborman/uuid"
|
||
|
"go.temporal.io/sdk/client"
|
||
|
)
|
||
|
|
||
|
type TestCommand struct {
|
||
|
//Token string `long:"token" description:"authenticate with this token"`
|
||
|
}
|
||
|
|
||
|
func (command *TestCommand) Execute(args []string) error {
|
||
|
//ctx := context.Background()
|
||
|
|
||
|
c, err := client.Dial(client.Options{
|
||
|
HostPort: "192.168.133.120:7233",
|
||
|
Namespace: "archivinator-ng",
|
||
|
})
|
||
|
if err != nil {
|
||
|
log.Fatalln("Unable to create client", err)
|
||
|
}
|
||
|
defer c.Close()
|
||
|
|
||
|
// This workflow ID can be user business logic identifier as well.
|
||
|
workflowID := "parent-workflow_" + uuid.New()
|
||
|
workflowOptions := client.StartWorkflowOptions{
|
||
|
ID: workflowID,
|
||
|
TaskQueue: "request-grabber",
|
||
|
}
|
||
|
|
||
|
we, err := c.ExecuteWorkflow(context.Background(), workflowOptions, grabber.SampleParentWorkflow)
|
||
|
if err != nil {
|
||
|
log.Fatalln("Unable to execute workflow", err)
|
||
|
}
|
||
|
log.Println("Started workflow", "WorkflowID", we.GetID(), "RunID", we.GetRunID())
|
||
|
return nil
|
||
|
}
|