Esempio n. 1
0
 public RegSvcBgTask(
     ILoggerFactory loggerFactory,
     INacosNamingService svc,
     IServer server,
     IOptionsMonitor <NacosAspNetOptions> optionsAccs)
 {
     _logger   = loggerFactory.CreateLogger <RegSvcBgTask>();
     _svc      = svc;
     _options  = optionsAccs.CurrentValue;
     _features = server.Features;
 }
        /// <summary>
        /// Add Nacos AspNet. This will register and de-register instance automatically.
        /// Mainly for nacos server 2.x
        /// </summary>
        /// <param name="services">services</param>
        /// <param name="optionsAccs">optionsAccs</param>
        /// <returns>IServiceCollection</returns>
        public static IServiceCollection AddNacosAspNet(this IServiceCollection services, Action <NacosAspNetOptions> optionsAccs)
        {
            services.Configure(optionsAccs);

            var options = new NacosAspNetOptions();

            optionsAccs.Invoke(options);
            services.AddNacosV2Naming(x => options.BuildSdkOptions());
            services.AddSingleton <RegSvcBgTask>();

            return(services);
        }