Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
2
22a7f0099
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Summer2022
22a7f0099
Commits
665a9629
Commit
665a9629
authored
4 years ago
by
watermelo
Browse files
Options
Downloads
Patches
Plain Diff
Mod: add router tag unit tests scripts
parent
9375ede6
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
before_ut.bat
+3
-0
3 additions, 0 deletions
before_ut.bat
cluster/router/tag/tag_router.go
+15
-17
15 additions, 17 deletions
cluster/router/tag/tag_router.go
with
18 additions
and
17 deletions
before_ut.bat
+
3
−
0
View file @
665a9629
...
...
@@ -36,5 +36,8 @@ xcopy /f "%zkJar%" "cluster/router/chain/zookeeper-4unittest/contrib/fatjar/"
md
cluster
\router\condition\zookeeper
-
4
unittest
\contrib\fatjar
xcopy
/f
"
%zkJar%
"
"cluster/router/condition/zookeeper-4unittest/contrib/fatjar/"
mkdir
-p
cluster
/router/tag/zookeeper
-
4
unittest
/contrib/fatjar
cp
$
{
zkJar
}
cluster
/router/tag/zookeeper
-
4
unittest
/contrib/fatjar
md
metadata
\report\zookeeper\zookeeper
-
4
unittest
\contrib\fatjar
xcopy
/f
"
%zkJar%
"
"metadata/report/zookeeper/zookeeper-4unittest/contrib/fatjar/"
\ No newline at end of file
This diff is collapsed.
Click to expand it.
cluster/router/tag/tag_router.go
+
15
−
17
View file @
665a9629
...
...
@@ -221,29 +221,27 @@ func filterInvokersWithTag(invokers []protocol.Invoker, url *common.URL, invocat
if
len
(
result
)
>
0
||
tagRouterRule
.
Force
{
return
result
}
}
else
{
// dynamic tag group doesn't have any item about the requested app OR it's null after filtered by
// dynamic tag group but force=false. check static tag
filter
:=
func
(
invoker
protocol
.
Invoker
)
bool
{
return
invoker
.
GetUrl
()
.
GetParam
(
constant
.
Tagkey
,
""
)
==
tag
}
result
=
filterInvoker
(
invokers
,
filter
)
}
// dynamic tag group doesn't have any item about the requested app OR it's null after filtered by
// dynamic tag group but force=false. check static tag
filter
:=
func
(
invoker
protocol
.
Invoker
)
bool
{
return
invoker
.
GetUrl
()
.
GetParam
(
constant
.
Tagkey
,
""
)
==
tag
}
result
=
filterInvoker
(
invokers
,
filter
)
// If there's no tagged providers that can match the current tagged request. force.tag is set by default
// to false, which means it will invoke any providers without a tag unless it's explicitly disallowed.
if
len
(
result
)
>
0
||
isForceUseTag
(
url
,
invocation
)
{
return
result
}
else
{
// FAILOVER: return all Providers without any tags.
filterAddressNotMatches
:=
func
(
invoker
protocol
.
Invoker
)
bool
{
url
:=
invoker
.
GetUrl
()
return
len
(
addresses
)
==
0
||
!
checkAddressMatch
(
tagRouterRule
.
getAddresses
(),
url
.
Ip
,
url
.
Port
)
}
filterTagIsEmpty
:=
func
(
invoker
protocol
.
Invoker
)
bool
{
return
invoker
.
GetUrl
()
.
GetParam
(
constant
.
Tagkey
,
""
)
==
""
}
return
filterInvoker
(
invokers
,
filterAddressNotMatches
,
filterTagIsEmpty
)
}
// FAILOVER: return all Providers without any tags.
filterAddressNotMatches
:=
func
(
invoker
protocol
.
Invoker
)
bool
{
url
:=
invoker
.
GetUrl
()
return
len
(
addresses
)
==
0
||
!
checkAddressMatch
(
tagRouterRule
.
getAddresses
(),
url
.
Ip
,
url
.
Port
)
}
filterTagIsEmpty
:=
func
(
invoker
protocol
.
Invoker
)
bool
{
return
invoker
.
GetUrl
()
.
GetParam
(
constant
.
Tagkey
,
""
)
==
""
}
return
filterInvoker
(
invokers
,
filterAddressNotMatches
,
filterTagIsEmpty
)
}
// isForceUseTag returns whether force use tag
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment