Skip to content

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

// 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
mrombout pushed a commit to softsense/cadence-client that referenced this pull request Feb 26, 2025
… empty polls (cadence-workflow#1416)

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
shijiesheng added a commit to shijiesheng/cadence-client that referenced this pull request Jun 2, 2025
shijiesheng added a commit that referenced this pull request Jun 3, 2025
…ties for empty polls (#1416)" (#1424)

This reverts commit d9dcddc.

What changed?

A pure revert of d9dcddc#diff-caac3c5868c1fd134487cacc53e459b7375722e23c6aba3e9407521feba00007

Why?

Nilness check is no longer enough after the commit

One alternative is to add additional emptiness check. This makes the client code error prone. Thus, a pure revert is desired.

How did you test it?

Unit Test
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