Support asyncronous connection creation in DI
- Dominant language
- C#
- Stars
- 6.3k
- Forks
- 991
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 196
Description
### Is there an existing issue for this?
- [x] I have searched the existing issues
### Is your feature request related to a problem? Please describe the problem.
Currently Aspire is putting long lived connection objects in DI as singletons, like `ConnectionMultiplexer` for Redis. This ultimately forces the app to establish the connection(s) before the app can start its own bootstrapping logic, delaying the time before it can serve its first response.
This was discussed in #565.
### Describe the solution you'd like
I would like to request that Aspire registers a shim that can lazily establish the connection when asked for. It could be as simple as `Task` or an interface that contains method along the lines of `ValueTask GetAsync()`.
This is the first suggestion of #565.
### Additional context
We have observed that registering a shim and egarly establishing the connection in parallel to the app startup reduces the time of first response by about two seconds.
Contributor guide
Assessment
This issue has not been assessed yet.