-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose count_workflow_executions on the temporal client #272
Merged
DeRauk
merged 8 commits into
coinbase:master
from
harsh-stripe:count-workflow-executions
Nov 9, 2023
+36
−0
Merged
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
09eca23
Expose count_workflow_executions on the temporal client
harsh-stripe f8dd685
Return a wrapped type for count_workflows response
harsh-stripe 17660a3
Add integration tests
harsh-stripe be52fa7
Remove debug log lines
harsh-stripe 35bad5d
Update lib/temporal/client.rb
harsh-stripe 29e7b78
Return the count value of count_workflow_executions instead of wrappi…
harsh-stripe cbf1008
Resolve merge conflicts
harsh-stripe 3239f9a
Remove the example integration spec for count_workflows. ES isn't set…
harsh-stripe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# frozen_string_literal: true | ||
|
||
describe 'Temporal.count_workflow_executions', :integration do | ||
it 'returns the number of workflows matching the provided query' do | ||
workflow_id = SecureRandom.uuid | ||
run_id = Temporal.start_workflow( | ||
HelloWorldWorkflow, | ||
'Test', | ||
options: { workflow_id: workflow_id } | ||
) | ||
|
||
Temporal.await_workflow_result( | ||
HelloWorldWorkflow, | ||
workflow_id: workflow_id, | ||
run_id: run_id | ||
) | ||
|
||
query = "WorkflowType = \"HelloWorldWorkflow\" AND WorkflowId = \"#{workflow_id}\"" | ||
|
||
# This is a workaround for the fact that this API hits the visibility store and there's a lag | ||
# before the workflow gets indexed | ||
result = nil | ||
|
||
5.times do | ||
result = Temporal.count_workflow_executions( | ||
'ruby-samples', query: query | ||
) | ||
|
||
break if result.count.positive? | ||
|
||
sleep 1 | ||
end | ||
|
||
expect(result.count).to eq(1) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module Temporal | ||
class Workflow | ||
class CountWorkflowsResult | ||
def initialize(count:) | ||
@count = count | ||
end | ||
|
||
attr_reader :count | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@harsh-stripe Why create a new response object to return here? It'd be simpler to just return the count from this method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made a commit to return the count instead of this wrapped object. I had initially created it thinking it might be useful for a future contributor if they wanted to include aggregation groups based on https://github.com/temporalio/api/blob/master/temporal/api/workflowservice/v1/request_response.proto#L795-L798 in the future, but it isn't required now since it doesn't quite work yet in Temporal.