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

Populate tasks in internal workflowTask and activityTask entities for empty polls #1416

Merged
merged 3 commits into from
Jan 17, 2025

Conversation

shijiesheng
Copy link
Member

@shijiesheng shijiesheng commented Jan 16, 2025

What changed?
ensure task field is populated in workflowTask and activityTask for empty polls.

Why?

Task response even with empty task contains information like AutoConfigHint, which is needed for poller auto scaler

How did you test it?

Unit Test

Potential risks

@@ -75,15 +75,17 @@ type (
// workflowTask wraps a decision task.
workflowTask struct {
task *s.PollForDecisionTaskResponse
autoConfigHint *s.AutoConfigHint
Copy link
Member

Choose a reason for hiding this comment

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

why can not we reuse the autoConfigHint inside task(PollForDecisionTaskResponse) here? I'm assuming task != nil will mess up the logic somewhere else

Copy link
Member Author

Choose a reason for hiding this comment

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

I haven't tried. But the field is widely used in many different places. Breaking the Nilness assumption might mess it up.

Copy link
Member

Choose a reason for hiding this comment

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

I don't think we need the new field. It's a redundant information and requires each instantiation of workflowTask/activityTask to fill it based on the response.
Instead expose a helper function such as:

func (wt *workflowTask) GetAutoConfigHint() *s.AutoConfigHint {
   if wt.task == nil {
     return nil
  }
  return wt.task.GetAutoConfigHint()

Less code to write and maintain.

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah, I checked carefully. We can populate this task field for empty polls. Thus I've changed the title as well.

@shijiesheng shijiesheng changed the title Add AutoConfigHint field for internal workflowTask and activityTask Populate tasks in internal workflowTask and activityTask entities for empty polls Jan 16, 2025
common.PtrOf(int64(1000)),
},
}
for _, tt := range []struct {
Copy link
Member

Choose a reason for hiding this comment

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

let's also add nil cases

Copy link
Member Author

Choose a reason for hiding this comment

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

It's actually not possible for client to return nil, nil for both response and error so I'll skip the test

@shijiesheng shijiesheng merged commit d9dcddc into cadence-workflow:master Jan 17, 2025
9 of 10 checks passed
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.

3 participants