Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions temporalcli/commands.gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -2898,6 +2898,7 @@ type TemporalWorkflowListCommand struct {
Query string
Archived bool
Limit int
PageSize int
}

func NewTemporalWorkflowListCommand(cctx *CommandContext, parent *TemporalWorkflowCommand) *TemporalWorkflowListCommand {
Expand All @@ -2915,6 +2916,7 @@ func NewTemporalWorkflowListCommand(cctx *CommandContext, parent *TemporalWorkfl
s.Command.Flags().StringVarP(&s.Query, "query", "q", "", "Content for an SQL-like `QUERY` List Filter.")
s.Command.Flags().BoolVar(&s.Archived, "archived", false, "Limit output to archived Workflow Executions.")
s.Command.Flags().IntVar(&s.Limit, "limit", 0, "Maximum number of Workflow Executions to display.")
s.Command.Flags().IntVar(&s.PageSize, "page-size", 0, "Maximum number of Workflow Executions to fetch at a time from the server.")
s.Command.Run = func(c *cobra.Command, args []string) {
if err := s.run(cctx, args); err != nil {
cctx.Options.Fail(err)
Expand Down
10 changes: 7 additions & 3 deletions temporalcli/commands.workflow_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,7 @@ func (c *TemporalWorkflowListCommand) run(cctx *CommandContext, _ []string) erro
cctx.Printer.StartList()
defer cctx.Printer.EndList()

// Build request and start looping. We always use default page size regardless
// of user-defined limit, because we're ok w/ extra page data and the default
// is not clearly defined.
// Build request and start looping.
pageFetcher := c.pageFetcher(cctx, cl)
var nextPageToken []byte
var execsProcessed int
Expand Down Expand Up @@ -360,16 +358,22 @@ func (c *TemporalWorkflowListCommand) pageFetcher(
cctx *CommandContext,
cl client.Client,
) func(next []byte) (workflowPage, error) {

if c.Limit > 0 && c.Limit < c.PageSize {
c.PageSize = c.Limit
}
return func(next []byte) (workflowPage, error) {
if c.Archived {
return cl.ListArchivedWorkflow(cctx, &workflowservice.ListArchivedWorkflowExecutionsRequest{
Query: c.Query,
NextPageToken: next,
PageSize: int32(c.PageSize),
})
}
return cl.ListWorkflow(cctx, &workflowservice.ListWorkflowExecutionsRequest{
Query: c.Query,
NextPageToken: next,
PageSize: int32(c.PageSize),
})
}
}
Expand Down
2 changes: 2 additions & 0 deletions temporalcli/commands.workflow_view_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,10 +442,12 @@ func (s *SharedServerSuite) TestWorkflow_List() {
"workflow", "list",
"--address", s.Address(),
"--query", fmt.Sprintf(`TaskQueue="%s"`, s.Worker().Options.TaskQueue),
"--page-size", "1",
)
s.NoError(res.Err)
out := res.Stdout.String()
s.ContainsOnSameLine(out, "Completed", "DevWorkflow")
s.Equal(3, strings.Count(out, "DevWorkflow"))

// JSON
res = s.Execute(
Expand Down
3 changes: 3 additions & 0 deletions temporalcli/commandsgen/commands.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2886,6 +2886,9 @@ commands:
- name: limit
type: int
description: Maximum number of Workflow Executions to display.
- name: page-size
Copy link
Contributor

@cretz cretz Feb 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- name: page-size
- name: force-override-page-size

Mentioned internally, but this less-wieldy form may make it a bit clearer users usually don't ever need to set this. No strong opinion though.

type: int
description: Maximum number of Workflow Executions to fetch at a time from the server.

- name: temporal workflow metadata
summary: Query the Workflow for user-specified metadata
Expand Down
Loading