diff --git a/temporalcli/commands.activity_test.go b/temporalcli/commands.activity_test.go index d747092a..c5c11da6 100644 --- a/temporalcli/commands.activity_test.go +++ b/temporalcli/commands.activity_test.go @@ -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", ) diff --git a/temporalcli/commands.gen.go b/temporalcli/commands.gen.go index 0546d37e..ee0370bc 100644 --- a/temporalcli/commands.gen.go +++ b/temporalcli/commands.gen.go @@ -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 @@ -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 { @@ -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) @@ -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 diff --git a/temporalcli/commands.schedule_test.go b/temporalcli/commands.schedule_test.go index af88e29a..591622a9 100644 --- a/temporalcli/commands.schedule_test.go +++ b/temporalcli/commands.schedule_test.go @@ -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() { @@ -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...)..., diff --git a/temporalcli/commands.taskqueue_test.go b/temporalcli/commands.taskqueue_test.go index 3bc9ef8c..f85277c9 100644 --- a/temporalcli/commands.taskqueue_test.go +++ b/temporalcli/commands.taskqueue_test.go @@ -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 { @@ -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 @@ -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 { @@ -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) diff --git a/temporalcli/commands.workflow.go b/temporalcli/commands.workflow.go index 4bd5f7b4..c4b6922d 100644 --- a/temporalcli/commands.workflow.go +++ b/temporalcli/commands.workflow.go @@ -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 { diff --git a/temporalcli/commands.workflow_exec_test.go b/temporalcli/commands.workflow_exec_test.go index f76301d1..d0fd4043 100644 --- a/temporalcli/commands.workflow_exec_test.go +++ b/temporalcli/commands.workflow_exec_test.go @@ -30,13 +30,13 @@ import ( func (s *SharedServerSuite) TestWorkflow_Start_SimpleSuccess() { // Text - s.Worker.OnDevWorkflow(func(ctx workflow.Context, input any) (any, error) { + s.Worker().OnDevWorkflow(func(ctx workflow.Context, input any) (any, error) { return map[string]string{"foo": "bar"}, nil }) res := s.Execute( "workflow", "start", "--address", s.Address(), - "--task-queue", s.Worker.Options.TaskQueue, + "--task-queue", s.Worker().Options.TaskQueue, "--type", "DevWorkflow", "--workflow-id", "my-id1", ) @@ -45,7 +45,7 @@ func (s *SharedServerSuite) TestWorkflow_Start_SimpleSuccess() { out := res.Stdout.String() s.ContainsOnSameLine(out, "WorkflowId", "my-id1") s.Contains(out, "RunId") - s.ContainsOnSameLine(out, "TaskQueue", s.Worker.Options.TaskQueue) + s.ContainsOnSameLine(out, "TaskQueue", s.Worker().Options.TaskQueue) s.ContainsOnSameLine(out, "Type", "DevWorkflow") s.ContainsOnSameLine(out, "Namespace", "default") @@ -54,7 +54,7 @@ func (s *SharedServerSuite) TestWorkflow_Start_SimpleSuccess() { "workflow", "start", "-o", "json", "--address", s.Address(), - "--task-queue", s.Worker.Options.TaskQueue, + "--task-queue", s.Worker().Options.TaskQueue, "--type", "DevWorkflow", "--workflow-id", "my-id2", ) @@ -63,7 +63,7 @@ func (s *SharedServerSuite) TestWorkflow_Start_SimpleSuccess() { s.NoError(json.Unmarshal(res.Stdout.Bytes(), &jsonOut)) s.Equal("my-id2", jsonOut["workflowId"]) s.NotEmpty(jsonOut["runId"]) - s.Equal(s.Worker.Options.TaskQueue, jsonOut["taskQueue"]) + s.Equal(s.Worker().Options.TaskQueue, jsonOut["taskQueue"]) s.Equal("DevWorkflow", jsonOut["type"]) s.Equal("default", jsonOut["namespace"]) } @@ -89,7 +89,7 @@ func (s *SharedServerSuite) TestWorkflow_Start_StartDelay() { res := s.Execute( "workflow", "start", "--address", s.Address(), - "--task-queue", s.Worker.Options.TaskQueue, + "--task-queue", s.Worker().Options.TaskQueue, "--type", "DevWorkflow", "--workflow-id", "my-id1", "-i", `["val1", "val2"]`, @@ -104,13 +104,13 @@ func (s *SharedServerSuite) TestWorkflow_Start_StartDelay() { func (s *SharedServerSuite) TestWorkflow_Execute_SimpleSuccess() { // Text - s.Worker.OnDevWorkflow(func(ctx workflow.Context, input any) (any, error) { + s.Worker().OnDevWorkflow(func(ctx workflow.Context, input any) (any, error) { return map[string]string{"foo": "bar"}, nil }) res := s.Execute( "workflow", "execute", "--address", s.Address(), - "--task-queue", s.Worker.Options.TaskQueue, + "--task-queue", s.Worker().Options.TaskQueue, "--type", "DevWorkflow", "--workflow-id", "my-id1", "-i", `["val1", "val2"]`, @@ -119,7 +119,7 @@ func (s *SharedServerSuite) TestWorkflow_Execute_SimpleSuccess() { out := res.Stdout.String() // Confirm running (most of this check is done on start test) s.ContainsOnSameLine(out, "WorkflowId", "my-id1") - s.Equal([]any{"val1", "val2"}, s.Worker.DevWorkflowLastInput()) + s.Equal([]any{"val1", "val2"}, s.Worker().DevWorkflowLastInput()) // Confirm we have some events s.ContainsOnSameLine(out, "1", "WorkflowExecutionStarted") s.ContainsOnSameLine(out, "2", "WorkflowTaskScheduled") @@ -134,7 +134,7 @@ func (s *SharedServerSuite) TestWorkflow_Execute_SimpleSuccess() { "workflow", "execute", "-o", "json", "--address", s.Address(), - "--task-queue", s.Worker.Options.TaskQueue, + "--task-queue", s.Worker().Options.TaskQueue, "--type", "DevWorkflow", "--workflow-id", "my-id2", ) @@ -149,13 +149,13 @@ func (s *SharedServerSuite) TestWorkflow_Execute_SimpleSuccess() { func (s *SharedServerSuite) TestWorkflow_Execute_SimpleFailure() { // Text - s.Worker.OnDevWorkflow(func(ctx workflow.Context, input any) (any, error) { + s.Worker().OnDevWorkflow(func(ctx workflow.Context, input any) (any, error) { return nil, fmt.Errorf("intentional failure") }) res := s.Execute( "workflow", "execute", "--address", s.Address(), - "--task-queue", s.Worker.Options.TaskQueue, + "--task-queue", s.Worker().Options.TaskQueue, "--type", "DevWorkflow", "--workflow-id", "my-id1", ) @@ -171,7 +171,7 @@ func (s *SharedServerSuite) TestWorkflow_Execute_SimpleFailure() { "workflow", "execute", "-o", "json", "--address", s.Address(), - "--task-queue", s.Worker.Options.TaskQueue, + "--task-queue", s.Worker().Options.TaskQueue, "--type", "DevWorkflow", "--workflow-id", "my-id2", ) @@ -185,17 +185,17 @@ func (s *SharedServerSuite) TestWorkflow_Execute_SimpleFailure() { func (s *SharedServerSuite) TestWorkflow_Execute_NestedFailure() { // Text - s.Worker.OnDevWorkflow(func(ctx workflow.Context, input any) (any, error) { + s.Worker().OnDevWorkflow(func(ctx workflow.Context, input any) (any, error) { err := workflow.ExecuteActivity(ctx, DevActivity).Get(ctx, nil) return nil, err }) - s.Worker.OnDevActivity(func(ctx context.Context, input any) (any, error) { + s.Worker().OnDevActivity(func(ctx context.Context, input any) (any, error) { return nil, fmt.Errorf("intentional activity failure") }) res := s.Execute( "workflow", "execute", "--address", s.Address(), - "--task-queue", s.Worker.Options.TaskQueue, + "--task-queue", s.Worker().Options.TaskQueue, "--type", "DevWorkflow", "--workflow-id", "my-id1", ) @@ -211,7 +211,7 @@ func (s *SharedServerSuite) TestWorkflow_Execute_NestedFailure() { "workflow", "execute", "-o", "json", "--address", s.Address(), - "--task-queue", s.Worker.Options.TaskQueue, + "--task-queue", s.Worker().Options.TaskQueue, "--type", "DevWorkflow", "--workflow-id", "my-id2", ) @@ -228,7 +228,7 @@ func (s *SharedServerSuite) TestWorkflow_Execute_NestedFailure() { func (s *SharedServerSuite) TestWorkflow_Execute_Cancel() { // Very bad™️ channel tricks doCancelChan := make(chan struct{}) - s.Worker.OnDevWorkflow(func(ctx workflow.Context, input any) (any, error) { + s.Worker().OnDevWorkflow(func(ctx workflow.Context, input any) (any, error) { doCancelChan <- struct{}{} err := workflow.Await(ctx, func() bool { return false @@ -244,7 +244,7 @@ func (s *SharedServerSuite) TestWorkflow_Execute_Cancel() { res := s.Execute( "workflow", "execute", "--address", s.Address(), - "--task-queue", s.Worker.Options.TaskQueue, + "--task-queue", s.Worker().Options.TaskQueue, "--type", "DevWorkflow", "--workflow-id", "my-id1", ) @@ -261,7 +261,7 @@ func (s *SharedServerSuite) TestWorkflow_Execute_Cancel() { "workflow", "execute", "-o", "json", "--address", s.Address(), - "--task-queue", s.Worker.Options.TaskQueue, + "--task-queue", s.Worker().Options.TaskQueue, "--type", "DevWorkflow", "--workflow-id", "my-id2", ) @@ -272,7 +272,7 @@ func (s *SharedServerSuite) TestWorkflow_Execute_Cancel() { } func (s *SharedServerSuite) TestWorkflow_Execute_Timeout() { - s.Worker.OnDevWorkflow(func(ctx workflow.Context, input any) (any, error) { + s.Worker().OnDevWorkflow(func(ctx workflow.Context, input any) (any, error) { err := workflow.Await(ctx, func() bool { return false }) @@ -283,7 +283,7 @@ func (s *SharedServerSuite) TestWorkflow_Execute_Timeout() { res := s.Execute( "workflow", "execute", "--address", s.Address(), - "--task-queue", s.Worker.Options.TaskQueue, + "--task-queue", s.Worker().Options.TaskQueue, "--type", "DevWorkflow", "--execution-timeout", "1ms", "--workflow-id", "my-id1", @@ -297,7 +297,7 @@ func (s *SharedServerSuite) TestWorkflow_Execute_Timeout() { "workflow", "execute", "-o", "json", "--address", s.Address(), - "--task-queue", s.Worker.Options.TaskQueue, + "--task-queue", s.Worker().Options.TaskQueue, "--type", "DevWorkflow", "--execution-timeout", "1ms", "--workflow-id", "my-id2", @@ -309,7 +309,7 @@ func (s *SharedServerSuite) TestWorkflow_Execute_Timeout() { } func (s *SharedServerSuite) TestWorkflow_Execute_ContinueAsNew() { - s.Worker.OnDevWorkflow(func(ctx workflow.Context, input any) (any, error) { + s.Worker().OnDevWorkflow(func(ctx workflow.Context, input any) (any, error) { if input.(float64) < 2 { return nil, workflow.NewContinueAsNewError(ctx, "DevWorkflow", input.(float64)+1) } @@ -320,7 +320,7 @@ func (s *SharedServerSuite) TestWorkflow_Execute_ContinueAsNew() { res := s.Execute( "workflow", "execute", "--address", s.Address(), - "--task-queue", s.Worker.Options.TaskQueue, + "--task-queue", s.Worker().Options.TaskQueue, "--type", "DevWorkflow", "-i", "1", "--workflow-id", "my-id1", @@ -348,7 +348,7 @@ func (s *SharedServerSuite) TestWorkflow_Execute_ProtoJSON_Input() { startWorkflowReqSerialized, err := protojson.Marshal(startWorkflowReq) s.NoError(err) - s.Worker.Worker.RegisterWorkflowWithOptions(func( + s.Worker().Worker.RegisterWorkflowWithOptions(func( ctx workflow.Context, input *workflowservice.StartWorkflowExecutionRequest, ) (*workflowservice.StartWorkflowExecutionRequest, error) { @@ -359,7 +359,7 @@ func (s *SharedServerSuite) TestWorkflow_Execute_ProtoJSON_Input() { res := s.Execute( "workflow", "execute", "--address", s.Address(), - "--task-queue", s.Worker.Options.TaskQueue, + "--task-queue", s.Worker().Options.TaskQueue, "--type", "ProtoJSONWorkflow", "--input-meta", "encoding=json/protobuf", "-i", string(startWorkflowReqSerialized), @@ -377,7 +377,7 @@ func (s *SharedServerSuite) TestWorkflow_Failure_On_Start() { res := s.Execute( "workflow", cmd, "--address", s.Address(), - "--task-queue", s.Worker.Options.TaskQueue, + "--task-queue", s.Worker().Options.TaskQueue, "--type", "DevWorkflow", "--workflow-id", veryLongID, ) @@ -420,7 +420,7 @@ func (s *SharedServerSuite) TestWorkflow_Execute_ClientHeaders() { res := s.Execute( "workflow", "execute", "--address", s.Address(), - "--task-queue", s.Worker.Options.TaskQueue, + "--task-queue", s.Worker().Options.TaskQueue, "--type", "DevWorkflow", "--workflow-id", "my-id1", "-i", `["val1", "val2"]`, @@ -440,7 +440,7 @@ func (s *SharedServerSuite) TestWorkflow_Execute_EnvVars() { } res := s.Execute( "workflow", "execute", - "--task-queue", s.Worker.Options.TaskQueue, + "--task-queue", s.Worker().Options.TaskQueue, "--type", "DevWorkflow", "--workflow-id", "my-id1", ) @@ -469,7 +469,7 @@ func (s *SharedServerSuite) TestWorkflow_Execute_EnvConfig() { "--env", "myenv", "--env-file", tmpFile.Name(), "--address", s.Address(), - "--task-queue", s.Worker.Options.TaskQueue, + "--task-queue", s.Worker().Options.TaskQueue, "--type", "DevWorkflow", "--workflow-id", "my-id1", "--input", `"cli-input"`, @@ -483,7 +483,7 @@ func (s *SharedServerSuite) TestWorkflow_Execute_EnvConfig() { "--env", "myenv", "--env-file", tmpFile.Name(), "--address", s.Address(), - "--task-queue", s.Worker.Options.TaskQueue, + "--task-queue", s.Worker().Options.TaskQueue, "--type", "DevWorkflow", "--workflow-id", "my-id2", ) diff --git a/temporalcli/commands.workflow_reset_test.go b/temporalcli/commands.workflow_reset_test.go index 157929ba..86adff9e 100644 --- a/temporalcli/commands.workflow_reset_test.go +++ b/temporalcli/commands.workflow_reset_test.go @@ -37,11 +37,11 @@ func (s *SharedServerSuite) awaitNextWorkflow(searchAttr string) { func (s *SharedServerSuite) TestWorkflow_Reset_ToFirstWorkflowTask() { var wfExecutions, activityExecutions int - s.Worker.OnDevActivity(func(ctx context.Context, a any) (any, error) { + s.Worker().OnDevActivity(func(ctx context.Context, a any) (any, error) { activityExecutions++ return nil, nil }) - s.Worker.OnDevWorkflow(func(ctx workflow.Context, a any) (any, error) { + s.Worker().OnDevWorkflow(func(ctx workflow.Context, a any) (any, error) { workflow.ExecuteActivity(ctx, DevActivity, 1).Get(ctx, nil) wfExecutions++ return nil, nil @@ -52,7 +52,7 @@ func (s *SharedServerSuite) TestWorkflow_Reset_ToFirstWorkflowTask() { run, err := s.Client.ExecuteWorkflow( s.Context, client.StartWorkflowOptions{ - TaskQueue: s.Worker.Options.TaskQueue, + TaskQueue: s.Worker().Options.TaskQueue, SearchAttributes: map[string]any{"CustomKeywordField": searchAttr}, }, DevWorkflow, @@ -79,11 +79,11 @@ func (s *SharedServerSuite) TestWorkflow_Reset_ToFirstWorkflowTask() { func (s *SharedServerSuite) TestWorkflow_Reset_ToLastWorkflowTask() { var wfExecutions, activityExecutions int - s.Worker.OnDevActivity(func(ctx context.Context, a any) (any, error) { + s.Worker().OnDevActivity(func(ctx context.Context, a any) (any, error) { activityExecutions++ return nil, nil }) - s.Worker.OnDevWorkflow(func(ctx workflow.Context, a any) (any, error) { + s.Worker().OnDevWorkflow(func(ctx workflow.Context, a any) (any, error) { workflow.ExecuteActivity(ctx, DevActivity, 1).Get(ctx, nil) wfExecutions++ return nil, nil @@ -94,7 +94,7 @@ func (s *SharedServerSuite) TestWorkflow_Reset_ToLastWorkflowTask() { run, err := s.Client.ExecuteWorkflow( s.Context, client.StartWorkflowOptions{ - TaskQueue: s.Worker.Options.TaskQueue, + TaskQueue: s.Worker().Options.TaskQueue, SearchAttributes: map[string]any{"CustomKeywordField": searchAttr}, }, DevWorkflow, @@ -123,7 +123,7 @@ func (s *SharedServerSuite) TestWorkflow_Reset_ToEventID() { // We execute two activities and will resume just before the second one. We use the same activity for both // but a unique input so we can check which fake activity is executed var oneExecutions, twoExecutions int - s.Worker.OnDevActivity(func(ctx context.Context, a any) (any, error) { + s.Worker().OnDevActivity(func(ctx context.Context, a any) (any, error) { n, ok := a.(float64) if !ok { return nil, fmt.Errorf("expected float64, not %T (%v)", a, a) @@ -139,7 +139,7 @@ func (s *SharedServerSuite) TestWorkflow_Reset_ToEventID() { return n, nil }) - s.Worker.OnDevWorkflow(func(ctx workflow.Context, a any) (any, error) { + s.Worker().OnDevWorkflow(func(ctx workflow.Context, a any) (any, error) { var res any if err := workflow.ExecuteActivity(ctx, DevActivity, 1).Get(ctx, &res); err != nil { return res, err @@ -153,7 +153,7 @@ func (s *SharedServerSuite) TestWorkflow_Reset_ToEventID() { run, err := s.Client.ExecuteWorkflow( s.Context, client.StartWorkflowOptions{ - TaskQueue: s.Worker.Options.TaskQueue, + TaskQueue: s.Worker().Options.TaskQueue, SearchAttributes: map[string]any{"CustomKeywordField": searchAttr}, }, DevWorkflow, diff --git a/temporalcli/commands.workflow_test.go b/temporalcli/commands.workflow_test.go index 0be7588f..79c141bb 100644 --- a/temporalcli/commands.workflow_test.go +++ b/temporalcli/commands.workflow_test.go @@ -16,7 +16,7 @@ import ( func (s *SharedServerSuite) TestWorkflow_Signal_SingleWorkflowSuccess() { // Make workflow wait for signal and then return it - s.Worker.OnDevWorkflow(func(ctx workflow.Context, a any) (any, error) { + s.Worker().OnDevWorkflow(func(ctx workflow.Context, a any) (any, error) { var ret any workflow.GetSignalChannel(ctx, "my-signal").Receive(ctx, &ret) return ret, nil @@ -25,7 +25,7 @@ func (s *SharedServerSuite) TestWorkflow_Signal_SingleWorkflowSuccess() { // Start the workflow run, err := s.Client.ExecuteWorkflow( s.Context, - client.StartWorkflowOptions{TaskQueue: s.Worker.Options.TaskQueue}, + client.StartWorkflowOptions{TaskQueue: s.Worker().Options.TaskQueue}, DevWorkflow, "ignored", ) @@ -62,7 +62,7 @@ func (s *SharedServerSuite) TestWorkflow_Signal_BatchWorkflowSuccessJSON() { func (s *SharedServerSuite) testSignalBatchWorkflow(json bool) *CommandResult { // Make workflow wait for signal and then return it - s.Worker.OnDevWorkflow(func(ctx workflow.Context, a any) (any, error) { + s.Worker().OnDevWorkflow(func(ctx workflow.Context, a any) (any, error) { var ret any workflow.GetSignalChannel(ctx, "my-signal").Receive(ctx, &ret) return ret, nil @@ -75,7 +75,7 @@ func (s *SharedServerSuite) testSignalBatchWorkflow(json bool) *CommandResult { run, err := s.Client.ExecuteWorkflow( s.Context, client.StartWorkflowOptions{ - TaskQueue: s.Worker.Options.TaskQueue, + TaskQueue: s.Worker().Options.TaskQueue, SearchAttributes: map[string]any{"CustomKeywordField": searchAttr}, }, DevWorkflow, @@ -120,7 +120,7 @@ func (s *SharedServerSuite) testSignalBatchWorkflow(json bool) *CommandResult { } func (s *SharedServerSuite) TestWorkflow_Delete_BatchWorkflowSuccess() { - s.Worker.OnDevWorkflow(func(ctx workflow.Context, a any) (any, error) { + s.Worker().OnDevWorkflow(func(ctx workflow.Context, a any) (any, error) { ctx.Done().Receive(ctx, nil) return nil, ctx.Err() }) @@ -180,7 +180,7 @@ func (s *SharedServerSuite) TestWorkflow_Delete_BatchWorkflowSuccess() { } func (s *SharedServerSuite) TestWorkflow_Terminate_SingleWorkflowSuccess_WithoutReason() { - s.Worker.OnDevWorkflow(func(ctx workflow.Context, a any) (any, error) { + s.Worker().OnDevWorkflow(func(ctx workflow.Context, a any) (any, error) { ctx.Done().Receive(ctx, nil) return nil, ctx.Err() }) @@ -188,7 +188,7 @@ func (s *SharedServerSuite) TestWorkflow_Terminate_SingleWorkflowSuccess_Without // Start the workflow run, err := s.Client.ExecuteWorkflow( s.Context, - client.StartWorkflowOptions{TaskQueue: s.Worker.Options.TaskQueue}, + client.StartWorkflowOptions{TaskQueue: s.Worker().Options.TaskQueue}, DevWorkflow, "ignored", ) @@ -220,7 +220,7 @@ func (s *SharedServerSuite) TestWorkflow_Terminate_SingleWorkflowSuccess_Without } func (s *SharedServerSuite) TestWorkflow_Terminate_SingleWorkflowSuccess_WithReason() { - s.Worker.OnDevWorkflow(func(ctx workflow.Context, a any) (any, error) { + s.Worker().OnDevWorkflow(func(ctx workflow.Context, a any) (any, error) { ctx.Done().Receive(ctx, nil) return nil, ctx.Err() }) @@ -228,7 +228,7 @@ func (s *SharedServerSuite) TestWorkflow_Terminate_SingleWorkflowSuccess_WithRea // Start the workflow run, err := s.Client.ExecuteWorkflow( s.Context, - client.StartWorkflowOptions{TaskQueue: s.Worker.Options.TaskQueue}, + client.StartWorkflowOptions{TaskQueue: s.Worker().Options.TaskQueue}, DevWorkflow, "ignored", ) @@ -274,7 +274,7 @@ func (s *SharedServerSuite) TestWorkflow_Terminate_BatchWorkflowSuccessJSON() { } func (s *SharedServerSuite) testTerminateBatchWorkflow(json bool) *CommandResult { - s.Worker.OnDevWorkflow(func(ctx workflow.Context, a any) (any, error) { + s.Worker().OnDevWorkflow(func(ctx workflow.Context, a any) (any, error) { ctx.Done().Receive(ctx, nil) return nil, ctx.Err() }) @@ -286,7 +286,7 @@ func (s *SharedServerSuite) testTerminateBatchWorkflow(json bool) *CommandResult run, err := s.Client.ExecuteWorkflow( s.Context, client.StartWorkflowOptions{ - TaskQueue: s.Worker.Options.TaskQueue, + TaskQueue: s.Worker().Options.TaskQueue, SearchAttributes: map[string]any{"CustomKeywordField": searchAttr}, }, DevWorkflow, @@ -341,7 +341,7 @@ func (s *SharedServerSuite) testTerminateBatchWorkflow(json bool) *CommandResult func (s *SharedServerSuite) TestWorkflow_Cancel_SingleWorkflowSuccess() { // Make workflow wait for cancel and then return the context's error - s.Worker.OnDevWorkflow(func(ctx workflow.Context, a any) (any, error) { + s.Worker().OnDevWorkflow(func(ctx workflow.Context, a any) (any, error) { ctx.Done().Receive(ctx, nil) return nil, ctx.Err() }) @@ -349,7 +349,7 @@ func (s *SharedServerSuite) TestWorkflow_Cancel_SingleWorkflowSuccess() { // Start the workflow run, err := s.Client.ExecuteWorkflow( s.Context, - client.StartWorkflowOptions{TaskQueue: s.Worker.Options.TaskQueue}, + client.StartWorkflowOptions{TaskQueue: s.Worker().Options.TaskQueue}, DevWorkflow, "ignored", ) @@ -370,7 +370,7 @@ func (s *SharedServerSuite) TestWorkflow_Cancel_SingleWorkflowSuccess() { func (s *SharedServerSuite) TestWorkflow_Update() { updateName := "test-update" - s.Worker.OnDevWorkflow(func(ctx workflow.Context, val any) (any, error) { + s.Worker().OnDevWorkflow(func(ctx workflow.Context, val any) (any, error) { // setup a simple workflow which receives non-negative floats in updates and adds them to a running counter counter, ok := val.(float64) if !ok { @@ -408,7 +408,7 @@ func (s *SharedServerSuite) TestWorkflow_Update() { input := rand.Intn(100) run, err := s.Client.ExecuteWorkflow( s.Context, - client.StartWorkflowOptions{TaskQueue: s.Worker.Options.TaskQueue}, + client.StartWorkflowOptions{TaskQueue: s.Worker().Options.TaskQueue}, DevWorkflow, input, ) @@ -457,7 +457,7 @@ func (s *SharedServerSuite) TestWorkflow_Cancel_BatchWorkflowSuccessJSON() { func (s *SharedServerSuite) testCancelBatchWorkflow(json bool) *CommandResult { // Make workflow wait for cancel and then return the context's error - s.Worker.OnDevWorkflow(func(ctx workflow.Context, a any) (any, error) { + s.Worker().OnDevWorkflow(func(ctx workflow.Context, a any) (any, error) { ctx.Done().Receive(ctx, nil) return nil, ctx.Err() }) @@ -469,7 +469,7 @@ func (s *SharedServerSuite) testCancelBatchWorkflow(json bool) *CommandResult { run, err := s.Client.ExecuteWorkflow( s.Context, client.StartWorkflowOptions{ - TaskQueue: s.Worker.Options.TaskQueue, + TaskQueue: s.Worker().Options.TaskQueue, SearchAttributes: map[string]any{"CustomKeywordField": searchAttr}, }, DevWorkflow, @@ -519,7 +519,7 @@ func (s *SharedServerSuite) TestWorkflow_Query_SingleWorkflowSuccessJSON() { } func (s *SharedServerSuite) testQueryWorkflow(json bool) { - s.Worker.OnDevWorkflow(func(ctx workflow.Context, a any) (any, error) { + s.Worker().OnDevWorkflow(func(ctx workflow.Context, a any) (any, error) { err := workflow.SetQueryHandler(ctx, "my-query", func(arg string) (any, error) { retme := struct { Echo string `json:"input"` @@ -538,7 +538,7 @@ func (s *SharedServerSuite) testQueryWorkflow(json bool) { // Start the workflow run, err := s.Client.ExecuteWorkflow( s.Context, - client.StartWorkflowOptions{TaskQueue: s.Worker.Options.TaskQueue}, + client.StartWorkflowOptions{TaskQueue: s.Worker().Options.TaskQueue}, DevWorkflow, "ignored", ) @@ -594,7 +594,7 @@ func (s *SharedServerSuite) TestWorkflow_Stack_SingleWorkflowSuccessJSON() { func (s *SharedServerSuite) testStackWorkflow(json bool) { // Make workflow wait for signal and then return it - s.Worker.OnDevWorkflow(func(ctx workflow.Context, a any) (any, error) { + s.Worker().OnDevWorkflow(func(ctx workflow.Context, a any) (any, error) { done := false workflow.Go(ctx, func(ctx workflow.Context) { _ = workflow.Await(ctx, func() bool { @@ -610,7 +610,7 @@ func (s *SharedServerSuite) testStackWorkflow(json bool) { // Start the workflow run, err := s.Client.ExecuteWorkflow( s.Context, - client.StartWorkflowOptions{TaskQueue: s.Worker.Options.TaskQueue}, + client.StartWorkflowOptions{TaskQueue: s.Worker().Options.TaskQueue}, DevWorkflow, "ignored", ) diff --git a/temporalcli/commands.workflow_view.go b/temporalcli/commands.workflow_view.go index 145fa131..8498bc4c 100644 --- a/temporalcli/commands.workflow_view.go +++ b/temporalcli/commands.workflow_view.go @@ -14,6 +14,7 @@ import ( "go.temporal.io/api/workflow/v1" "go.temporal.io/api/workflowservice/v1" "go.temporal.io/sdk/client" + "go.temporal.io/sdk/converter" ) func (c *TemporalWorkflowDescribeCommand) run(cctx *CommandContext, args []string) error { @@ -265,8 +266,51 @@ func (c *TemporalWorkflowListCommand) pageFetcher( } } -func (*TemporalWorkflowCountCommand) run(*CommandContext, []string) error { - return fmt.Errorf("TODO") +func (c *TemporalWorkflowCountCommand) run(cctx *CommandContext, _ []string) error { + cl, err := c.Parent.ClientOptions.dialClient(cctx) + if err != nil { + return err + } + defer cl.Close() + + resp, err := cl.WorkflowService().CountWorkflowExecutions(cctx, &workflowservice.CountWorkflowExecutionsRequest{ + Namespace: c.Parent.Namespace, + Query: c.Query, + }) + if err != nil { + return err + } + + // Just dump response on JSON, otherwise print total and groups + if cctx.JSONOutput { + // Shorthand does not apply to search attributes currently, so we're going + // to remove the "type" from the metadata encoding on group values to make + // it apply + for _, group := range resp.Groups { + for _, payload := range group.GroupValues { + delete(payload.GetMetadata(), "type") + } + } + return cctx.Printer.PrintStructured(resp, printer.StructuredOptions{}) + } + + cctx.Printer.Printlnf("Total: %v", resp.Count) + for _, group := range resp.Groups { + // Payload values are search attributes, so we can use the default converter + var valueStr string + for _, payload := range group.GroupValues { + var value any + if err := converter.GetDefaultDataConverter().FromPayload(payload, &value); err != nil { + value = fmt.Sprintf("", err) + } + if valueStr != "" { + valueStr += ", " + } + valueStr += fmt.Sprintf("%v", value) + } + cctx.Printer.Printlnf("Group total: %v, values: %v", group.Count, valueStr) + } + return nil } func (c *TemporalWorkflowShowCommand) run(cctx *CommandContext, args []string) error { diff --git a/temporalcli/commands.workflow_view_test.go b/temporalcli/commands.workflow_view_test.go index 3bc6a5bf..c73139da 100644 --- a/temporalcli/commands.workflow_view_test.go +++ b/temporalcli/commands.workflow_view_test.go @@ -5,9 +5,11 @@ import ( "encoding/json" "fmt" "strconv" + "strings" "time" "github.com/temporalio/cli/temporalcli" + "go.temporal.io/api/enums/v1" "go.temporal.io/api/workflowservice/v1" "go.temporal.io/sdk/client" "go.temporal.io/sdk/workflow" @@ -15,11 +17,11 @@ import ( func (s *SharedServerSuite) TestWorkflow_Describe_ActivityFailing() { // Set activity to just continually error - s.Worker.OnDevActivity(func(ctx context.Context, a any) (any, error) { + s.Worker().OnDevActivity(func(ctx context.Context, a any) (any, error) { return nil, fmt.Errorf("intentional error") }) - s.Worker.OnDevWorkflow(func(ctx workflow.Context, input any) (any, error) { + s.Worker().OnDevWorkflow(func(ctx workflow.Context, input any) (any, error) { ctx = workflow.WithActivityOptions(ctx, workflow.ActivityOptions{ StartToCloseTimeout: 10 * time.Second, }) @@ -31,7 +33,7 @@ func (s *SharedServerSuite) TestWorkflow_Describe_ActivityFailing() { // Start the workflow and wait until it has at least reached activity failure run, err := s.Client.ExecuteWorkflow( s.Context, - client.StartWorkflowOptions{TaskQueue: s.Worker.Options.TaskQueue}, + client.StartWorkflowOptions{TaskQueue: s.Worker().Options.TaskQueue}, DevWorkflow, "ignored", ) @@ -72,7 +74,7 @@ func (s *SharedServerSuite) TestWorkflow_Describe_Completed() { // Start the workflow and wait until it has at least reached activity failure run, err := s.Client.ExecuteWorkflow( s.Context, - client.StartWorkflowOptions{TaskQueue: s.Worker.Options.TaskQueue}, + client.StartWorkflowOptions{TaskQueue: s.Worker().Options.TaskQueue}, DevWorkflow, map[string]string{"foo": "bar"}, ) @@ -108,7 +110,7 @@ func (s *SharedServerSuite) TestWorkflow_Describe_ResetPoints() { // Start the workflow and wait until it has at least reached activity failure run, err := s.Client.ExecuteWorkflow( s.Context, - client.StartWorkflowOptions{TaskQueue: s.Worker.Options.TaskQueue}, + client.StartWorkflowOptions{TaskQueue: s.Worker().Options.TaskQueue}, DevWorkflow, map[string]string{"foo": "bar"}, ) @@ -144,7 +146,7 @@ func (s *SharedServerSuite) TestWorkflow_Describe_ResetPoints() { } func (s *SharedServerSuite) TestWorkflow_Show_Follow() { - s.Worker.OnDevWorkflow(func(ctx workflow.Context, a any) (any, error) { + s.Worker().OnDevWorkflow(func(ctx workflow.Context, a any) (any, error) { sigs := 0 for { workflow.GetSignalChannel(ctx, "my-signal").Receive(ctx, nil) @@ -159,7 +161,7 @@ func (s *SharedServerSuite) TestWorkflow_Show_Follow() { // Start the workflow run, err := s.Client.ExecuteWorkflow( s.Context, - client.StartWorkflowOptions{TaskQueue: s.Worker.Options.TaskQueue}, + client.StartWorkflowOptions{TaskQueue: s.Worker().Options.TaskQueue}, DevWorkflow, "ignored", ) @@ -191,7 +193,7 @@ func (s *SharedServerSuite) TestWorkflow_Show_Follow() { } func (s *SharedServerSuite) TestWorkflow_Show_NoFollow() { - s.Worker.OnDevWorkflow(func(ctx workflow.Context, a any) (any, error) { + s.Worker().OnDevWorkflow(func(ctx workflow.Context, a any) (any, error) { sigs := 0 for { workflow.GetSignalChannel(ctx, "my-signal").Receive(ctx, nil) @@ -206,7 +208,7 @@ func (s *SharedServerSuite) TestWorkflow_Show_NoFollow() { // Start the workflow run, err := s.Client.ExecuteWorkflow( s.Context, - client.StartWorkflowOptions{TaskQueue: s.Worker.Options.TaskQueue}, + client.StartWorkflowOptions{TaskQueue: s.Worker().Options.TaskQueue}, DevWorkflow, "ignored", ) @@ -239,7 +241,7 @@ func (s *SharedServerSuite) TestWorkflow_Show_NoFollow() { } func (s *SharedServerSuite) TestWorkflow_Show_JSON() { - s.Worker.OnDevWorkflow(func(ctx workflow.Context, a any) (any, error) { + s.Worker().OnDevWorkflow(func(ctx workflow.Context, a any) (any, error) { sigs := 0 for { workflow.GetSignalChannel(ctx, "my-signal").Receive(ctx, nil) @@ -254,7 +256,7 @@ func (s *SharedServerSuite) TestWorkflow_Show_JSON() { // Start the workflow run, err := s.Client.ExecuteWorkflow( s.Context, - client.StartWorkflowOptions{TaskQueue: s.Worker.Options.TaskQueue}, + client.StartWorkflowOptions{TaskQueue: s.Worker().Options.TaskQueue}, DevWorkflow, "ignored", ) @@ -290,7 +292,7 @@ func (s *SharedServerSuite) TestWorkflow_Show_JSON() { } func (s *SharedServerSuite) TestWorkflow_List() { - s.Worker.OnDevWorkflow(func(ctx workflow.Context, a any) (any, error) { + s.Worker().OnDevWorkflow(func(ctx workflow.Context, a any) (any, error) { return a, nil }) @@ -298,7 +300,7 @@ func (s *SharedServerSuite) TestWorkflow_List() { for i := 0; i < 3; i++ { run, err := s.Client.ExecuteWorkflow( s.Context, - client.StartWorkflowOptions{TaskQueue: s.Worker.Options.TaskQueue}, + client.StartWorkflowOptions{TaskQueue: s.Worker().Options.TaskQueue}, DevWorkflow, strconv.Itoa(i), ) @@ -309,7 +311,7 @@ func (s *SharedServerSuite) TestWorkflow_List() { res := s.Execute( "workflow", "list", "--address", s.Address(), - "--query", fmt.Sprintf(`TaskQueue="%s"`, s.Worker.Options.TaskQueue), + "--query", fmt.Sprintf(`TaskQueue="%s"`, s.Worker().Options.TaskQueue), ) s.NoError(res.Err) out := res.Stdout.String() @@ -319,7 +321,7 @@ func (s *SharedServerSuite) TestWorkflow_List() { res = s.Execute( "workflow", "list", "--address", s.Address(), - "--query", fmt.Sprintf(`TaskQueue="%s"`, s.Worker.Options.TaskQueue), + "--query", fmt.Sprintf(`TaskQueue="%s"`, s.Worker().Options.TaskQueue), "-o", "json", ) s.NoError(res.Err) @@ -328,3 +330,90 @@ func (s *SharedServerSuite) TestWorkflow_List() { s.ContainsOnSameLine(out, "name", "DevWorkflow") s.ContainsOnSameLine(out, "status", "WORKFLOW_EXECUTION_STATUS_COMPLETED") } + +func (s *SharedServerSuite) TestWorkflow_Count() { + s.Worker().OnDevWorkflow(func(ctx workflow.Context, shouldComplete any) (any, error) { + // Only complete if shouldComplete is a true bool + shouldCompleteBool, _ := shouldComplete.(bool) + return nil, workflow.Await(ctx, func() bool { return shouldCompleteBool }) + }) + + // Create 3 that complete and 2 that don't + for i := 0; i < 5; i++ { + _, err := s.Client.ExecuteWorkflow( + s.Context, + client.StartWorkflowOptions{TaskQueue: s.Worker().Options.TaskQueue}, + DevWorkflow, + i < 3, + ) + s.NoError(err) + } + + // List and confirm they are all there in expected statuses + s.Eventually( + func() bool { + resp, err := s.Client.ListWorkflow(s.Context, &workflowservice.ListWorkflowExecutionsRequest{ + Query: "TaskQueue = '" + s.Worker().Options.TaskQueue + "'", + }) + s.NoError(err) + var completed, running int + for _, exec := range resp.Executions { + if exec.Status == enums.WORKFLOW_EXECUTION_STATUS_COMPLETED { + completed++ + } else if exec.Status == enums.WORKFLOW_EXECUTION_STATUS_RUNNING { + running++ + } + } + return completed == 3 && running == 2 + }, + 10*time.Second, + 100*time.Millisecond, + ) + + // Simple count w/out grouping + res := s.Execute( + "workflow", "count", + "--address", s.Address(), + "--query", "TaskQueue = '"+s.Worker().Options.TaskQueue+"'", + ) + s.NoError(res.Err) + out := res.Stdout.String() + s.Equal("Total: 5", strings.TrimSpace(out)) + + // Grouped + res = s.Execute( + "workflow", "count", + "--address", s.Address(), + "--query", "TaskQueue = '"+s.Worker().Options.TaskQueue+"' GROUP BY ExecutionStatus", + ) + s.NoError(res.Err) + out = res.Stdout.String() + s.Contains(out, "Total: 5") + s.Contains(out, "Group total: 2, values: Running") + s.Contains(out, "Group total: 3, values: Completed") + + // Simple count w/out grouping JSON + res = s.Execute( + "workflow", "count", + "--address", s.Address(), + "--query", "TaskQueue = '"+s.Worker().Options.TaskQueue+"'", + "-o", "json", + ) + s.NoError(res.Err) + out = res.Stdout.String() + // Proto JSON makes this count a string + s.Contains(out, `"count": "5"`) + + // Grouped JSON + res = s.Execute( + "workflow", "count", + "--address", s.Address(), + "--query", "TaskQueue = '"+s.Worker().Options.TaskQueue+"' GROUP BY ExecutionStatus", + "-o", "jsonl", + ) + s.NoError(res.Err) + out = res.Stdout.String() + s.Contains(out, `"count":"5"`) + s.Contains(out, `{"groupValues":["Running"],"count":"2"}`) + s.Contains(out, `{"groupValues":["Completed"],"count":"3"}`) +} diff --git a/temporalcli/commands_test.go b/temporalcli/commands_test.go index e50d5678..39a15421 100644 --- a/temporalcli/commands_test.go +++ b/temporalcli/commands_test.go @@ -167,8 +167,10 @@ type SharedServerSuite struct { *CommandHarness *DevServer - Worker *DevWorker - Suite suite.Suite + Suite suite.Suite + + lazyWorker *DevWorker + lazyWorkerLock sync.Mutex } func (s *SharedServerSuite) SetupSuite() { @@ -185,7 +187,6 @@ func (s *SharedServerSuite) SetupSuite() { s.Server.Stop() } }() - s.Worker = s.DevServer.StartDevWorker(s.Suite.T(), DevWorkerOptions{}) success = true } @@ -194,7 +195,6 @@ func (s *SharedServerSuite) TearDownSuite() { } func (s *SharedServerSuite) Stop() { - s.Worker.Stop() s.DevServer.Stop() } @@ -202,7 +202,9 @@ func (s *SharedServerSuite) SetupTest() { // Clear log buffer s.ResetLogOutput() // Reset worker - s.Worker.Reset() + s.lazyWorkerLock.Lock() + s.lazyWorker = nil + s.lazyWorkerLock.Unlock() // Create new command harness s.CommandHarness = NewCommandHarness(s.Suite.T()) } @@ -216,6 +218,24 @@ func (s *SharedServerSuite) TearDownTest() { s.CommandHarness.Close() } s.CommandHarness = nil + // Stop worker + s.lazyWorkerLock.Lock() + defer s.lazyWorkerLock.Unlock() + if s.lazyWorker != nil { + s.lazyWorker.Stop() + s.lazyWorker = nil + } +} + +// Worker gets a worker specific to this test (starting lazily if needed). +func (s *SharedServerSuite) Worker() *DevWorker { + // Start lazily + s.lazyWorkerLock.Lock() + defer s.lazyWorkerLock.Unlock() + if s.lazyWorker == nil { + s.lazyWorker = s.DevServer.StartDevWorker(s.Suite.T(), DevWorkerOptions{}) + } + return s.lazyWorker } func (s *SharedServerSuite) T() *testing.T { return s.Suite.T() } diff --git a/temporalcli/commandsmd/commands.md b/temporalcli/commandsmd/commands.md index 89b3178a..5df32875 100644 --- a/temporalcli/commandsmd/commands.md +++ b/temporalcli/commandsmd/commands.md @@ -723,7 +723,13 @@ Includes options set for [single workflow or batch](#options-set-single-workflow ### temporal workflow count: Count Workflow Executions. -TODO +The `temporal workflow count` command returns a count of [Workflow Executions](/concepts/what-is-a-workflow-execution). + +Use the options listed below to change the command's behavior. + +#### Options + +* `--query`, `-q` (string) - Filter results using a SQL-like query. ### temporal workflow delete: Deletes a Workflow Execution. @@ -1018,10 +1024,6 @@ Use the options listed below to change the behavior of this command. * `--reason` (string) - Reason for termination. Defaults to message with the current user's name. * `--yes`, `-y` (bool) - Confirm prompt to perform batch. Only allowed if query is present. -### temporal workflow trace: Trace progress of a Workflow Execution and its children. - -TODO - ### temporal workflow update: Updates a running workflow synchronously. The `temporal workflow update` command is used to synchronously [Update](/concepts/what-is-an-update) a