Skip to content
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

Add tryGettingSimpleWorkflowResult and tryGettingComplexWorkflowResult #199

Merged
merged 3 commits into from
Jul 31, 2023

Conversation

zklgame
Copy link
Contributor

@zklgame zklgame commented Jul 28, 2023

issue: #85

@codecov
Copy link

codecov bot commented Jul 28, 2023

Codecov Report

Merging #199 (0fe9c65) into main (3409ea7) will increase coverage by 0.55%.
The diff coverage is 73.52%.

@@             Coverage Diff              @@
##               main     #199      +/-   ##
============================================
+ Coverage     71.49%   72.05%   +0.55%     
- Complexity      376      388      +12     
============================================
  Files            60       60              
  Lines          1575     1585      +10     
  Branches        139      140       +1     
============================================
+ Hits           1126     1142      +16     
+ Misses          379      372       -7     
- Partials         70       71       +1     
Files Changed Coverage Δ
...ain/java/io/iworkflow/core/UnregisteredClient.java 61.92% <70.00%> (+3.29%) ⬆️
src/main/java/io/iworkflow/core/Client.java 62.71% <100.00%> (+1.50%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

* @param workflowRunId optional, can be empty
* @return a list of the state output for completion states. User code will figure how to use ObjectEncoder to decode the output
*/
public List<StateCompletionOutput> getComplexWorkflowResultWithoutWait(
Copy link
Contributor

@longquanzheng longquanzheng Jul 28, 2023

Choose a reason for hiding this comment

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

I personally want to avoid using WithoutWait because it looks too similar to WithWait at quick glance...
If you look at

  • getComplexWorkflowResultWithoutWait
  • getComplexWorkflowResultWithWait
    The out is too minor for our human eyes.

Though it looks accurate in grammar 😮‍💨

Maybe just call tryGettingComplexWorkflowResult -- it seems like Temporal is going to have this name as well:
temporalio/features#314

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call, yeah when I was writting the codes I also needed to pay attention on the names...

@@ -209,6 +306,33 @@ public <T> T getSimpleWorkflowResultWithWait(
return clientOptions.getObjectEncoder().decode(output.getCompletedStateOutput(), valueClass);
}

private WorkflowGetResponse getWorkflowResponse(
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: to me this should be called getWorkflowResult, and the other one could be something like getWorkflowResultAndDecode

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I used the plural form getWorkflowResults because the return values is from workflowGetResponse.getResults().

@zklgame zklgame changed the title Add getSimpleWorkflowResultWithoutWait and getComplexWorkflowResultWi… Add tryGettingSimpleWorkflowResult and tryGettingComplexWorkflowResult Jul 29, 2023
* In some cases, a workflow may have more than one completion states
* For most cases, a workflow only has one result(one completion state).
* Use this API to retrieve the output of the state.
* If the workflow is still running, return null.
Copy link
Contributor

Choose a reason for hiding this comment

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

Returnning null will be a problem if some workflow actually return null as result. There will be hard to differentiate the null being results or workflow uncompleted.

throw IwfHttpException.fromFeignException(clientOptions.getObjectEncoder(), exp);
}

if (withWait && workflowGetResponse.getWorkflowStatus() != WorkflowStatus.COMPLETED) {
Copy link
Contributor

Choose a reason for hiding this comment

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

so maybe just throw uncompletedException here when withWait==false and workflow is not completed

* Use this API to retrieve the output of the state
* For most cases, a workflow only has one result(one completion state).
* Use this API to retrieve the output of the state with waiting for the workflow to complete.
* If the workflow is not COMPLETED, throw the {@link WorkflowUncompletedException}.
Copy link
Contributor

@longquanzheng longquanzheng Jul 31, 2023

Choose a reason for hiding this comment

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

Actually this is throwing a different exception today: see #202 we may fix that in the future (we can't change this today because it will be a breaking change for production 😮‍💨 )

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True...

@zklgame zklgame merged commit 7d4e076 into main Jul 31, 2023
3 checks passed
@zklgame zklgame deleted the zklgame/issue_85 branch July 31, 2023 06:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants