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
603c1b93
Commit
603c1b93
authored
5 years ago
by
scott
Browse files
Options
Downloads
Patches
Plain Diff
Fix wg bug, add(1) out of goroutine
parent
83d39758
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
remoting/etcdv3/listener.go
+2
-3
2 additions, 3 deletions
remoting/etcdv3/listener.go
remoting/kubernetes/listener.go
+3
-2
3 additions, 2 deletions
remoting/kubernetes/listener.go
remoting/zookeeper/listener.go
+3
-2
3 additions, 2 deletions
remoting/zookeeper/listener.go
with
8 additions
and
7 deletions
remoting/etcdv3/listener.go
+
2
−
3
View file @
603c1b93
...
...
@@ -53,7 +53,6 @@ func NewEventListener(client *Client) *EventListener {
// this method will return true when spec key deleted,
// this method will return false when deep layer connection lose
func
(
l
*
EventListener
)
ListenServiceNodeEvent
(
key
string
,
listener
...
remoting
.
DataListener
)
bool
{
l
.
wg
.
Add
(
1
)
defer
l
.
wg
.
Done
()
for
{
wc
,
err
:=
l
.
client
.
Watch
(
key
)
...
...
@@ -138,8 +137,6 @@ func (l *EventListener) handleEvents(event *clientv3.Event, listeners ...remotin
// ListenServiceNodeEventWithPrefix Listen on a set of key with spec prefix
func
(
l
*
EventListener
)
ListenServiceNodeEventWithPrefix
(
prefix
string
,
listener
...
remoting
.
DataListener
)
{
l
.
wg
.
Add
(
1
)
defer
l
.
wg
.
Done
()
for
{
wc
,
err
:=
l
.
client
.
WatchWithPrefix
(
prefix
)
...
...
@@ -217,12 +214,14 @@ func (l *EventListener) ListenServiceEvent(key string, listener remoting.DataLis
}
logger
.
Infof
(
"listen dubbo provider key{%s} event and wait to get all provider etcdv3 nodes"
,
key
)
l
.
wg
.
Add
(
1
)
go
func
(
key
string
,
listener
remoting
.
DataListener
)
{
l
.
ListenServiceNodeEventWithPrefix
(
key
,
listener
)
logger
.
Warnf
(
"listenDirEvent(key{%s}) goroutine exit now"
,
key
)
}(
key
,
listener
)
logger
.
Infof
(
"listen dubbo service key{%s}"
,
key
)
l
.
wg
.
Add
(
1
)
go
func
(
key
string
)
{
if
l
.
ListenServiceNodeEvent
(
key
)
{
listener
.
DataChange
(
remoting
.
Event
{
Path
:
key
,
Action
:
remoting
.
EventTypeDel
})
...
...
This diff is collapsed.
Click to expand it.
remoting/kubernetes/listener.go
+
3
−
2
View file @
603c1b93
...
...
@@ -48,7 +48,6 @@ func NewEventListener(client *Client) *EventListener {
// this method will return true when spec key deleted,
// this method will return false when deep layer connection lose
func
(
l
*
EventListener
)
ListenServiceNodeEvent
(
key
string
,
listener
...
remoting
.
DataListener
)
bool
{
l
.
wg
.
Add
(
1
)
defer
l
.
wg
.
Done
()
for
{
wc
,
done
,
err
:=
l
.
client
.
Watch
(
key
)
...
...
@@ -124,7 +123,6 @@ func (l *EventListener) handleEvents(event *WatcherEvent, listeners ...remoting.
// Listen on a set of key with spec prefix
func
(
l
*
EventListener
)
ListenServiceNodeEventWithPrefix
(
prefix
string
,
listener
...
remoting
.
DataListener
)
{
l
.
wg
.
Add
(
1
)
defer
l
.
wg
.
Done
()
for
{
wc
,
done
,
err
:=
l
.
client
.
WatchWithPrefix
(
prefix
)
...
...
@@ -197,12 +195,15 @@ func (l *EventListener) ListenServiceEvent(key string, listener remoting.DataLis
}
logger
.
Infof
(
"listen dubbo provider key{%s} event and wait to get all provider from kubernetes-watcherSet"
,
key
)
l
.
wg
.
Add
(
1
)
go
func
(
key
string
,
listener
remoting
.
DataListener
)
{
l
.
ListenServiceNodeEventWithPrefix
(
key
,
listener
)
logger
.
Warnf
(
"listenDirEvent(key{%s}) goroutine exit now"
,
key
)
}(
key
,
listener
)
logger
.
Infof
(
"listen dubbo service key{%s}"
,
key
)
l
.
wg
.
Add
(
1
)
go
func
(
key
string
)
{
if
l
.
ListenServiceNodeEvent
(
key
)
{
listener
.
DataChange
(
remoting
.
Event
{
Path
:
key
,
Action
:
remoting
.
EventTypeDel
})
...
...
This diff is collapsed.
Click to expand it.
remoting/zookeeper/listener.go
+
3
−
2
View file @
603c1b93
...
...
@@ -59,7 +59,6 @@ func (l *ZkEventListener) SetClient(client *ZookeeperClient) {
// ListenServiceNodeEvent ...
func
(
l
*
ZkEventListener
)
ListenServiceNodeEvent
(
zkPath
string
,
listener
...
remoting
.
DataListener
)
bool
{
l
.
wg
.
Add
(
1
)
defer
l
.
wg
.
Done
()
var
zkEvent
zk
.
Event
for
{
...
...
@@ -145,6 +144,7 @@ func (l *ZkEventListener) handleZkNodeEvent(zkPath string, children []string, li
continue
}
// listen l service node
l
.
wg
.
Add
(
1
)
go
func
(
node
string
,
zkPath
string
,
listener
remoting
.
DataListener
)
{
logger
.
Infof
(
"delete zkNode{%s}"
,
node
)
if
l
.
ListenServiceNodeEvent
(
node
,
listener
)
{
...
...
@@ -174,7 +174,6 @@ func (l *ZkEventListener) handleZkNodeEvent(zkPath string, children []string, li
}
func
(
l
*
ZkEventListener
)
listenDirEvent
(
zkPath
string
,
listener
remoting
.
DataListener
)
{
l
.
wg
.
Add
(
1
)
defer
l
.
wg
.
Done
()
var
(
...
...
@@ -261,6 +260,7 @@ func (l *ZkEventListener) listenDirEvent(zkPath string, listener remoting.DataLi
//if zkPath is end of "providers/ & consumers/" we do not listen children dir
if
strings
.
LastIndex
(
zkPath
,
constant
.
PROVIDER_CATEGORY
)
==
-
1
&&
strings
.
LastIndex
(
zkPath
,
constant
.
CONSUMER_CATEGORY
)
==
-
1
{
l
.
wg
.
Add
(
1
)
go
func
(
zkPath
string
,
listener
remoting
.
DataListener
)
{
l
.
listenDirEvent
(
zkPath
,
listener
)
logger
.
Warnf
(
"listenDirEvent(zkPath{%s}) goroutine exit now"
,
zkPath
)
...
...
@@ -292,6 +292,7 @@ func timeSecondDuration(sec int) time.Duration {
// --------> ListenServiceNodeEvent
func
(
l
*
ZkEventListener
)
ListenServiceEvent
(
zkPath
string
,
listener
remoting
.
DataListener
)
{
logger
.
Infof
(
"listen dubbo path{%s}"
,
zkPath
)
l
.
wg
.
Add
(
1
)
go
func
(
zkPath
string
,
listener
remoting
.
DataListener
)
{
l
.
listenDirEvent
(
zkPath
,
listener
)
logger
.
Warnf
(
"listenDirEvent(zkPath{%s}) goroutine exit now"
,
zkPath
)
...
...
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