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 10:38:43 UTC

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

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


##########
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:
   这个地方我权衡过,主要 attachment 格式没有强制规定(比如数组里是否只能有一个元素之类的),所以我考虑是说先单独写。



-- 
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