public static void AddConsul(this IServiceCollection services, ConsulOptions consulOptions)
 {
     //注册consul配置
     services.AddSingleton(consulOptions);
     //注册consul同步服务
     services.AddHostedService <ConsulHostedService>();
     //httpclient
     services.AddTransient <ConsulHttpClient>();
 }
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="logger"></param>
 public ConsulHostedService(ILogger <ConsulHostedService> logger, IApplicationLifetime lifetime, ConsulOptions consulOptions)
 {
     _logger       = logger;
     _lifetime     = lifetime;
     _consulConfig = consulOptions;
     //应用服务ip,未配置则默认系统自动获取应用所在机器地址
     if (string.IsNullOrEmpty(_consulConfig.ServiceAddress))
     {
         _consulConfig.ServiceAddress = GetAddress();
     }
 }