Feature Request: Integrate ObjectPool into Dependency Injection #55367
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
Is there an existing issue for this?
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
The text was updated successfully, but these errors were encountered: