@@ -50,6 +50,16 @@ class Client
5050 # Options as returned from {options} for +**to_h+ splat use in {initialize}. See {initialize} for details.
5151 class Options ; end # rubocop:disable Lint/EmptyClass
5252
53+ ListWorkflowPage = Data . define ( :executions , :next_page_token )
54+
55+ # A page of workflow executions returned by {Client#list_workflow_page}.
56+ #
57+ # @!attribute executions
58+ # @return [Array<WorkflowExecution>] List of workflow executions in this page.
59+ # @!attribute next_page_token
60+ # @return [String, nil] Token for the next page of results. nil if there are no more results.
61+ class ListWorkflowPage ; end # rubocop:disable Lint/EmptyClass
62+
5363 # Connect to Temporal server. This is a shortcut for +Connection.new+ followed by +Client.new+.
5464 #
5565 # @param target_host [String] +host:port+ for the Temporal server. For local development, this is often
@@ -486,7 +496,40 @@ def signal_with_start_workflow(
486496 #
487497 # @see https://docs.temporal.io/visibility
488498 def list_workflows ( query = nil , rpc_options : nil )
489- @impl . list_workflows ( Interceptor ::ListWorkflowsInput . new ( query :, rpc_options :) )
499+ next_page_token = nil
500+ Enumerator . new do |yielder |
501+ loop do
502+ list_workflow_page_input = Interceptor ::ListWorkflowPageInput . new (
503+ query : query ,
504+ rpc_options : rpc_options ,
505+ next_page_token : next_page_token ,
506+ page_size : nil
507+ )
508+ page = @impl . list_workflow_page ( list_workflow_page_input )
509+ page . executions . each { |execution | yielder << execution }
510+ next_page_token = page . next_page_token
511+ break if ( next_page_token || '' ) . empty?
512+ end
513+ end
514+ end
515+
516+ # List workflows one page at a time.
517+ #
518+ # @param query [String, nil] A Temporal visibility list filter.
519+ # @param page_size [Integer, nil] Maximum number of results to return.
520+ # @param next_page_token [String, nil] Token for the next page of results. If not set, the first page is returned.
521+ # @param rpc_options [RPCOptions, nil] Advanced RPC options.
522+ #
523+ # @return [ListWorkflowPage] Page of workflow executions, along with a next_page_token to keep fetching.
524+ #
525+ # @raise [Error::RPCError] RPC error from call.
526+ #
527+ # @see https://docs.temporal.io/visibility
528+ def list_workflow_page ( query = nil , page_size : nil , next_page_token : nil , rpc_options : nil )
529+ @impl . list_workflow_page ( Interceptor ::ListWorkflowPageInput . new ( query :,
530+ next_page_token :,
531+ page_size :,
532+ rpc_options :) )
490533 end
491534
492535 # Count workflows.
0 commit comments