From e4509b340160d026ed2fa94c3dcee16c66eaa035 Mon Sep 17 00:00:00 2001 From: pengganyu <peng_gy@163.com> Date: Tue, 10 Nov 2020 11:12:15 +0800 Subject: [PATCH] Add feature: rename func name : GetParamInt0 -> GetParamIntValue --- cluster/cluster_impl/forking_cluster_invoker.go | 2 +- cluster/loadbalance/consistent_hash.go | 2 +- common/url.go | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cluster/cluster_impl/forking_cluster_invoker.go b/cluster/cluster_impl/forking_cluster_invoker.go index be3203070..3ffda580c 100644 --- a/cluster/cluster_impl/forking_cluster_invoker.go +++ b/cluster/cluster_impl/forking_cluster_invoker.go @@ -56,7 +56,7 @@ func (invoker *forkingClusterInvoker) Invoke(ctx context.Context, invocation pro } var selected []protocol.Invoker - forks := invoker.GetUrl().GetParamByInt0(constant.FORKS_KEY, constant.DEFAULT_FORKS) + forks := invoker.GetUrl().GetParamByIntValue(constant.FORKS_KEY, constant.DEFAULT_FORKS) timeouts := invoker.GetUrl().GetParamInt(constant.TIMEOUT_KEY, constant.DEFAULT_TIMEOUT) if forks < 0 || forks > len(invokers) { selected = invokers diff --git a/cluster/loadbalance/consistent_hash.go b/cluster/loadbalance/consistent_hash.go index 3cb14d628..3d036b4f3 100644 --- a/cluster/loadbalance/consistent_hash.go +++ b/cluster/loadbalance/consistent_hash.go @@ -105,7 +105,7 @@ func newConsistentHashSelector(invokers []protocol.Invoker, methodName string, selector.virtualInvokers = make(map[uint32]protocol.Invoker) selector.hashCode = hashCode url := invokers[0].GetUrl() - selector.replicaNum = url.GetMethodParamInt0(methodName, HashNodes, 160) + selector.replicaNum = url.GetMethodParamIntValue(methodName, HashNodes, 160) indices := re.Split(url.GetMethodParam(methodName, HashArguments, "0"), -1) for _, index := range indices { i, err := strconv.Atoi(index) diff --git a/common/url.go b/common/url.go index 665aeb5ee..eae36ce69 100644 --- a/common/url.go +++ b/common/url.go @@ -502,8 +502,8 @@ func (c URL) GetParamInt32(key string, d int32) int32 { return int32(r) } -// GetParamByInt0 gets int value by @key -func (c URL) GetParamByInt0(key string, d int) int { +// GetParamByIntValue gets int value by @key +func (c URL) GetParamByIntValue(key string, d int) int { r, err := strconv.ParseInt(c.GetParam(key, ""), 10, 0) if r == 0 || err != nil { return d @@ -520,8 +520,8 @@ func (c URL) GetMethodParamInt(method string, key string, d int64) int64 { return r } -// GetMethodParamInt0 gets int method param -func (c URL) GetMethodParamInt0(method string, key string, d int) int { +// GetMethodParamIntValue gets int method param +func (c URL) GetMethodParamIntValue(method string, key string, d int) int { r, err := strconv.ParseInt(c.GetParam("methods."+method+"."+key, ""), 10, 0) if r == 0 || err != nil { return d -- GitLab