diff --git a/src/DotNetCore.CAP/NodeDiscovery/CAP.DiscoveryOptions.cs b/src/DotNetCore.CAP/NodeDiscovery/CAP.DiscoveryOptions.cs index 70d1c71..aeadd5e 100644 --- a/src/DotNetCore.CAP/NodeDiscovery/CAP.DiscoveryOptions.cs +++ b/src/DotNetCore.CAP/NodeDiscovery/CAP.DiscoveryOptions.cs @@ -26,6 +26,8 @@ public string CurrentNodeHostName { get; set; } public int CurrentNodePort { get; set; } + + public int NodeId { get; set; } public string NodeName { get; set; } public string MatchPath { get; set; } } diff --git a/src/DotNetCore.CAP/NodeDiscovery/INodeDiscoveryProvider.Consul.cs b/src/DotNetCore.CAP/NodeDiscovery/INodeDiscoveryProvider.Consul.cs index 1e05533..e0f197b 100644 --- a/src/DotNetCore.CAP/NodeDiscovery/INodeDiscoveryProvider.Consul.cs +++ b/src/DotNetCore.CAP/NodeDiscovery/INodeDiscoveryProvider.Consul.cs @@ -4,11 +4,11 @@ using System.Collections.Generic; using System.Text; using System.Threading.Tasks; using Consul; -using System.Security.Cryptography; +using System.Net; namespace DotNetCore.CAP.NodeDiscovery { - class ConsulNodeDiscoveryProvider : INodeDiscoveryProvider, IDisposable + public class ConsulNodeDiscoveryProvider : INodeDiscoveryProvider, IDisposable { private ConsulClient _consul; private readonly DiscoveryOptions _options; @@ -34,6 +34,7 @@ namespace DotNetCore.CAP.NodeDiscovery var nodes = services.Response.Select(x => new Node { + Id = x.Key, Name = x.Value.Service, Address = x.Value.Address, Port = x.Value.Port, @@ -47,6 +48,7 @@ namespace DotNetCore.CAP.NodeDiscovery { return _consul.Agent.ServiceRegister(new AgentServiceRegistration { + ID = _options.NodeId.ToString(), Name = _options.NodeName, Address = _options.CurrentNodeHostName, Port = _options.CurrentNodePort, diff --git a/src/DotNetCore.CAP/NodeDiscovery/INodeDiscoveryProvider.cs b/src/DotNetCore.CAP/NodeDiscovery/INodeDiscoveryProvider.cs index 06ff5aa..c9a3720 100644 --- a/src/DotNetCore.CAP/NodeDiscovery/INodeDiscoveryProvider.cs +++ b/src/DotNetCore.CAP/NodeDiscovery/INodeDiscoveryProvider.cs @@ -5,7 +5,7 @@ using System.Threading.Tasks; namespace DotNetCore.CAP.NodeDiscovery { - interface INodeDiscoveryProvider + public interface INodeDiscoveryProvider { Task> GetNodes(); diff --git a/src/DotNetCore.CAP/NodeDiscovery/Node.cs b/src/DotNetCore.CAP/NodeDiscovery/Node.cs index c77d1d9..fd3d382 100644 --- a/src/DotNetCore.CAP/NodeDiscovery/Node.cs +++ b/src/DotNetCore.CAP/NodeDiscovery/Node.cs @@ -4,7 +4,7 @@ using System.Text; namespace DotNetCore.CAP.NodeDiscovery { - class Node + public class Node { public string Id { get; set; }