Skip to content

Commit

Permalink
feat: allow passing the service-provider to the connection builder fu…
Browse files Browse the repository at this point in the history
…nction
  • Loading branch information
esskar committed Jul 20, 2023
1 parent 46951f1 commit a7c7c23
Showing 1 changed file with 30 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));
}
}

0 comments on commit a7c7c23

Please sign in to comment.