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

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

Open
ling921 opened this issue Jan 27, 2024 · 1 comment

Comments

@ling921
Copy link

ling921 commented Jan 27, 2024

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.

@ling921 ling921 changed the title [Proposal] Add custom IServiceScope support so that Step only accesses service instances of this scope [Proposal] Add IServiceScope support so that steps can get same service instances from this scope Jan 27, 2024
@vladimir-kovalyuk
Copy link

vladimir-kovalyuk commented Mar 21, 2024

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.

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

No branches or pull requests

2 participants