public ConsulConfigurationProvider(IConsulConfigurationSource source, ConsulConfigurationParser configurationParser) { this.configurationParser = configurationParser; this.source = source; if (source.ReloadOnChange) { ChangeToken.OnChange( () => this.configurationParser.Watch(this.source.ServiceKey, this.source.CancellationToken), async() => { Console.WriteLine("--------- SyZero.Consul:检测到配置变更 => 开始重新加载配置"); await this.configurationParser.GetConfig(true, source).ConfigureAwait(false); Thread.Sleep(source.ReloadDelay); this.Load(); Console.WriteLine("--------- SyZero.Consul:检测到配置变更 => 完成"); this.OnReload(); }); } }
public IConfigurationProvider Build(IConfigurationBuilder builder) { ConsulConfigurationParser consulParser = new ConsulConfigurationParser(this); return(new ConsulConfigurationProvider(this, consulParser)); }