public static ZookeeperConfig GetZookeeperConfig() { var env = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT"); if (!string.IsNullOrWhiteSpace(env) && Clusters.ContainsKey(env)) { return(Clusters[env]); } return(Clusters["GDEV"]); }
/// <summary> /// 获取集群执行器 /// </summary> /// <param name="invocation"></param> /// <returns></returns> private ICluster GetCluster(IInvocation invocation) { var result = Clusters[FailoverCluster.NAME]; var key = this.Address.GetMethodParameter(invocation.MethodInfo.Name, CLUSTER_KEY, ""); if (string.IsNullOrEmpty(key) || key == FailoverCluster.NAME) { key = this.Address.GetInterfaceParameter(invocation.TargetType.FullName, CLUSTER_KEY, ""); } if (Clusters.ContainsKey(key) && key != FailoverCluster.NAME) { result = Clusters[key]; } //result.Pool = GetClientPool(invocation); //result.Address = this.Address; return(result); }
public Cluster this[string clusterName] { get { if (!Clusters.ContainsKey(clusterName)) { throw new ArgumentException(); } return(Clusters[clusterName]); } set { if (!Clusters.ContainsKey(clusterName)) { throw new ArgumentException(); } Clusters[clusterName] = value; } }
/// <summary> /// 获取集群执行器 /// </summary> /// <param name="invocation"></param> /// <returns></returns> private ICluster GetCluster(IInvocation invocation) { var result = Clusters[FailoverCluster.NAME]; var key = this.Address.GetMethodParameter($"{invocation.TargetType.FullName}.{ invocation.MethodInfo.Name }", CLUSTER_KEY, ""); if (string.IsNullOrEmpty(key)) { key = this.Address.GetInterfaceParameter(invocation.TargetType.FullName, CLUSTER_KEY, ""); } if (string.IsNullOrEmpty(key)) { key = this.Address.GetParameter(CLUSTER_KEY, ""); } if (!string.IsNullOrEmpty(key) && Clusters.ContainsKey(key) && key != FailoverCluster.NAME) { result = Clusters[key]; } return(result); }