基于所有具有一定界面的服务,动态创建健康检查
我有一系列检查数据的服务,所有服务都在“ idatacheck”接口下。
idatachecks是一个空的接口,它
在命令行应用程序中使用一种方法“ runcheckAsync”:
IEnumerable<IDataCheck>? services = _serviceProvider.GetServices<IDataCheck>();
foreach (IDataCheck? s in services)
{
DataCheckResult result = await s.RunCheckAsync();
// all kinds of stuff with the result such as proposing to autofix
}
我现在也想使用healthcheck ui,ref:
- https:// https:// https://learlearn.microsoft.com/en -us/aspnet/core/host-and-deploy/health-checks?view = aspnetcore-6.0
- https://github.com/xabaril/aspnetcore.diagnostics.diagnostics.healthchecks
不想通过数据检查手动创建健康检查
我 要创建一个HealthCheck,否则它将在UI中仅在一个文本列中产生一长串结果,因为它不支持任何格式。
I have a long set of services that check data, and all under the interface "IDataCheck".
IDataChecks is an empty interface with one method "runCheckAsync"
In a commandline app I do:
IEnumerable<IDataCheck>? services = _serviceProvider.GetServices<IDataCheck>();
foreach (IDataCheck? s in services)
{
DataCheckResult result = await s.RunCheckAsync();
// all kinds of stuff with the result such as proposing to autofix
}
I now want to also present the results of these checks in asp.net core healtchecks using also the healthcheck ui, ref:
- https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/health-checks?view=aspnetcore-6.0
- https://github.com/Xabaril/AspNetCore.Diagnostics.HealthChecks
I do not want to create manually a healthcheck per data check because otherwise the usefulness of having an interface is gone
I also do not want to create one healthcheck only otherwise it will produce a long list of results all in one text only column in the ui since it does not support any formatting.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在“ webapplication app = builder.build();”之前,在宗师的评论的帮助下解决了这一点。打电话:
然后在Healtcheck本身中:
Solved this , with help from the comment from Guru, on the line before "WebApplication app = builder.Build();" to call:
and then in the healtcheck itself :