From a7c7c23182bf73b9078f499fb7eca812e9dfc6b2 Mon Sep 17 00:00:00 2001 From: Sascha Kiefer Date: Thu, 20 Jul 2023 16:47:51 +0200 Subject: [PATCH] feat: allow passing the service-provider to the connection builder function --- .../SignalRHealthCheckBuilderExtensions.cs | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/HealthChecks.SignalR/DependencyInjection/SignalRHealthCheckBuilderExtensions.cs b/src/HealthChecks.SignalR/DependencyInjection/SignalRHealthCheckBuilderExtensions.cs index e3550c3220..a21baa84df 100644 --- a/src/HealthChecks.SignalR/DependencyInjection/SignalRHealthCheckBuilderExtensions.cs +++ b/src/HealthChecks.SignalR/DependencyInjection/SignalRHealthCheckBuilderExtensions.cs @@ -75,4 +75,34 @@ public static IHealthChecksBuilder AddSignalRHub( tags, timeout)); } + + /// + /// Add a health check for SignalR. + /// + /// The . + /// The SignalR hub connection builder factory to be used. + /// The health check name. Optional. If null the type name 'signalr' will be used for the name. + /// + /// The that should be reported when the health check fails. Optional. If null then + /// the default status of will be reported. + /// + /// A list of tags that can be used to filter sets of health checks. Optional. + /// An optional representing the timeout of the check. + /// The specified . + public static IHealthChecksBuilder AddSignalRHub( + this IHealthChecksBuilder builder, + Func> hubConnectionBuilderFactory, + string? name = default, + HealthStatus? failureStatus = default, + IEnumerable? tags = default, + TimeSpan? timeout = default) + { + return builder.Add( + new HealthCheckRegistration( + name ?? NAME, + sp => new SignalRHealthCheck(hubConnectionBuilderFactory(sp)), + failureStatus, + tags, + timeout)); + } }