Skip to content

Commit

Permalink
Provide overload with IServiceProvider to AddSignalRHub (#1965)
Browse files Browse the repository at this point in the history
* feat: allow passing the service-provider to the connection builder function

(cherry picked from commit a7c7c23)

* api approval

---------

Co-authored-by: Sascha Kiefer <esskar@gmail.com>
  • Loading branch information
sungam3r and esskar committed Jul 30, 2023
1 parent 4c47bc2 commit 630800c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,34 @@ public static IHealthChecksBuilder AddSignalRHub(
tags,
timeout));
}

/// <summary>
/// Add a health check for SignalR.
/// </summary>
/// <param name="builder">The <see cref="IHealthChecksBuilder"/>.</param>
/// <param name="hubConnectionBuilderFactory">The SignalR hub connection builder factory to be used.</param>
/// <param name="name">The health check name. Optional. If <c>null</c> the type name 'signalr' will be used for the name.</param>
/// <param name="failureStatus">
/// The <see cref="HealthStatus"/> that should be reported when the health check fails. Optional. If <c>null</c> then
/// the default status of <see cref="HealthStatus.Unhealthy"/> will be reported.
/// </param>
/// <param name="tags">A list of tags that can be used to filter sets of health checks. Optional.</param>
/// <param name="timeout">An optional <see cref="TimeSpan"/> representing the timeout of the check.</param>
/// <returns>The specified <paramref name="builder"/>.</returns>
public static IHealthChecksBuilder AddSignalRHub(
this IHealthChecksBuilder builder,
Func<IServiceProvider, Func<HubConnection>> hubConnectionBuilderFactory,
string? name = default,
HealthStatus? failureStatus = default,
IEnumerable<string>? tags = default,
TimeSpan? timeout = default)
{
return builder.Add(
new HealthCheckRegistration(
name ?? NAME,
sp => new SignalRHealthCheck(hubConnectionBuilderFactory(sp)),
failureStatus,
tags,
timeout));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace Microsoft.Extensions.DependencyInjection
public static class SignalRHealthCheckBuilderExtensions
{
public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddSignalRHub(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, System.Func<Microsoft.AspNetCore.SignalR.Client.HubConnection> hubConnectionBuilder, string? name = null, Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus? failureStatus = default, System.Collections.Generic.IEnumerable<string>? tags = null, System.TimeSpan? timeout = default) { }
public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddSignalRHub(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, System.Func<System.IServiceProvider, System.Func<Microsoft.AspNetCore.SignalR.Client.HubConnection>> hubConnectionBuilderFactory, string? name = null, Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus? failureStatus = default, System.Collections.Generic.IEnumerable<string>? tags = null, System.TimeSpan? timeout = default) { }
public static Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder AddSignalRHub(this Microsoft.Extensions.DependencyInjection.IHealthChecksBuilder builder, string url, string? name = null, Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus? failureStatus = default, System.Collections.Generic.IEnumerable<string>? tags = null, System.TimeSpan? timeout = default) { }
}
}

0 comments on commit 630800c

Please sign in to comment.