You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2022/04/06 09:56:11 UTC

[GitHub] [dubbo-go] Mulavar commented on a diff in pull request #1811: fix(adasvc): fix getting attachment issues for triple

Mulavar commented on code in PR #1811:
URL: https://github.com/apache/dubbo-go/pull/1811#discussion_r843741570


##########
cluster/cluster/adaptivesvc/cluster_invoker.go:
##########
@@ -76,9 +76,16 @@ func (ivk *adaptiveServiceClusterInvoker) Invoke(ctx context.Context, invocation
 	}
 
 	// update metrics
-	remainingIface := result.Attachment(constant.AdaptiveServiceRemainingKey, "")
-	remainingStr, ok := remainingIface.(string)
-	if !ok {
+	var remainingStr string
+	remainingIface := result.Attachment(constant.AdaptiveServiceRemainingKey, nil)
+	if remainingIface != nil {
+		if str, strOK := remainingIface.(string); strOK {
+			remainingStr = str
+		} else if strArr, strArrOK := remainingIface.([]string); strArrOK && len(strArr) > 0 {
+			remainingStr = strArr[0]
+		}
+	}

Review Comment:
   这部分重复的代码需不需要包装成一个方法



-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org