Selaa lähdekoodia

add NodeId config to options.

master
Savorboard 7 vuotta sitten
vanhempi
commit
90ee75c3f9
4 muutettua tiedostoa jossa 8 lisäystä ja 4 poistoa
  1. +2
    -0
      src/DotNetCore.CAP/NodeDiscovery/CAP.DiscoveryOptions.cs
  2. +4
    -2
      src/DotNetCore.CAP/NodeDiscovery/INodeDiscoveryProvider.Consul.cs
  3. +1
    -1
      src/DotNetCore.CAP/NodeDiscovery/INodeDiscoveryProvider.cs
  4. +1
    -1
      src/DotNetCore.CAP/NodeDiscovery/Node.cs

+ 2
- 0
src/DotNetCore.CAP/NodeDiscovery/CAP.DiscoveryOptions.cs Näytä tiedosto

@@ -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; }
}


+ 4
- 2
src/DotNetCore.CAP/NodeDiscovery/INodeDiscoveryProvider.Consul.cs Näytä tiedosto

@@ -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,


+ 1
- 1
src/DotNetCore.CAP/NodeDiscovery/INodeDiscoveryProvider.cs Näytä tiedosto

@@ -5,7 +5,7 @@ using System.Threading.Tasks;

namespace DotNetCore.CAP.NodeDiscovery
{
interface INodeDiscoveryProvider
public interface INodeDiscoveryProvider
{
Task<IList<Node>> GetNodes();



+ 1
- 1
src/DotNetCore.CAP/NodeDiscovery/Node.cs Näytä tiedosto

@@ -4,7 +4,7 @@ using System.Text;

namespace DotNetCore.CAP.NodeDiscovery
{
class Node
public class Node
{
public string Id { get; set; }



Ladataan…
Peruuta
Tallenna