Skip to content

Commit

Permalink
Implement workflow count, temporarily remove workflow trace (#506)
Browse files Browse the repository at this point in the history
  • Loading branch information
cretz authored Mar 26, 2024
1 parent 02e0975 commit 04bd5e8
Show file tree
Hide file tree
Showing 12 changed files with 259 additions and 124 deletions.
4 changes: 2 additions & 2 deletions temporalcli/commands.activity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,13 @@ func (s *SharedServerSuite) TestActivity_Fail_InvalidDetail() {
// Test helpers

func (s *SharedServerSuite) waitActivityStarted() client.WorkflowRun {
s.Worker.OnDevActivity(func(ctx context.Context, a any) (any, error) {
s.Worker().OnDevActivity(func(ctx context.Context, a any) (any, error) {
time.Sleep(0xFFFF * time.Hour)
return nil, nil
})
run, err := s.Client.ExecuteWorkflow(
s.Context,
client.StartWorkflowOptions{TaskQueue: s.Worker.Options.TaskQueue},
client.StartWorkflowOptions{TaskQueue: s.Worker().Options.TaskQueue},
DevWorkflow,
"ignored",
)
Expand Down
30 changes: 7 additions & 23 deletions temporalcli/commands.gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -1624,7 +1624,6 @@ func NewTemporalWorkflowCommand(cctx *CommandContext, parent *TemporalCommand) *
s.Command.AddCommand(&NewTemporalWorkflowStackCommand(cctx, &s).Command)
s.Command.AddCommand(&NewTemporalWorkflowStartCommand(cctx, &s).Command)
s.Command.AddCommand(&NewTemporalWorkflowTerminateCommand(cctx, &s).Command)
s.Command.AddCommand(&NewTemporalWorkflowTraceCommand(cctx, &s).Command)
s.Command.AddCommand(&NewTemporalWorkflowUpdateCommand(cctx, &s).Command)
s.ClientOptions.buildFlags(cctx, s.Command.PersistentFlags())
return &s
Expand Down Expand Up @@ -1660,6 +1659,7 @@ func NewTemporalWorkflowCancelCommand(cctx *CommandContext, parent *TemporalWork
type TemporalWorkflowCountCommand struct {
Parent *TemporalWorkflowCommand
Command cobra.Command
Query string
}

func NewTemporalWorkflowCountCommand(cctx *CommandContext, parent *TemporalWorkflowCommand) *TemporalWorkflowCountCommand {
Expand All @@ -1668,8 +1668,13 @@ func NewTemporalWorkflowCountCommand(cctx *CommandContext, parent *TemporalWorkf
s.Command.DisableFlagsInUseLine = true
s.Command.Use = "count [flags]"
s.Command.Short = "Count Workflow Executions."
s.Command.Long = "TODO"
if hasHighlighting {
s.Command.Long = "The \x1b[1mtemporal workflow count\x1b[0m command returns a count of Workflow Executions.\n\nUse the options listed below to change the command's behavior."
} else {
s.Command.Long = "The `temporal workflow count` command returns a count of Workflow Executions.\n\nUse the options listed below to change the command's behavior."
}
s.Command.Args = cobra.NoArgs
s.Command.Flags().StringVarP(&s.Query, "query", "q", "", "Filter results using a SQL-like query.")
s.Command.Run = func(c *cobra.Command, args []string) {
if err := s.run(cctx, args); err != nil {
cctx.Options.Fail(err)
Expand Down Expand Up @@ -2147,27 +2152,6 @@ func NewTemporalWorkflowTerminateCommand(cctx *CommandContext, parent *TemporalW
return &s
}

type TemporalWorkflowTraceCommand struct {
Parent *TemporalWorkflowCommand
Command cobra.Command
}

func NewTemporalWorkflowTraceCommand(cctx *CommandContext, parent *TemporalWorkflowCommand) *TemporalWorkflowTraceCommand {
var s TemporalWorkflowTraceCommand
s.Parent = parent
s.Command.DisableFlagsInUseLine = true
s.Command.Use = "trace [flags]"
s.Command.Short = "Trace progress of a Workflow Execution and its children."
s.Command.Long = "TODO"
s.Command.Args = cobra.NoArgs
s.Command.Run = func(c *cobra.Command, args []string) {
if err := s.run(cctx, args); err != nil {
cctx.Options.Fail(err)
}
}
return &s
}

type TemporalWorkflowUpdateCommand struct {
Parent *TemporalWorkflowCommand
Command cobra.Command
Expand Down
4 changes: 2 additions & 2 deletions temporalcli/commands.schedule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
func (s *SharedServerSuite) createSchedule(args ...string) (schedId, schedWfId string, res *CommandResult) {
schedId = fmt.Sprintf("sched-%x", rand.Uint32())
schedWfId = fmt.Sprintf("my-wf-id-%x", rand.Uint32())
s.Worker.OnDevWorkflow(func(ctx workflow.Context, input any) (any, error) {
s.Worker().OnDevWorkflow(func(ctx workflow.Context, input any) (any, error) {
return nil, workflow.Sleep(ctx, 10*time.Second)
})
s.T().Cleanup(func() {
Expand All @@ -40,7 +40,7 @@ func (s *SharedServerSuite) createSchedule(args ...string) (schedId, schedWfId s
"schedule", "create",
"--address", s.Address(),
"-s", schedId,
"--task-queue", s.Worker.Options.TaskQueue,
"--task-queue", s.Worker().Options.TaskQueue,
"--type", "DevWorkflow",
"--workflow-id", schedWfId,
}, args...)...,
Expand Down
8 changes: 4 additions & 4 deletions temporalcli/commands.taskqueue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
func (s *SharedServerSuite) TestTaskQueue_Describe_Simple() {
// Wait until the poller appears
s.Eventually(func() bool {
desc, err := s.Client.DescribeTaskQueue(s.Context, s.Worker.Options.TaskQueue, enums.TASK_QUEUE_TYPE_WORKFLOW)
desc, err := s.Client.DescribeTaskQueue(s.Context, s.Worker().Options.TaskQueue, enums.TASK_QUEUE_TYPE_WORKFLOW)
s.NoError(err)
for _, poller := range desc.Pollers {
if poller.Identity == s.DevServer.Options.ClientOptions.Identity {
Expand All @@ -27,7 +27,7 @@ func (s *SharedServerSuite) TestTaskQueue_Describe_Simple() {
res := s.Execute(
"task-queue", "describe",
"--address", s.Address(),
"--task-queue", s.Worker.Options.TaskQueue,
"--task-queue", s.Worker().Options.TaskQueue,
)
s.NoError(res.Err)
// For text, just making sure our client identity is present is good enough
Expand All @@ -38,7 +38,7 @@ func (s *SharedServerSuite) TestTaskQueue_Describe_Simple() {
"task-queue", "describe",
"-o", "json",
"--address", s.Address(),
"--task-queue", s.Worker.Options.TaskQueue,
"--task-queue", s.Worker().Options.TaskQueue,
)
s.NoError(res.Err)
var jsonOut struct {
Expand All @@ -55,7 +55,7 @@ func (s *SharedServerSuite) TestTaskQueue_Describe_Simple() {
"task-queue", "describe",
"-o", "json",
"--address", s.Address(),
"--task-queue", s.Worker.Options.TaskQueue,
"--task-queue", s.Worker().Options.TaskQueue,
"--partitions", "10",
)
s.NoError(res.Err)
Expand Down
4 changes: 0 additions & 4 deletions temporalcli/commands.workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,6 @@ func (c *TemporalWorkflowTerminateCommand) run(cctx *CommandContext, _ []string)
return nil
}

func (*TemporalWorkflowTraceCommand) run(*CommandContext, []string) error {
return fmt.Errorf("TODO")
}

func (c *TemporalWorkflowUpdateCommand) run(cctx *CommandContext, args []string) error {
cl, err := c.Parent.ClientOptions.dialClient(cctx)
if err != nil {
Expand Down
Loading

0 comments on commit 04bd5e8

Please sign in to comment.