zhaoyunxing92 opened a new issue, #2550:
URL: https://github.com/apache/dubbo-go/issues/2550

   ### Environment
   
   - Server: Dubbo-go, v3.1.0
   - Client: Dubbo-go, v3.1.0
   - Protocol: dubbo
   - Registry: zk
   - 
   ### Issue description
   
   两边实现不一样导致客户端重试计算出来值不一样
   ## Java
   
   ```java
       private int calculateInvokeTimes(String methodName) {
           int len = getUrl().getMethodParameter(methodName, RETRIES_KEY, 
DEFAULT_RETRIES) + 1;
           RpcContext rpcContext = RpcContext.getClientAttachment();
           Object retry = rpcContext.getObjectAttachment(RETRIES_KEY);
           if (retry instanceof Number) {
               len = ((Number) retry).intValue() + 1;
               rpcContext.removeAttachment(RETRIES_KEY);
           }
           if (len <= 0) {
               len = 1;
           }
   
           return len;
       }
   ```
   ## Go
   
   ```go
   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
        }
   
        if retries > len(invokers) {
                retries = len(invokers)
        }
        return retries
   }
   ```
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to