Quellcode durchsuchen

support consul service check for https (#722)

master
zhangq vor 4 Jahren
committed by GitHub
Ursprung
Commit
8946ca33af
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden GPG-Schlüssel-ID: 4AEE18F83AFDEB23
2 geänderte Dateien mit 20 neuen und 9 gelöschten Zeilen
  1. +6
    -0
      src/DotNetCore.CAP.Dashboard/NodeDiscovery/CAP.DiscoveryOptions.cs
  2. +14
    -9
      src/DotNetCore.CAP.Dashboard/NodeDiscovery/INodeDiscoveryProvider.Consul.cs

+ 6
- 0
src/DotNetCore.CAP.Dashboard/NodeDiscovery/CAP.DiscoveryOptions.cs Datei anzeigen

@@ -13,6 +13,8 @@ namespace DotNetCore.CAP.Dashboard.NodeDiscovery

public const string DefaultMatchPath = "/cap";

public const string DefaultScheme = "http";

public DiscoveryOptions()
{
DiscoveryServerHostName = DefaultDiscoveryServerHost;
@@ -22,6 +24,8 @@ namespace DotNetCore.CAP.Dashboard.NodeDiscovery
CurrentNodePort = DefaultCurrentNodePort;

MatchPath = DefaultMatchPath;

Scheme = DefaultScheme;
}

public string DiscoveryServerHostName { get; set; }
@@ -34,5 +38,7 @@ namespace DotNetCore.CAP.Dashboard.NodeDiscovery
public string NodeName { get; set; }

public string MatchPath { get; set; }

public string Scheme { get; set; }
}
}

+ 14
- 9
src/DotNetCore.CAP.Dashboard/NodeDiscovery/INodeDiscoveryProvider.Consul.cs Datei anzeigen

@@ -69,21 +69,26 @@ namespace DotNetCore.CAP.Dashboard.NodeDiscovery
{
try
{
var healthCheck = new AgentServiceCheck
{
DeregisterCriticalServiceAfter = TimeSpan.FromSeconds(30),
Interval = TimeSpan.FromSeconds(10),
Status = HealthStatus.Passing
};

if (_options.Scheme.Equals("http", StringComparison.OrdinalIgnoreCase))
healthCheck.HTTP = $"http://{_options.CurrentNodeHostName}:{_options.CurrentNodePort}{_options.MatchPath}/health";
else if (_options.Scheme.Equals("https", StringComparison.OrdinalIgnoreCase))
healthCheck.TCP = $"{_options.CurrentNodeHostName}:{_options.CurrentNodePort}";

return _consul.Agent.ServiceRegister(new AgentServiceRegistration
{
ID = _options.NodeId,
Name = _options.NodeName,
Address = _options.CurrentNodeHostName,
Port = _options.CurrentNodePort,
Tags = new[] {"CAP", "Client", "Dashboard"},
Check = new AgentServiceCheck
{
DeregisterCriticalServiceAfter = TimeSpan.FromSeconds(30),
Interval = TimeSpan.FromSeconds(10),
Status = HealthStatus.Passing,
HTTP =
$"http://{_options.CurrentNodeHostName}:{_options.CurrentNodePort}{_options.MatchPath}/health"
}
Tags = new[] { "CAP", "Client", "Dashboard" },
Check = healthCheck
});
}
catch (Exception ex)


Laden…
Abbrechen
Speichern