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 Request: Integrate ObjectPool into Dependency Injection #55367

Open
1 task done
grochoge opened this issue Apr 25, 2024 · 4 comments
Open
1 task done

Feature Request: Integrate ObjectPool into Dependency Injection #55367

grochoge opened this issue Apr 25, 2024 · 4 comments
Labels
api-suggestion Early API idea and discussion, it is NOT ready for implementation area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions

Comments

@grochoge
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

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

Right now if a service/etc wants to use an object from a Microsoft.Extensions.ObjectPool, it needs to know it's getting a pooled object.

There's also no way to customize service resolution and dispose behavior of the dependency injection machinery.

Describe the solution you'd like

Provide a way to automatically resolve a service from an object pool and return at the end of a scope (checking IResettable.TryReset if applicable). Perhaps something like a .AddPooled<IExampleService, ExampleService>( maxCount: 10 ) as an alternative to .AddScoped<IExampleService,ExampleService>().

Or at least provide customization hooks in the DI machinery so we can implement this ourselves.

Additional context

No response

@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label Used by the dotnet-issue-labeler to label those issues which couldn't be triaged automatically label Apr 25, 2024
@gfoidl gfoidl added area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions api-suggestion Early API idea and discussion, it is NOT ready for implementation and removed needs-area-label Used by the dotnet-issue-labeler to label those issues which couldn't be triaged automatically labels Apr 26, 2024
@amcasey
Copy link
Member

amcasey commented Apr 29, 2024

I suspect DI pooling has come up before. @halter73?

@amcasey amcasey changed the title Feature Request: Integrate ObjectPool into Depdendency Injection Feature Request: Integrate ObjectPool into Dependency Injection Apr 29, 2024
@davidfowl
Copy link
Member

https://www.nuget.org/packages/Microsoft.Extensions.ObjectPool.DependencyInjection/

@amcasey
Copy link
Member

amcasey commented Apr 29, 2024

Thanks, @davidfowl! Good to go, @grochoge?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-suggestion Early API idea and discussion, it is NOT ready for implementation area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions
Projects
None yet
Development

No branches or pull requests

4 participants