This is an automated email from the ASF dual-hosted git repository.
liujun pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git
The following commit(s) were added to refs/heads/main by this push:
new d21e6995a Polish retry time (#2564)
d21e6995a is described below
commit d21e6995a3c7b60fff5a1e18601fd9042634cf5a
Author: zhaoyunxing <[email protected]>
AuthorDate: Thu Jan 11 14:45:52 2024 +0800
Polish retry time (#2564)
fixes #2550
---
cluster/cluster/failover/cluster_invoker.go | 24 ++++--------------------
1 file changed, 4 insertions(+), 20 deletions(-)
diff --git a/cluster/cluster/failover/cluster_invoker.go
b/cluster/cluster/failover/cluster_invoker.go
index 0d6db65c7..2aa45d5a8 100644
--- a/cluster/cluster/failover/cluster_invoker.go
+++ b/cluster/cluster/failover/cluster_invoker.go
@@ -20,16 +20,10 @@ package failover
import (
"context"
"fmt"
- "strconv"
-)
-import (
"github.com/dubbogo/gost/log/logger"
-
perrors "github.com/pkg/errors"
-)
-import (
"dubbo.apache.org/dubbo-go/v3/cluster/cluster/base"
"dubbo.apache.org/dubbo-go/v3/cluster/directory"
"dubbo.apache.org/dubbo-go/v3/common"
@@ -114,23 +108,13 @@ func getRetries(invokers []protocol.Invoker, methodName
string) int {
if len(invokers) <= 0 {
return constant.DefaultRetriesInt
}
-
url := invokers[0].GetURL()
- // get reties
- retriesConfig := url.GetParam(constant.RetriesKey,
constant.DefaultRetries)
- // Get the service method loadbalance config if have
- if v := url.GetMethodParam(methodName, constant.RetriesKey, ""); len(v)
!= 0 {
- retriesConfig = v
- }
- retries, err := strconv.Atoi(retriesConfig)
- if err != nil || retries < 0 {
- logger.Error("Your retries config is invalid,pls do a check.
And will use the default retries configuration instead.")
- retries = constant.DefaultRetriesInt
- }
+ retries := url.GetMethodParamIntValue(methodName, constant.RetriesKey,
+ url.GetParamByIntValue(constant.RetriesKey,
constant.DefaultRetriesInt))
- if retries > len(invokers) {
- retries = len(invokers)
+ if retries < 0 {
+ return constant.DefaultRetriesInt
}
return retries
}