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
2fe1edfd
Commit
2fe1edfd
authored
5 years ago
by
邹毅贤
Browse files
Options
Downloads
Patches
Plain Diff
fix problems
parent
f9ed6b53
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
cluster/router_chain.go
+3
-1
3 additions, 1 deletion
cluster/router_chain.go
registry/directory/directory.go
+29
-72
29 additions, 72 deletions
registry/directory/directory.go
with
32 additions
and
73 deletions
cluster/router_chain.go
+
3
−
1
View file @
2fe1edfd
package
cluster
import
(
"sort"
)
import
(
"github.com/apache/dubbo-go/common"
"github.com/apache/dubbo-go/protocol"
"sort"
)
type
RouterChain
struct
{
...
...
This diff is collapsed.
Click to expand it.
registry/directory/directory.go
+
29
−
72
View file @
2fe1edfd
...
...
@@ -31,7 +31,6 @@ import (
)
import
(
"github.com/apache/dubbo-go/cluster"
"github.com/apache/dubbo-go/cluster/directory"
"github.com/apache/dubbo-go/common"
"github.com/apache/dubbo-go/common/constant"
...
...
@@ -64,8 +63,8 @@ type registryDirectory struct {
consumerConfigurationListener
*
consumerConfigurationListener
referenceConfigurationListener
*
referenceConfigurationListener
Options
serviceKey
string
forbidden
atomic
.
Bool
serviceKey
string
forbidden
atomic
.
Bool
}
func
NewRegistryDirectory
(
url
*
common
.
URL
,
registry
registry
.
Registry
,
opts
...
Option
)
(
*
registryDirectory
,
error
)
{
...
...
@@ -93,38 +92,9 @@ func NewRegistryDirectory(url *common.URL, registry registry.Registry, opts ...O
//subscribe from registry
func
(
dir
*
registryDirectory
)
Subscribe
(
url
*
common
.
URL
)
{
for
{
if
!
dir
.
registry
.
IsAvailable
()
{
logger
.
Warnf
(
"event listener game over."
)
return
}
listener
,
err
:=
dir
.
registry
.
Subscribe
(
url
)
if
err
!=
nil
{
if
!
dir
.
registry
.
IsAvailable
()
{
logger
.
Warnf
(
"event listener game over."
)
return
}
logger
.
Warnf
(
"getListener() = err:%v"
,
perrors
.
WithStack
(
err
))
time
.
Sleep
(
time
.
Duration
(
RegistryConnDelay
)
*
time
.
Second
)
continue
}
for
{
serviceEvent
,
err
:=
listener
.
Next
()
if
err
!=
nil
{
logger
.
Warnf
(
"Selector.watch() = error{%v}"
,
perrors
.
WithStack
(
err
))
listener
.
Close
()
time
.
Sleep
(
time
.
Duration
(
RegistryConnDelay
)
*
time
.
Second
)
return
}
logger
.
Infof
(
"update begin, service event: %v"
,
serviceEvent
.
String
())
go
dir
.
update
(
serviceEvent
)
}
}
dir
.
consumerConfigurationListener
.
addNotifyListener
(
dir
)
dir
.
referenceConfigurationListener
=
newReferenceConfigurationListener
(
dir
,
url
)
dir
.
registry
.
Subscribe
(
url
,
dir
)
}
func
(
dir
*
registryDirectory
)
Notify
(
event
*
registry
.
ServiceEvent
)
{
...
...
@@ -157,34 +127,34 @@ func (dir *registryDirectory) refreshInvokers(res *registry.ServiceEvent) {
//TODO: router
}
switch
res
.
Action
{
case
remoting
.
EventTypeAdd
:
url
:=
dir
.
GetUrl
()
var
urls
[]
*
common
.
URL
for
_
,
v
:=
range
url
.
GetBackupUrls
()
{
p
:=
v
.
Protocol
category
:=
v
.
GetParam
(
constant
.
CATEGORY_KEY
,
constant
.
PROVIDERS_CATEGORY
)
if
strings
.
EqualFold
(
category
,
constant
.
ROUTERS_CATEGORY
)
||
strings
.
EqualFold
(
constant
.
ROUTE_PROTOCOL
,
p
)
{
urls
=
append
(
urls
,
v
)
case
remoting
.
EventTypeAdd
:
url
:=
dir
.
GetUrl
()
var
urls
[]
*
common
.
URL
for
_
,
v
:=
range
url
.
GetBackupUrls
()
{
p
:=
v
.
Protocol
category
:=
v
.
GetParam
(
constant
.
CATEGORY_KEY
,
constant
.
PROVIDERS_CATEGORY
)
if
strings
.
EqualFold
(
category
,
constant
.
ROUTERS_CATEGORY
)
||
strings
.
EqualFold
(
constant
.
ROUTE_PROTOCOL
,
p
)
{
urls
=
append
(
urls
,
v
)
}
}
}
if
len
(
urls
)
>
0
{
routers
:=
toRouters
(
urls
)
if
len
(
routers
)
>
0
{
dir
.
SetRouters
(
routers
)
if
len
(
urls
)
>
0
{
routers
:=
toRouters
(
urls
)
if
len
(
routers
)
>
0
{
dir
.
SetRouters
(
routers
)
}
}
}
//dir.cacheService.EventTypeAdd(res.Path, dir.serviceTTL)
dir
.
cacheInvoker
(
res
.
Service
)
case
remoting
.
EventTypeDel
:
//dir.cacheService.EventTypeDel(res.Path, dir.serviceTTL)
dir
.
uncacheInvoker
(
res
.
Service
)
logger
.
Infof
(
"selector delete service url{%s}"
,
res
.
Service
)
default
:
return
}
//dir.cacheService.EventTypeAdd(res.Path, dir.serviceTTL)
dir
.
cacheInvoker
(
&
res
.
Service
)
case
remoting
.
EventTypeDel
:
//dir.cacheService.EventTypeDel(res.Path, dir.serviceTTL)
dir
.
uncacheInvoker
(
&
res
.
Service
)
logger
.
Infof
(
"selector delete service url{%s}"
,
res
.
Service
)
default
:
return
}
}
newInvokers
:=
dir
.
toGroupInvokers
()
...
...
@@ -364,16 +334,3 @@ func (l *consumerConfigurationListener) Process(event *config_center.ConfigChang
l
.
BaseConfigurationListener
.
Process
(
event
)
l
.
directory
.
refreshInvokers
(
nil
)
}
func
newConsumerConfigurationListener
(
dir
*
registryDirectory
)
*
consumerConfigurationListener
{
listener
:=
&
consumerConfigurationListener
{
directory
:
dir
}
listener
.
InitWith
(
config
.
GetConsumerConfig
()
.
ApplicationConfig
.
Name
+
constant
.
CONFIGURATORS_SUFFIX
,
listener
,
extension
.
GetDefaultConfiguratorFunc
(),
)
return
listener
}
func
(
l
*
consumerConfigurationListener
)
addNotifyListener
(
listener
registry
.
NotifyListener
)
{
l
.
listeners
=
appe
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