You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "FinalT (via GitHub)" <gi...@apache.org> on 2023/04/09 13:34:53 UTC

[GitHub] [dubbo-go] FinalT commented on a diff in pull request #2276: Ftr: Implement condition routing

FinalT commented on code in PR #2276:
URL: https://github.com/apache/dubbo-go/pull/2276#discussion_r1161286466


##########
cluster/router/condition/matcher/base/matcher.go:
##########
@@ -0,0 +1,135 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package base
+
+import (
+	"sort"
+)
+
+import (
+	"github.com/dubbogo/gost/log/logger"
+)
+
+import (
+	"dubbo.apache.org/dubbo-go/v3/cluster/router/condition/matcher"
+	"dubbo.apache.org/dubbo-go/v3/cluster/router/condition/matcher/pattern"
+	"dubbo.apache.org/dubbo-go/v3/common"
+	"dubbo.apache.org/dubbo-go/v3/common/constant"
+	"dubbo.apache.org/dubbo-go/v3/common/extension"
+	"dubbo.apache.org/dubbo-go/v3/protocol"
+)
+
+// ConditionMatcher records the match and mismatch patterns of this matcher while at the same time
+// provides the common match logics.
+type ConditionMatcher struct {
+	Matches       map[string]struct{}
+	Mismatches    map[string]struct{}
+	ValueMatchers []pattern.ValuePattern
+
+	Matcher matcher.ConditionMatcher

Review Comment:
   This is to implement the hook function, I need to call the subclass GetValue method in the IsMatch method
   
   > Why does here need a `Matcher`? I just checked all constructive functions of condition matchers have a same behavior:
   > 
   > ```
   > conditionMatcher.Matcher = conditionMatcher
   > ```
   > 
   > I think it is a self-reference.
   
   This is to implement the hook function, I need to call the subclass GetValue method in the IsMatch method



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