public NacosServiceRegistry(INacosNamingClient nacosClient, NacosDiscoveryOptions options, INacosScheduler scheduler = null, ILogger <NacosServiceRegistry> logger = null)
 {
     _scheduler   = scheduler;
     _options     = options ?? throw new ArgumentNullException(nameof(options));
     _nacosClient = nacosClient;
     _logger      = logger;
 }
示例#2
0
        internal static string GetAppName(NacosDiscoveryOptions options, IConfiguration config)
        {
            string appName = options.ServiceName;

            if (!string.IsNullOrEmpty(appName))
            {
                return(appName);
            }

            return(config.GetValue("spring:application:name", "application"));
        }
示例#3
0
        internal static bool GetHealthy(NacosDiscoveryOptions options, IConfiguration config)
        {
            bool?ephemeral = options.Healthy;

            if (!ephemeral.HasValue)
            {
                return(true);
            }


            return(ephemeral.Value);
        }
示例#4
0
        public static NacosRegistration CreateRegistration(IConfiguration config, NacosDiscoveryOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }

            return(new NacosRegistration(GetAppName(options, config), options.IpAddress, options.Cluster, options.Enabled, GetEphemeral(options, config), options.GroupName, GetHealthy(options, config), options.IsSecure, options.Namespace, options.Port));
        }
示例#5
0
 public NacosDiscoveryClient(NacosDiscoveryOptions options
                             , INacosNamingClient nacosNamingClient
                             , INacosServiceRegistrar registrar    = null,
                             ILogger <NacosDiscoveryClient> logger = null
                             )
 {
     _client      = nacosNamingClient ?? throw new ArgumentNullException(nameof(nacosNamingClient));
     _options     = options ?? throw new ArgumentNullException(nameof(options));
     this._logger = logger;
     //_thisServiceInstance = new ThisServiceInstance(options);
     _registrar = registrar;
     if (_registrar != null)
     {
         _registrar.Start();
         _thisServiceInstance = new ThisServiceInstance(_registrar.Registration);
     }
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="NacosHealthContributor"/> class.
 /// </summary>
 /// <param name="client">a Nacos client to use for health checks</param>
 /// <param name="options">configuration options</param>
 /// <param name="logger">optional logger</param>
 public NacosHealthContributor(INacosNamingClient client, NacosDiscoveryOptions options, ILogger <NacosHealthContributor> logger = null)
 {
     _client  = client ?? throw new ArgumentNullException(nameof(client));
     _options = options ?? throw new ArgumentNullException(nameof(options));
     _logger  = logger;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="NacosTtlScheduler"/> class.
 /// </summary>
 /// <param name="options">configuration options</param>
 /// <param name="client">the Consul client</param>
 /// <param name="logger">optional logger</param>
 public NacosTtlScheduler(NacosDiscoveryOptions options, INacosNamingClient client, ILogger <NacosTtlScheduler> logger = null)
 {
     _options = options;
     _client  = client;
     _logger  = logger;
 }