Skip to content

Commit

Permalink
Fix for memory leak in NATS (#1217)
Browse files Browse the repository at this point in the history
  • Loading branch information
sungam3r authored Jun 3, 2022
1 parent 557c28d commit 932e036
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
3 changes: 1 addition & 2 deletions samples/HealthChecks.UI.Branding/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
}
}

public class RandomHealthCheck
: IHealthCheck
public class RandomHealthCheck : IHealthCheck
{
public Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,12 @@ public static IHealthChecksBuilder AddNats(
var options = new NatsOptions();
setup?.Invoke(options);

builder.Services
.AddSingleton(sp => new NatsHealthCheck(options));

return builder.Add(new HealthCheckRegistration(
name ?? NAME,
sp => new NatsHealthCheck(options),
sp => sp.GetRequiredService<NatsHealthCheck>(),
failureStatus,
tags,
timeout));
Expand Down
2 changes: 1 addition & 1 deletion src/HealthChecks.Nats/NatsHealthCheck.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace HealthChecks.Nats
/// </remarks>
public sealed class NatsHealthCheck : IHealthCheck, IDisposable
{
private static readonly ConnectionFactory _connectionFactory = new ConnectionFactory();
private static readonly ConnectionFactory _connectionFactory = new();

private readonly NatsOptions _options;

Expand Down

0 comments on commit 932e036

Please sign in to comment.