Skip to content

Conversation

timl3136
Copy link
Member

What changed?
integrate decision handler into worker

Why?
now that handler is implemented, we will integrate that with decision worker

How did you test it?
unit test

Potential risks

Release notes

Documentation Changes

@timl3136 timl3136 changed the title integrate decision handler into worker Integrate decision handler into worker Sep 16, 2025
Signed-off-by: Tim Li <ltim@uber.com>
Signed-off-by: Tim Li <ltim@uber.com>
Signed-off-by: Tim Li <ltim@uber.com>
# Deserialize the input using the client's data converter
try:
# Use from_data method with a single type hint of None (no type conversion)
input_data_list = await self._context.client().data_converter.from_data(started_attrs.input, [None])
Copy link
Member

Choose a reason for hiding this comment

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

type hints are needed here. I recommend creating a WorkflowDefinition class similar to activitydefinition. And pass it from registry.

timl3136 and others added 6 commits September 22, 2025 15:47
Signed-off-by: Tim Li <ltim@uber.com>
Signed-off-by: Tim Li <ltim@uber.com>
Signed-off-by: Tim Li <ltim@uber.com>
Signed-off-by: Tim Li <ltim@uber.com>
Copy link
Member

@shijiesheng shijiesheng left a comment

Choose a reason for hiding this comment

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

DecisionTaskHandler should not have WorkflowEngine field but instead will have a cache to hold workflowEngines. DecisionWorker will be multithreaded on handling decision tasks and handler needs to be threadsafe.

@shijiesheng shijiesheng self-requested a review October 2, 2025 18:28
"task_token": task.task_token[:16].hex() if task.task_token else None
}
)
except Exception as e:
Copy link
Member

Choose a reason for hiding this comment

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

error needs to be thrown out

Copy link
Member Author

Choose a reason for hiding this comment

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

For this part, I think we actually don't need to raise error here since if decision task failure responses failed to sent to server, it will timeout and retry the decision task anyway, there is no need to disrupt the worker's execution flow as that would be counterproductive

Signed-off-by: Tim Li <ltim@uber.com>
Signed-off-by: Tim Li <ltim@uber.com>
)
# Use thread-safe cache to get or create workflow engine
cache_key = (workflow_id, run_id)
with self._cache_lock:
Copy link
Member

Choose a reason for hiding this comment

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

current cache is unbounded. We need a LFU cache here. Maybe add a TODO for next PR

Signed-off-by: Tim Li <ltim@uber.com>
Signed-off-by: Tim Li <ltim@uber.com>
@timl3136 timl3136 merged commit 7a49de6 into cadence-workflow:main Oct 3, 2025
5 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.

2 participants