Skip to content

Commit

Permalink
Consul Diagnostics (#1828)
Browse files Browse the repository at this point in the history
  • Loading branch information
rogeralsing authored Oct 19, 2022
1 parent 0532178 commit 3aa0ca3
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/Proto.Cluster.Consul/ConsulProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using JetBrains.Annotations;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Proto.Diagnostics;

namespace Proto.Cluster.Consul;
//TLDR;
Expand Down Expand Up @@ -49,6 +50,26 @@ private readonly TimeSpan
private int _port;
private bool _shutdown;

public async Task<DiagnosticsEntry[]> GetDiagnostics()
{
try
{
var statuses = await _client.Health.Service(_consulServiceName, null, false, new QueryOptions
{

}
, _cluster.System.Shutdown
);

var health = new DiagnosticsEntry("ConsulProvider", "Services", statuses.Response);
return new[] { health };
}
catch (Exception x)
{
return new[] { new DiagnosticsEntry("ConsulProvider", "Exception", x.ToString() ) };
}
}

public ConsulProvider(ConsulProviderConfig config) : this(config, _ => { })
{
}
Expand Down

0 comments on commit 3aa0ca3

Please sign in to comment.