Exemplo n.º 1
0
        /// <summary>
        /// 通过服务名获取地址。(Consul目录:ServiceAddress)
        /// </summary>
        public static string GetAddress(string srvName, string defaultAddress, bool readAppSetting = false)
        {
            var catKey = $"{Catalog}/{srvName}";

            return(readAppSetting
                ? CentralConfiguration.GetAppSetting(srvName, CentralConfiguration.Get(catKey, defaultAddress))
                : CentralConfiguration.Get(catKey, defaultAddress));
        }
Exemplo n.º 2
0
 /// <summary>
 /// 获取外部服务设置,如MQ、缓存等。(Consul目录:ExternalService)。<br />
 /// readAppSetting 是否优先读取本地配置。
 /// </summary>
 public static string GetExternalSrvSet(string key, string defaultSet = null, bool readAppSetting = false)
 {
     if (readAppSetting)
     {
         var localSet = CentralConfiguration.GetAppSetting(key);
         if (localSet.NotNull())
         {
             return(localSet);
         }
     }
     return(CentralConfiguration.Get($"{ExternalCatalog}/{key}", defaultSet));
 }
Exemplo n.º 3
0
 /// <summary>
 /// 获取当前部署的服务名称,同一服务部署多个实例时,保持唯一,如:MimsDataBroker1,MimsDataBroker2
 /// </summary>
 public static string GetDeployServiceName(string defaultName)
 {
     return(CentralConfiguration.GetAppSetting("DeployServiceName", defaultName));
 }