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
fedaae51
Commit
fedaae51
authored
4 years ago
by
Ian Luo
Browse files
Options
Downloads
Patches
Plain Diff
fix unit test
parent
ef1ddcf3
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
cluster/router/chain/chain.go
+0
-3
0 additions, 3 deletions
cluster/router/chain/chain.go
registry/directory/directory.go
+9
-5
9 additions, 5 deletions
registry/directory/directory.go
with
9 additions
and
8 deletions
cluster/router/chain/chain.go
+
0
−
3
View file @
fedaae51
...
...
@@ -125,11 +125,8 @@ func (c *RouterChain) loop() {
for
{
select
{
case
<-
time
.
Tick
(
timeInterval
)
:
logger
.
Debugf
(
"start to build address cache since time interval %d second ticks"
,
int
(
timeInterval
.
Seconds
()))
c
.
buildCache
()
case
<-
c
.
ch
:
logger
.
Debugf
(
"start to build address cache since at least %d times of address notified within %d seconds"
,
countThreshold
,
int
(
timeThreshold
.
Seconds
()))
c
.
buildCache
()
}
}
...
...
This diff is collapsed.
Click to expand it.
registry/directory/directory.go
+
9
−
5
View file @
fedaae51
...
...
@@ -60,6 +60,7 @@ type RegistryDirectory struct {
serviceType
string
registry
registry
.
Registry
cacheInvokersMap
*
sync
.
Map
// use sync.map
consumerURL
*
common
.
URL
cacheOriginUrl
*
common
.
URL
configurators
[]
config_center
.
Configurator
consumerConfigurationListener
*
consumerConfigurationListener
...
...
@@ -81,9 +82,9 @@ func NewRegistryDirectory(url *common.URL, registry registry.Registry) (cluster.
registry
:
registry
,
}
dir
.
c
acheOriginUrl
=
dir
.
getConsumerUrl
(
url
.
SubURL
)
dir
.
c
onsumerURL
=
dir
.
getConsumerUrl
(
url
.
SubURL
)
if
routerChain
,
err
:=
chain
.
NewRouterChain
(
dir
.
c
acheOriginUrl
);
err
==
nil
{
if
routerChain
,
err
:=
chain
.
NewRouterChain
(
dir
.
c
onsumerURL
);
err
==
nil
{
dir
.
BaseDirectory
.
SetRouterChain
(
routerChain
)
}
else
{
logger
.
Warnf
(
"fail to create router chain with url: %s, err is: %v"
,
url
.
SubURL
,
err
)
...
...
@@ -159,7 +160,9 @@ func (dir *RegistryDirectory) refreshInvokers(res *registry.ServiceEvent) {
newInvokers
:=
dir
.
toGroupInvokers
()
dir
.
listenerLock
.
Lock
()
dir
.
cacheInvokers
=
newInvokers
dir
.
RouterChain
()
.
SetInvokers
(
newInvokers
)
if
res
!=
nil
{
dir
.
RouterChain
()
.
SetInvokers
(
newInvokers
)
}
dir
.
listenerLock
.
Unlock
()
// After dir.cacheInvokers is updated,destroy the oldInvoker
// Ensure that no request will enter the oldInvoker
...
...
@@ -229,8 +232,9 @@ func (dir *RegistryDirectory) cacheInvoker(url *common.URL) protocol.Invoker {
if
url
==
nil
&&
dir
.
cacheOriginUrl
!=
nil
{
url
=
dir
.
cacheOriginUrl
}
else
{
dir
.
cacheOriginUrl
=
url
}
if
url
==
nil
{
logger
.
Error
(
"URL is nil ,pls check if service url is subscribe successfully!"
)
return
nil
...
...
@@ -265,7 +269,7 @@ func (dir *RegistryDirectory) List(invocation protocol.Invocation) []protocol.In
if
routerChain
==
nil
{
return
invokers
}
return
routerChain
.
Route
(
dir
.
c
acheOriginUrl
,
invocation
)
return
routerChain
.
Route
(
dir
.
c
onsumerURL
,
invocation
)
}
// IsAvailable whether the directory is available
...
...
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