danielgerlag/workflow-core

[Proposal] Add IServiceScope support so that steps can get same service instances from this scope

ling921 opened this issue · 1 comments

Is your feature request related to a problem? Please describe.

I have a scoped service IMyService and get an IMyService instance from a scope, I hope that all steps will obtain the same IMyService instance when the workflow is running. This can prevent the services between multiple workflows from interfering with each other.

Describe the solution you'd like

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

Describe alternatives you've considered

None

Additional context

I would like to make a pull request for this.

From my perspective what you would like to achieve is not guaranteed within the resilient long running process. The host may execute the half of steps then get restarted and continue executing the rest of steps. So you can not rely on the WFC hoping that it would provide the same IMyService for all steps.
You may inject IServiceScope and IServiceScopeFactory into your step. Maybe these interfaces being injected would help you with your needs?
BTW, not sure Workflow-Core project is alive.