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

[Feature] Add scope support for workflow #1232

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ling921
Copy link

@ling921 ling921 commented Jan 27, 2024

Describe the change

This pull request is to make Step to only obtain services from a specific scope.

Related issues: #1231 #846

Describe your implementation or design

Add a method to IWorkflowController called StartWorkflowWithScope, which accept an additional parameter IServiceScope, and then save it in WorkflowInstance

Tests

Yes

Breaking change

No

Additional context

None

@danielgerlag
Copy link
Owner

@ling921 thanks for the effort. Unfortunately, this does not make sense to wrap an entire workflow in a scope. When the workflow is executed, the entire thing "may" be executed all at once, or it may be partially executed and continue several days later, or on another machine. So we cannot preserve the scope across these time and node boundaries.
We do wrap step executions within a scope here

@ling921
Copy link
Author

ling921 commented Jan 28, 2024

I understand this, and I haven't changed its default behavior. If users expect wrokflow steps to be executed within a certain scope, they should manage the creation and disposal of the scope themselves.

Also, I think the design of this scope is meaningful. I can define a scoped service to track or change the step's execution, and even share some unmanaged resources, etc. All of these are more suitable to be written in a service rather than within TData.

The primary challenge is ensuring the effective management of the scope, especially regarding proper disposal. In my current design, it is imperative for the user to proficiently handle scope disposal. With correct scope disposal, I believe there should be no issues with long-term retention.

There may be a more optimal design that can achieve this.

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.

None yet

2 participants