Skip to content

Commit

Permalink
[#1276]modify the name of the receiver to a single character (#1561)
Browse files Browse the repository at this point in the history
Co-authored-by: dongjianhui03 <[email protected]>
  • Loading branch information
Mulavar and dongjianhui03 authored Nov 5, 2021
1 parent 1d2647d commit 35d27b4
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 42 deletions.
6 changes: 3 additions & 3 deletions cluster/router/v3router/judger/attachment_match_judger.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions cluster/router/v3router/judger/bool_match_judger.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions cluster/router/v3router/judger/double_match_judger.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions cluster/router/v3router/judger/double_range_match_judger.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions cluster/router/v3router/judger/list_double_match_judger.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions cluster/router/v3router/judger/list_string_match_judger.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
16 changes: 8 additions & 8 deletions cluster/router/v3router/judger/method_match_judger.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
18 changes: 9 additions & 9 deletions cluster/router/v3router/judger/string_match_judger.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions cluster/router/v3router/uniform_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 {
Expand All @@ -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!")
}
Expand Down Expand Up @@ -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:
Expand All @@ -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
}
Expand Down

0 comments on commit 35d27b4

Please sign in to comment.