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

IWF-163: Add retry policy to QueryWorkflow calls #491

Merged
merged 10 commits into from
Nov 26, 2024

Conversation

lwolczynski
Copy link
Contributor

Description

Checklist

  • Code compiles correctly
  • Tests for the changes have been added
  • All tests passing
  • This PR change is backwards-compatible
  • This PR CONTAINS a (planned) breaking change (it is not backwards compatible)

Related Issue

Closes #437

@lwolczynski lwolczynski force-pushed the jira/lwolczynski/IWF-163 branch from 68fa7a7 to 7feffc2 Compare November 22, 2024 22:26
Comment on lines 127 to 131
retryPolicy := temporalapi.QueryWorkflowFailedRetryPolicy{
InitialIntervalSeconds: config.GetInitialIntervalSecondsWithDefault(),
MaximumAttempts: config.GetMaximumAttemptsWithDefault(),
}
unifiedClient = temporalapi.NewTemporalClient(temporalClient, config.Interpreter.Temporal.Namespace, converter.GetDefaultDataConverter(), false, retryPolicy)
Copy link
Contributor

Choose a reason for hiding this comment

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

If you have config.GetInitialIntervalSecondsWithDefault(), then the expectation is that the code that need to use the value will call it to get the value with default, instead of passing into here.

So it will be temporalapi.NewTemporalClient(temporalClient, config.Interpreter.Temporal.Namespace, converter.GetDefaultDataConverter(), false, config.ApiConfig.QueryRetryPolicy)

Also consider using pointers to make this optional and load the default values in client.go.
Basically the config can be defined it as a pointer instead of struct. So that internally, we just need to pass a nil into this, which should let it use the default value.

qres, err = queryWorkflowWithStrongConsistency(t, ctx, workflowID, runID, queryType, args)
if err != nil {
if t.isQueryFailedError(err) {
if attempt == t.queryWorkflowFailedRetryPolicy.MaximumAttempts {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: I don't think we need another check here, since it'a already checked by the for loop condition?

Although we will have to check err != nil again outside of the loop

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Boils down to the same thing, but it might be a little cleaner. Done

@lwolczynski lwolczynski force-pushed the jira/lwolczynski/IWF-163 branch from b42805b to fc4f2d6 Compare November 25, 2024 20:08
) uclient.UnifiedClient {
var rp QueryWorkflowFailedRetryPolicy

if retryPolicy.InitialIntervalSeconds == 0 {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I'm not mistaken, not providing Config.ApiConfig.QueryWorkflowFailedRetryPolicy in yaml file will make the default int value show (which is 0). In other words, we shouldn't need a nil check here

@lwolczynski lwolczynski changed the base branch from main to jira/holiday/iwf-330 November 25, 2024 21:41
@lwolczynski lwolczynski marked this pull request as ready for review November 25, 2024 22:02
@lwolczynski lwolczynski merged commit 6ead62a into jira/holiday/iwf-330 Nov 26, 2024
10 checks passed
@lwolczynski lwolczynski deleted the jira/lwolczynski/IWF-163 branch November 26, 2024 16:02
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.

Refactor persistence_test and move API call retry to API Service
2 participants