Open ling921 opened 10 months ago
@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
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.
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
calledStartWorkflowWithScope
, which accept an additional parameterIServiceScope
, and then save it inWorkflowInstance
Tests
Yes
Breaking change
No
Additional context
None