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
c1343978
Unverified
Commit
c1343978
authored
2 years ago
by
ken.lj
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Plain Diff
Fix polaris Subscriber #2026
parents
19ddecf8
f5a933d0
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
registry/polaris/core.go
+3
-3
3 additions, 3 deletions
registry/polaris/core.go
registry/polaris/listener.go
+1
-0
1 addition, 0 deletions
registry/polaris/listener.go
registry/polaris/registry.go
+15
-0
15 additions, 0 deletions
registry/polaris/registry.go
with
19 additions
and
3 deletions
registry/polaris/core.go
+
3
−
3
View file @
c1343978
...
...
@@ -32,13 +32,13 @@ import (
"dubbo.apache.org/dubbo-go/v3/remoting"
)
type
subscriber
func
(
remoting
.
EventType
,
[]
model
.
Instance
)
type
item
func
(
remoting
.
EventType
,
[]
model
.
Instance
)
type
PolarisServiceWatcher
struct
{
consumer
api
.
ConsumerAPI
subscribeParam
*
api
.
WatchServiceRequest
lock
*
sync
.
RWMutex
subscribers
[]
subscriber
subscribers
[]
item
execOnce
*
sync
.
Once
}
...
...
@@ -48,7 +48,7 @@ func newPolarisWatcher(param *api.WatchServiceRequest, consumer api.ConsumerAPI)
subscribeParam
:
param
,
consumer
:
consumer
,
lock
:
&
sync
.
RWMutex
{},
subscribers
:
make
([]
subscriber
,
0
),
subscribers
:
make
([]
item
,
0
),
execOnce
:
&
sync
.
Once
{},
}
return
watcher
,
nil
...
...
This diff is collapsed.
Click to expand it.
registry/polaris/listener.go
+
1
−
0
View file @
c1343978
...
...
@@ -51,6 +51,7 @@ func NewPolarisListener(url *common.URL) (*polarisListener, error) {
events
:
gxchan
.
NewUnboundedChan
(
32
),
closeCh
:
make
(
chan
struct
{}),
}
return
listener
,
nil
}
...
...
This diff is collapsed.
Click to expand it.
registry/polaris/registry.go
+
15
−
0
View file @
c1343978
...
...
@@ -150,6 +150,11 @@ func (pr *polarisRegistry) UnRegister(conf *common.URL) error {
// Subscribe returns nil if subscribing registry successfully. If not returns an error.
func
(
pr
*
polarisRegistry
)
Subscribe
(
url
*
common
.
URL
,
notifyListener
registry
.
NotifyListener
)
error
{
var
(
newParam
api
.
WatchServiceRequest
newConsumer
api
.
ConsumerAPI
)
role
,
_
:=
strconv
.
Atoi
(
url
.
GetParam
(
constant
.
RegistryRoleKey
,
""
))
if
role
!=
common
.
CONSUMER
{
return
nil
...
...
@@ -163,8 +168,17 @@ func (pr *polarisRegistry) Subscribe(url *common.URL, notifyListener registry.No
continue
}
watcher
,
err
:=
newPolarisWatcher
(
&
newParam
,
newConsumer
)
if
err
!=
nil
{
logger
.
Warnf
(
"getwatcher() = err:%v"
,
perrors
.
WithStack
(
err
))
timer
:=
time
.
NewTimer
(
time
.
Duration
(
RegistryConnDelay
)
*
time
.
Second
)
timer
.
Reset
(
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
()
...
...
@@ -172,6 +186,7 @@ func (pr *polarisRegistry) Subscribe(url *common.URL, notifyListener registry.No
}
logger
.
Infof
(
"update begin, service event: %v"
,
serviceEvent
.
String
())
notifyListener
.
Notify
(
serviceEvent
)
watcher
.
startWatch
()
}
}
}
...
...
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