Skip to content

Commit

Permalink
Polish retry time (apache#2564)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaoyunxing92 authored Jan 11, 2024
1 parent eeab1e9 commit d21e699
Showing 1 changed file with 4 additions and 20 deletions.
24 changes: 4 additions & 20 deletions cluster/cluster/failover/cluster_invoker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}

0 comments on commit d21e699

Please sign in to comment.