diff --git a/cluster/router/v3router/judger/attachment_match_judger.go b/cluster/router/v3router/judger/attachment_match_judger.go index 31f46e05cf..d28373982a 100644 --- a/cluster/router/v3router/judger/attachment_match_judger.go +++ b/cluster/router/v3router/judger/attachment_match_judger.go @@ -27,13 +27,13 @@ type AttachmentMatchJudger struct { } // nolint -func (amj *AttachmentMatchJudger) Judge(invocation protocol.Invocation) bool { +func (j *AttachmentMatchJudger) Judge(invocation protocol.Invocation) bool { invAttaMap := invocation.Attachments() - if amj.EagleeyeContext != nil && !judge(amj.EagleeyeContext, invAttaMap) { + if j.EagleeyeContext != nil && !judge(j.EagleeyeContext, invAttaMap) { return false } - return amj.DubboContext == nil || judge(amj.DubboContext, invAttaMap) + return j.DubboContext == nil || judge(j.DubboContext, invAttaMap) } func judge(condition map[string]*config.StringMatch, invAttaMap map[string]interface{}) bool { diff --git a/cluster/router/v3router/judger/bool_match_judger.go b/cluster/router/v3router/judger/bool_match_judger.go index 5c4bb46e77..a49a6b6f5c 100644 --- a/cluster/router/v3router/judger/bool_match_judger.go +++ b/cluster/router/v3router/judger/bool_match_judger.go @@ -27,8 +27,8 @@ type BoolMatchJudger struct { } // nolint -func (lsmj *BoolMatchJudger) Judge(input bool) bool { - return input == lsmj.Exact +func (j *BoolMatchJudger) Judge(input bool) bool { + return input == j.Exact } // nolint diff --git a/cluster/router/v3router/judger/double_match_judger.go b/cluster/router/v3router/judger/double_match_judger.go index d5ec3844fd..c143fba5a6 100644 --- a/cluster/router/v3router/judger/double_match_judger.go +++ b/cluster/router/v3router/judger/double_match_judger.go @@ -27,15 +27,15 @@ type DoubleMatchJudger struct { } // nolint -func (dmj *DoubleMatchJudger) Judge(input float64) bool { - if dmj.Exact != 0 { - return input == dmj.Exact +func (j *DoubleMatchJudger) Judge(input float64) bool { + if j.Exact != 0 { + return input == j.Exact } - if dmj.Range != nil { - return newDoubleRangeMatchJudger(dmj.Range).Judge(input) + if j.Range != nil { + return newDoubleRangeMatchJudger(j.Range).Judge(input) } // todo mod match ?? - //if dmj.Mode != 0 { + //if j.Mode != 0 { // //} return true diff --git a/cluster/router/v3router/judger/double_range_match_judger.go b/cluster/router/v3router/judger/double_range_match_judger.go index 8897fc3c7d..3e149785a0 100644 --- a/cluster/router/v3router/judger/double_range_match_judger.go +++ b/cluster/router/v3router/judger/double_range_match_judger.go @@ -27,8 +27,8 @@ type DoubleRangeMatchJudger struct { } // nolint -func (drmj *DoubleRangeMatchJudger) Judge(input float64) bool { - return input >= drmj.Start && input < drmj.End +func (j *DoubleRangeMatchJudger) Judge(input float64) bool { + return input >= j.Start && input < j.End } // nolint diff --git a/cluster/router/v3router/judger/list_double_match_judger.go b/cluster/router/v3router/judger/list_double_match_judger.go index b968334e5e..b0d5db6197 100644 --- a/cluster/router/v3router/judger/list_double_match_judger.go +++ b/cluster/router/v3router/judger/list_double_match_judger.go @@ -27,8 +27,8 @@ type ListDoubleMatchJudger struct { } // nolint -func (lsmj *ListDoubleMatchJudger) Judge(input float64) bool { - for _, v := range lsmj.Oneof { +func (j *ListDoubleMatchJudger) Judge(input float64) bool { + for _, v := range j.Oneof { if newDoubleMatchJudger(v).Judge(input) { return true } diff --git a/cluster/router/v3router/judger/list_string_match_judger.go b/cluster/router/v3router/judger/list_string_match_judger.go index a1df1e9d47..c7b66ec73c 100644 --- a/cluster/router/v3router/judger/list_string_match_judger.go +++ b/cluster/router/v3router/judger/list_string_match_judger.go @@ -27,8 +27,8 @@ type ListStringMatchJudger struct { } // nolint -func (lsmj *ListStringMatchJudger) Judge(input string) bool { - for _, v := range lsmj.Oneof { +func (j *ListStringMatchJudger) Judge(input string) bool { + for _, v := range j.Oneof { if NewStringMatchJudger(v).Judge(input) { return true } diff --git a/cluster/router/v3router/judger/method_match_judger.go b/cluster/router/v3router/judger/method_match_judger.go index e069ef9cca..3225bea9c2 100644 --- a/cluster/router/v3router/judger/method_match_judger.go +++ b/cluster/router/v3router/judger/method_match_judger.go @@ -28,22 +28,22 @@ type MethodMatchJudger struct { } // Judge Method Match Judger only judge on -func (mmj *MethodMatchJudger) Judge(invocation protocol.Invocation) bool { - if mmj.NameMatch != nil { - strJudger := NewStringMatchJudger(mmj.NameMatch) +func (j *MethodMatchJudger) Judge(invocation protocol.Invocation) bool { + if j.NameMatch != nil { + strJudger := NewStringMatchJudger(j.NameMatch) if !strJudger.Judge(invocation.MethodName()) { return false } } // todo now argc Must not be zero, else it will cause unexpected result - if mmj.Argc != 0 && len(invocation.ParameterValues()) != mmj.Argc { + if j.Argc != 0 && len(invocation.ParameterValues()) != j.Argc { return false } - if mmj.Args != nil { + if j.Args != nil { params := invocation.ParameterValues() - for _, v := range mmj.Args { + for _, v := range j.Args { index := int(v.Index) if index > len(params) || index < 1 { return false @@ -72,11 +72,11 @@ func (mmj *MethodMatchJudger) Judge(invocation protocol.Invocation) bool { } } // todo Argp match judge ??? conflict to args? - //if mmj.Argp != nil { + //if j.Argp != nil { // //} // todo Headers match judge: reserve for triple - //if mmj.Headers != nil { + //if j.Headers != nil { // //} return true diff --git a/cluster/router/v3router/judger/string_match_judger.go b/cluster/router/v3router/judger/string_match_judger.go index fae5278fb2..74302d17f3 100644 --- a/cluster/router/v3router/judger/string_match_judger.go +++ b/cluster/router/v3router/judger/string_match_judger.go @@ -32,21 +32,21 @@ type StringMatchJudger struct { } // nolint -func (smj *StringMatchJudger) Judge(input string) bool { - if smj.Exact != "" { - return input == smj.Exact +func (j *StringMatchJudger) Judge(input string) bool { + if j.Exact != "" { + return input == j.Exact } - if smj.Prefix != "" { - return strings.HasPrefix(input, smj.Prefix) + if j.Prefix != "" { + return strings.HasPrefix(input, j.Prefix) } - if smj.Regex != "" { - ok, err := regexp.MatchString(smj.Regex, input) + if j.Regex != "" { + ok, err := regexp.MatchString(j.Regex, input) return ok && err == nil } - if smj.NoEmpty != "" { + if j.NoEmpty != "" { return input != "" } - if smj.Empty != "" { + if j.Empty != "" { return input == "" } return true diff --git a/cluster/router/v3router/uniform_rule.go b/cluster/router/v3router/uniform_rule.go index 4dddc35adb..53f940b176 100644 --- a/cluster/router/v3router/uniform_rule.go +++ b/cluster/router/v3router/uniform_rule.go @@ -46,8 +46,8 @@ type VirtualServiceRule struct { // match read from VirtualServiceRule's Match config // it judges if this invocation matches the router rule request defined in config one by one -func (vsr *VirtualServiceRule) match(url *common.URL, invocation protocol.Invocation) bool { - for _, v := range vsr.routerItem.Match { +func (r *VirtualServiceRule) match(url *common.URL, invocation protocol.Invocation) bool { + for _, v := range r.routerItem.Match { // method match judge if v.Method != nil { methodMatchJudger := judger.NewMethodMatchJudger(v.Method) @@ -79,9 +79,9 @@ func (vsr *VirtualServiceRule) match(url *common.URL, invocation protocol.Invoca // tryGetSubsetFromRouterOfOneDestination is a recursion function // try from destination 's header to final fallback destination, when success, it return result destination, else return error -func (vsr *VirtualServiceRule) tryGetSubsetFromRouterOfOneDestination(desc *config.DubboDestination, invokers []protocol.Invoker) ([]protocol.Invoker, int, error) { +func (r *VirtualServiceRule) tryGetSubsetFromRouterOfOneDestination(desc *config.DubboDestination, invokers []protocol.Invoker) ([]protocol.Invoker, int, error) { subSet := desc.Destination.Subset - labels, ok := vsr.uniformRule.DestinationLabelListMap[subSet] + labels, ok := r.uniformRule.DestinationLabelListMap[subSet] resultInvokers := make([]protocol.Invoker, 0) if ok { for _, v := range invokers { @@ -95,7 +95,7 @@ func (vsr *VirtualServiceRule) tryGetSubsetFromRouterOfOneDestination(desc *conf } if desc.Destination.Fallback != nil { - return vsr.tryGetSubsetFromRouterOfOneDestination(desc.Destination.Fallback, invokers) + return r.tryGetSubsetFromRouterOfOneDestination(desc.Destination.Fallback, invokers) } return nil, 0, perrors.New("No invoker matches and no fallback destination to choose!") } @@ -146,10 +146,10 @@ func (w *weightInvokerPairResults) getTargetInvokers() []protocol.Invoker { return w.pairs[0].invokerList } -func (vsr *VirtualServiceRule) getRuleTargetInvokers(invokers []protocol.Invoker) ([]protocol.Invoker, error) { +func (r *VirtualServiceRule) getRuleTargetInvokers(invokers []protocol.Invoker) ([]protocol.Invoker, error) { // weightInvokerPairResult is the collection routerDesc of all destination fields, weightInvokerPairResult := weightInvokerPairResults{} - for _, v := range vsr.routerItem.Router { + for _, v := range r.routerItem.Router { // v is one destination 's header e.g. /* route: @@ -176,7 +176,7 @@ func (vsr *VirtualServiceRule) getRuleTargetInvokers(invokers []protocol.Invoker host: demo subset: v6 */ - invokerListOfOneDest, weight, err := vsr.tryGetSubsetFromRouterOfOneDestination(v, invokers) + invokerListOfOneDest, weight, err := r.tryGetSubsetFromRouterOfOneDestination(v, invokers) if err != nil { return nil, err }