Provide access to service factory when registering async health check
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 281
Description
### Is your feature request related to a problem? Please describe.
When registering an async health check, I would like to have access to the service factory so that I can get my health checks to call dependencies that are resolved by the service factory.
### Describe the solution you'd like
AddAsyncCheck to be able to resolve services via IoC
### Describe alternatives you've considered
Copy DelegateHealthCheck from the extensions library and make it public. Then do the following:
```
services.Add(new HealthCheckRegistration("bing", provider =>
{
return new DelegateHealthCheck(async token =>
{
var bing = provider.GetService();
var bingSearchResponse = await bing.Find(new SearchCriteria("London", CountryCode.GB));
return bingSearchResponse.Count > 0
? new HealthCheckResult(HealthStatus.Healthy, "Bing is there!")
: new HealthCheckResult(HealthStatus.Unhealthy, "Bing gone walkies!");
});
}, null, new string[] {"liveness-external"}));
```
Contributor guide
Assessment
This issue has not been assessed yet.