Example #1
0
        /// <summary> 使用Consul配置中心 </summary>
        /// <param name="manager"></param>
        public static void UseConsul(this ConfigManager manager)
        {
            //配置中心
            var provider = new ConsulConfigProvider();

            manager.Build(b => b.Add(provider));
            manager.ConfigChanged += provider.Reload;
        }
Example #2
0
        /// <summary> 使用Consul配置中心 </summary>
        /// <param name="manager"></param>
        public static ISpearConfigBuilder AddConsulConfig(this ISpearConfigBuilder builder)
        {
            //配置中心
            var provider = new ConsulConfigProvider();
            var t        = builder.Sources.FirstOrDefault(c => c is ConsulConfigProvider);

            if (t != null)
            {
                builder.Sources.Remove(t);
            }
            builder.Sources.Insert(0, provider);
            return(builder);
        }