You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2022/07/21 06:48:29 UTC
[GitHub] [dubbo-go] jasondeng1997 opened a new pull request, #1988: fix PolarisServiceWatcher bug
jasondeng1997 opened a new pull request, #1988:
URL: https://github.com/apache/dubbo-go/pull/1988
ConsumerAPI.Subscribe 只需要执行一次,如果 Subscribe,可能是 SDK 内返回了类似 Busy 类的错误,因此需要先保证 ConsumerAPI.Subscribe 一定成功,成功之后,会返回一个用于订阅的 chan,这个chan需要走 for range or for select 的语句不断消费 chan 里面的实例变化事件,如果 chan 被 sdk 内部逻辑 close 的话,那么就又会走到外层的循环进行再次发起订阅动作,如果内部for发生错误,跳出当前for,继续执行监听事件
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo-go] chuntaojun commented on a diff in pull request #1988: fix PolarisServiceWatcher bug
Posted by GitBox <gi...@apache.org>.
chuntaojun commented on code in PR #1988:
URL: https://github.com/apache/dubbo-go/pull/1988#discussion_r926336767
##########
registry/polaris/core.go:
##########
@@ -74,48 +73,52 @@ func (watcher *PolarisServiceWatcher) lazyRun() {
// startWatch start run work to watch target service by polaris
func (watcher *PolarisServiceWatcher) startWatch() {
-
for {
resp, err := watcher.consumer.WatchService(watcher.subscribeParam)
if err != nil {
time.Sleep(time.Duration(500 * time.Millisecond))
continue
}
-
watcher.notifyAllSubscriber(&config_center.ConfigChangeEvent{
Value: resp.GetAllInstancesResp.Instances,
ConfigType: remoting.EventTypeAdd,
})
- select {
- case event := <-resp.EventChannel:
- eType := event.GetSubScribeEventType()
- if eType == api.EventInstance {
- insEvent := event.(*model.InstanceEvent)
- if insEvent.AddEvent != nil {
- watcher.notifyAllSubscriber(&config_center.ConfigChangeEvent{
- Value: insEvent.AddEvent.Instances,
- ConfigType: remoting.EventTypeAdd,
- })
- }
- if insEvent.UpdateEvent != nil {
- instances := make([]model.Instance, len(insEvent.UpdateEvent.UpdateList))
- for i := range insEvent.UpdateEvent.UpdateList {
- instances[i] = insEvent.UpdateEvent.UpdateList[i].After
+ for {
+ select {
+ case event := <-resp.EventChannel:
+ eType := event.GetSubScribeEventType()
+ if eType == api.EventInstance {
+ insEvent := event.(*model.InstanceEvent)
+
+ if insEvent.AddEvent != nil {
+ watcher.notifyAllSubscriber(&config_center.ConfigChangeEvent{
+ Value: insEvent.AddEvent.Instances,
+ ConfigType: remoting.EventTypeAdd,
+ })
+ }
+ if insEvent.UpdateEvent != nil {
+ instances := make([]model.Instance, len(insEvent.UpdateEvent.UpdateList))
+ for i := range insEvent.UpdateEvent.UpdateList {
+ instances[i] = insEvent.UpdateEvent.UpdateList[i].After
+ }
+ watcher.notifyAllSubscriber(&config_center.ConfigChangeEvent{
+ Value: instances,
+ ConfigType: remoting.EventTypeUpdate,
+ })
+ }
+ if insEvent.DeleteEvent != nil {
+ watcher.notifyAllSubscriber(&config_center.ConfigChangeEvent{
+ Value: insEvent.DeleteEvent.Instances,
+ ConfigType: remoting.EventTypeDel,
+ })
}
- watcher.notifyAllSubscriber(&config_center.ConfigChangeEvent{
- Value: instances,
- ConfigType: remoting.EventTypeUpdate,
- })
- }
- if insEvent.DeleteEvent != nil {
- watcher.notifyAllSubscriber(&config_center.ConfigChangeEvent{
- Value: insEvent.DeleteEvent.Instances,
- ConfigType: remoting.EventTypeDel,
- })
}
+ case <-time.After(20 * time.Second):
Review Comment:
我理解阻塞在这个 select 应该没问题吧?
##########
registry/polaris/core.go:
##########
@@ -74,48 +73,52 @@ func (watcher *PolarisServiceWatcher) lazyRun() {
// startWatch start run work to watch target service by polaris
func (watcher *PolarisServiceWatcher) startWatch() {
-
for {
resp, err := watcher.consumer.WatchService(watcher.subscribeParam)
if err != nil {
time.Sleep(time.Duration(500 * time.Millisecond))
continue
}
-
watcher.notifyAllSubscriber(&config_center.ConfigChangeEvent{
Value: resp.GetAllInstancesResp.Instances,
ConfigType: remoting.EventTypeAdd,
})
- select {
- case event := <-resp.EventChannel:
- eType := event.GetSubScribeEventType()
- if eType == api.EventInstance {
- insEvent := event.(*model.InstanceEvent)
- if insEvent.AddEvent != nil {
- watcher.notifyAllSubscriber(&config_center.ConfigChangeEvent{
- Value: insEvent.AddEvent.Instances,
- ConfigType: remoting.EventTypeAdd,
- })
- }
- if insEvent.UpdateEvent != nil {
- instances := make([]model.Instance, len(insEvent.UpdateEvent.UpdateList))
- for i := range insEvent.UpdateEvent.UpdateList {
- instances[i] = insEvent.UpdateEvent.UpdateList[i].After
+ for {
+ select {
+ case event := <-resp.EventChannel:
+ eType := event.GetSubScribeEventType()
+ if eType == api.EventInstance {
+ insEvent := event.(*model.InstanceEvent)
+
+ if insEvent.AddEvent != nil {
+ watcher.notifyAllSubscriber(&config_center.ConfigChangeEvent{
+ Value: insEvent.AddEvent.Instances,
+ ConfigType: remoting.EventTypeAdd,
+ })
+ }
+ if insEvent.UpdateEvent != nil {
+ instances := make([]model.Instance, len(insEvent.UpdateEvent.UpdateList))
+ for i := range insEvent.UpdateEvent.UpdateList {
+ instances[i] = insEvent.UpdateEvent.UpdateList[i].After
+ }
+ watcher.notifyAllSubscriber(&config_center.ConfigChangeEvent{
+ Value: instances,
+ ConfigType: remoting.EventTypeUpdate,
+ })
+ }
+ if insEvent.DeleteEvent != nil {
+ watcher.notifyAllSubscriber(&config_center.ConfigChangeEvent{
+ Value: insEvent.DeleteEvent.Instances,
+ ConfigType: remoting.EventTypeDel,
+ })
}
- watcher.notifyAllSubscriber(&config_center.ConfigChangeEvent{
- Value: instances,
- ConfigType: remoting.EventTypeUpdate,
- })
- }
- if insEvent.DeleteEvent != nil {
- watcher.notifyAllSubscriber(&config_center.ConfigChangeEvent{
- Value: insEvent.DeleteEvent.Instances,
- ConfigType: remoting.EventTypeDel,
- })
}
+ case <-time.After(20 * time.Second):
Review Comment:
这一块逻辑的作用?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo-go] jasondeng1997 commented on a diff in pull request #1988: fix PolarisServiceWatcher bug
Posted by GitBox <gi...@apache.org>.
jasondeng1997 commented on code in PR #1988:
URL: https://github.com/apache/dubbo-go/pull/1988#discussion_r927231808
##########
registry/polaris/core.go:
##########
@@ -74,48 +73,52 @@ func (watcher *PolarisServiceWatcher) lazyRun() {
// startWatch start run work to watch target service by polaris
func (watcher *PolarisServiceWatcher) startWatch() {
-
for {
resp, err := watcher.consumer.WatchService(watcher.subscribeParam)
if err != nil {
time.Sleep(time.Duration(500 * time.Millisecond))
continue
}
-
watcher.notifyAllSubscriber(&config_center.ConfigChangeEvent{
Value: resp.GetAllInstancesResp.Instances,
ConfigType: remoting.EventTypeAdd,
})
- select {
- case event := <-resp.EventChannel:
- eType := event.GetSubScribeEventType()
- if eType == api.EventInstance {
- insEvent := event.(*model.InstanceEvent)
- if insEvent.AddEvent != nil {
- watcher.notifyAllSubscriber(&config_center.ConfigChangeEvent{
- Value: insEvent.AddEvent.Instances,
- ConfigType: remoting.EventTypeAdd,
- })
- }
- if insEvent.UpdateEvent != nil {
- instances := make([]model.Instance, len(insEvent.UpdateEvent.UpdateList))
- for i := range insEvent.UpdateEvent.UpdateList {
- instances[i] = insEvent.UpdateEvent.UpdateList[i].After
+ for {
+ select {
+ case event := <-resp.EventChannel:
+ eType := event.GetSubScribeEventType()
+ if eType == api.EventInstance {
+ insEvent := event.(*model.InstanceEvent)
+
+ if insEvent.AddEvent != nil {
+ watcher.notifyAllSubscriber(&config_center.ConfigChangeEvent{
+ Value: insEvent.AddEvent.Instances,
+ ConfigType: remoting.EventTypeAdd,
+ })
+ }
+ if insEvent.UpdateEvent != nil {
+ instances := make([]model.Instance, len(insEvent.UpdateEvent.UpdateList))
+ for i := range insEvent.UpdateEvent.UpdateList {
+ instances[i] = insEvent.UpdateEvent.UpdateList[i].After
+ }
+ watcher.notifyAllSubscriber(&config_center.ConfigChangeEvent{
+ Value: instances,
+ ConfigType: remoting.EventTypeUpdate,
+ })
+ }
+ if insEvent.DeleteEvent != nil {
+ watcher.notifyAllSubscriber(&config_center.ConfigChangeEvent{
+ Value: insEvent.DeleteEvent.Instances,
+ ConfigType: remoting.EventTypeDel,
+ })
}
- watcher.notifyAllSubscriber(&config_center.ConfigChangeEvent{
- Value: instances,
- ConfigType: remoting.EventTypeUpdate,
- })
- }
- if insEvent.DeleteEvent != nil {
- watcher.notifyAllSubscriber(&config_center.ConfigChangeEvent{
- Value: insEvent.DeleteEvent.Instances,
- ConfigType: remoting.EventTypeDel,
- })
}
+ case <-time.After(20 * time.Second):
Review Comment:
阻塞20秒以后再执行,所以先执行上面的,上面的如果20秒还没有执行完,重新执行说明上面的bug,当然是否可以用户自定义,另外20秒是否过长,这个在dubbo yaml配置文件里面可以用户自定义配置
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo-go] jasondeng1997 commented on pull request #1988: fix PolarisServiceWatcher bug
Posted by GitBox <gi...@apache.org>.
jasondeng1997 commented on PR #1988:
URL: https://github.com/apache/dubbo-go/pull/1988#issuecomment-1191110473
@chuntaojun pls review pr
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo-go] jasondeng1997 commented on pull request #1988: fix PolarisServiceWatcher bug
Posted by GitBox <gi...@apache.org>.
jasondeng1997 commented on PR #1988:
URL: https://github.com/apache/dubbo-go/pull/1988#issuecomment-1191110360
@chuntaojun pls review pr
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo-go] codecov-commenter commented on pull request #1988: fix PolarisServiceWatcher bug
Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #1988:
URL: https://github.com/apache/dubbo-go/pull/1988#issuecomment-1191121769
# [Codecov](https://codecov.io/gh/apache/dubbo-go/pull/1988?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#1988](https://codecov.io/gh/apache/dubbo-go/pull/1988?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (989852b) into [3.0](https://codecov.io/gh/apache/dubbo-go/commit/98e3c7a9a05997b663283126b6b892b44f1cbcd2?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (98e3c7a) will **increase** coverage by `0.02%`.
> The diff coverage is `n/a`.
```diff
@@ Coverage Diff @@
## 3.0 #1988 +/- ##
==========================================
+ Coverage 44.38% 44.40% +0.02%
==========================================
Files 283 283
Lines 17041 17055 +14
==========================================
+ Hits 7563 7573 +10
- Misses 8672 8680 +8
+ Partials 806 802 -4
```
| [Impacted Files](https://codecov.io/gh/apache/dubbo-go/pull/1988?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [cluster/cluster/base/cluster\_invoker.go](https://codecov.io/gh/apache/dubbo-go/pull/1988/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y2x1c3Rlci9jbHVzdGVyL2Jhc2UvY2x1c3Rlcl9pbnZva2VyLmdv) | `24.44% <0.00%> (-13.34%)` | :arrow_down: |
| [config/graceful\_shutdown.go](https://codecov.io/gh/apache/dubbo-go/pull/1988/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y29uZmlnL2dyYWNlZnVsX3NodXRkb3duLmdv) | `3.88% <0.00%> (-0.12%)` | :arrow_down: |
| [filter/graceful\_shutdown/provider\_filter.go](https://codecov.io/gh/apache/dubbo-go/pull/1988/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZmlsdGVyL2dyYWNlZnVsX3NodXRkb3duL3Byb3ZpZGVyX2ZpbHRlci5nbw==) | `74.35% <0.00%> (+0.67%)` | :arrow_up: |
| [metrics/prometheus/reporter.go](https://codecov.io/gh/apache/dubbo-go/pull/1988/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-bWV0cmljcy9wcm9tZXRoZXVzL3JlcG9ydGVyLmdv) | `31.79% <0.00%> (+1.53%)` | :arrow_up: |
| [config/graceful\_shutdown\_config.go](https://codecov.io/gh/apache/dubbo-go/pull/1988/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y29uZmlnL2dyYWNlZnVsX3NodXRkb3duX2NvbmZpZy5nbw==) | `92.72% <0.00%> (+19.39%)` | :arrow_up: |
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo-go] chuntaojun commented on a diff in pull request #1988: fix PolarisServiceWatcher bug and add ZookeeperServiceDiscovery ut
Posted by GitBox <gi...@apache.org>.
chuntaojun commented on code in PR #1988:
URL: https://github.com/apache/dubbo-go/pull/1988#discussion_r928108610
##########
registry/polaris/core.go:
##########
@@ -74,48 +73,52 @@ func (watcher *PolarisServiceWatcher) lazyRun() {
// startWatch start run work to watch target service by polaris
func (watcher *PolarisServiceWatcher) startWatch() {
-
for {
resp, err := watcher.consumer.WatchService(watcher.subscribeParam)
if err != nil {
time.Sleep(time.Duration(500 * time.Millisecond))
continue
}
-
watcher.notifyAllSubscriber(&config_center.ConfigChangeEvent{
Value: resp.GetAllInstancesResp.Instances,
ConfigType: remoting.EventTypeAdd,
})
- select {
- case event := <-resp.EventChannel:
- eType := event.GetSubScribeEventType()
- if eType == api.EventInstance {
- insEvent := event.(*model.InstanceEvent)
- if insEvent.AddEvent != nil {
- watcher.notifyAllSubscriber(&config_center.ConfigChangeEvent{
- Value: insEvent.AddEvent.Instances,
- ConfigType: remoting.EventTypeAdd,
- })
- }
- if insEvent.UpdateEvent != nil {
- instances := make([]model.Instance, len(insEvent.UpdateEvent.UpdateList))
- for i := range insEvent.UpdateEvent.UpdateList {
- instances[i] = insEvent.UpdateEvent.UpdateList[i].After
+ for {
+ select {
+ case event := <-resp.EventChannel:
+ eType := event.GetSubScribeEventType()
+ if eType == api.EventInstance {
+ insEvent := event.(*model.InstanceEvent)
+
+ if insEvent.AddEvent != nil {
+ watcher.notifyAllSubscriber(&config_center.ConfigChangeEvent{
+ Value: insEvent.AddEvent.Instances,
+ ConfigType: remoting.EventTypeAdd,
+ })
+ }
+ if insEvent.UpdateEvent != nil {
+ instances := make([]model.Instance, len(insEvent.UpdateEvent.UpdateList))
+ for i := range insEvent.UpdateEvent.UpdateList {
+ instances[i] = insEvent.UpdateEvent.UpdateList[i].After
+ }
+ watcher.notifyAllSubscriber(&config_center.ConfigChangeEvent{
+ Value: instances,
+ ConfigType: remoting.EventTypeUpdate,
+ })
+ }
+ if insEvent.DeleteEvent != nil {
+ watcher.notifyAllSubscriber(&config_center.ConfigChangeEvent{
+ Value: insEvent.DeleteEvent.Instances,
+ ConfigType: remoting.EventTypeDel,
+ })
}
- watcher.notifyAllSubscriber(&config_center.ConfigChangeEvent{
- Value: instances,
- ConfigType: remoting.EventTypeUpdate,
- })
- }
- if insEvent.DeleteEvent != nil {
- watcher.notifyAllSubscriber(&config_center.ConfigChangeEvent{
- Value: insEvent.DeleteEvent.Instances,
- ConfigType: remoting.EventTypeDel,
- })
}
+ case <-time.After(1 * time.Second):
Review Comment:
感觉这个是可以移除的,应该不太需求
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo-go] chuntaojun commented on a diff in pull request #1988: fix PolarisServiceWatcher bug and add ZookeeperServiceDiscovery ut
Posted by GitBox <gi...@apache.org>.
chuntaojun commented on code in PR #1988:
URL: https://github.com/apache/dubbo-go/pull/1988#discussion_r928370138
##########
registry/polaris/core.go:
##########
@@ -74,48 +73,52 @@ func (watcher *PolarisServiceWatcher) lazyRun() {
// startWatch start run work to watch target service by polaris
func (watcher *PolarisServiceWatcher) startWatch() {
-
for {
resp, err := watcher.consumer.WatchService(watcher.subscribeParam)
if err != nil {
time.Sleep(time.Duration(500 * time.Millisecond))
continue
}
-
watcher.notifyAllSubscriber(&config_center.ConfigChangeEvent{
Value: resp.GetAllInstancesResp.Instances,
ConfigType: remoting.EventTypeAdd,
})
- select {
- case event := <-resp.EventChannel:
- eType := event.GetSubScribeEventType()
- if eType == api.EventInstance {
- insEvent := event.(*model.InstanceEvent)
- if insEvent.AddEvent != nil {
- watcher.notifyAllSubscriber(&config_center.ConfigChangeEvent{
- Value: insEvent.AddEvent.Instances,
- ConfigType: remoting.EventTypeAdd,
- })
- }
- if insEvent.UpdateEvent != nil {
- instances := make([]model.Instance, len(insEvent.UpdateEvent.UpdateList))
- for i := range insEvent.UpdateEvent.UpdateList {
- instances[i] = insEvent.UpdateEvent.UpdateList[i].After
+ for {
+ select {
+ case event := <-resp.EventChannel:
+ eType := event.GetSubScribeEventType()
+ if eType == api.EventInstance {
+ insEvent := event.(*model.InstanceEvent)
+
+ if insEvent.AddEvent != nil {
+ watcher.notifyAllSubscriber(&config_center.ConfigChangeEvent{
+ Value: insEvent.AddEvent.Instances,
+ ConfigType: remoting.EventTypeAdd,
+ })
+ }
+ if insEvent.UpdateEvent != nil {
+ instances := make([]model.Instance, len(insEvent.UpdateEvent.UpdateList))
+ for i := range insEvent.UpdateEvent.UpdateList {
+ instances[i] = insEvent.UpdateEvent.UpdateList[i].After
+ }
+ watcher.notifyAllSubscriber(&config_center.ConfigChangeEvent{
+ Value: instances,
+ ConfigType: remoting.EventTypeUpdate,
+ })
+ }
+ if insEvent.DeleteEvent != nil {
+ watcher.notifyAllSubscriber(&config_center.ConfigChangeEvent{
+ Value: insEvent.DeleteEvent.Instances,
+ ConfigType: remoting.EventTypeDel,
+ })
}
- watcher.notifyAllSubscriber(&config_center.ConfigChangeEvent{
- Value: instances,
- ConfigType: remoting.EventTypeUpdate,
- })
- }
- if insEvent.DeleteEvent != nil {
- watcher.notifyAllSubscriber(&config_center.ConfigChangeEvent{
- Value: insEvent.DeleteEvent.Instances,
- ConfigType: remoting.EventTypeDel,
- })
}
+ case <-time.After(20 * time.Second):
Review Comment:
> 感觉完全没有必要在在外层加一个for
大佬要不一起来DingTalk:44817370 一起聊下?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo-go] hYuang commented on a diff in pull request #1988: fix PolarisServiceWatcher bug and add ZookeeperServiceDiscovery ut
Posted by GitBox <gi...@apache.org>.
hYuang commented on code in PR #1988:
URL: https://github.com/apache/dubbo-go/pull/1988#discussion_r928189115
##########
registry/polaris/core.go:
##########
@@ -74,48 +73,52 @@ func (watcher *PolarisServiceWatcher) lazyRun() {
// startWatch start run work to watch target service by polaris
func (watcher *PolarisServiceWatcher) startWatch() {
-
for {
resp, err := watcher.consumer.WatchService(watcher.subscribeParam)
if err != nil {
time.Sleep(time.Duration(500 * time.Millisecond))
continue
}
-
watcher.notifyAllSubscriber(&config_center.ConfigChangeEvent{
Value: resp.GetAllInstancesResp.Instances,
ConfigType: remoting.EventTypeAdd,
})
- select {
- case event := <-resp.EventChannel:
- eType := event.GetSubScribeEventType()
- if eType == api.EventInstance {
- insEvent := event.(*model.InstanceEvent)
- if insEvent.AddEvent != nil {
- watcher.notifyAllSubscriber(&config_center.ConfigChangeEvent{
- Value: insEvent.AddEvent.Instances,
- ConfigType: remoting.EventTypeAdd,
- })
- }
- if insEvent.UpdateEvent != nil {
- instances := make([]model.Instance, len(insEvent.UpdateEvent.UpdateList))
- for i := range insEvent.UpdateEvent.UpdateList {
- instances[i] = insEvent.UpdateEvent.UpdateList[i].After
+ for {
+ select {
+ case event := <-resp.EventChannel:
+ eType := event.GetSubScribeEventType()
+ if eType == api.EventInstance {
+ insEvent := event.(*model.InstanceEvent)
+
+ if insEvent.AddEvent != nil {
+ watcher.notifyAllSubscriber(&config_center.ConfigChangeEvent{
+ Value: insEvent.AddEvent.Instances,
+ ConfigType: remoting.EventTypeAdd,
+ })
+ }
+ if insEvent.UpdateEvent != nil {
+ instances := make([]model.Instance, len(insEvent.UpdateEvent.UpdateList))
+ for i := range insEvent.UpdateEvent.UpdateList {
+ instances[i] = insEvent.UpdateEvent.UpdateList[i].After
+ }
+ watcher.notifyAllSubscriber(&config_center.ConfigChangeEvent{
+ Value: instances,
+ ConfigType: remoting.EventTypeUpdate,
+ })
+ }
+ if insEvent.DeleteEvent != nil {
+ watcher.notifyAllSubscriber(&config_center.ConfigChangeEvent{
+ Value: insEvent.DeleteEvent.Instances,
+ ConfigType: remoting.EventTypeDel,
+ })
}
- watcher.notifyAllSubscriber(&config_center.ConfigChangeEvent{
- Value: instances,
- ConfigType: remoting.EventTypeUpdate,
- })
- }
- if insEvent.DeleteEvent != nil {
- watcher.notifyAllSubscriber(&config_center.ConfigChangeEvent{
- Value: insEvent.DeleteEvent.Instances,
- ConfigType: remoting.EventTypeDel,
- })
}
+ case <-time.After(20 * time.Second):
Review Comment:
感觉完全没有必要在在外层加一个for
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
[GitHub] [dubbo-go] AlexStocks merged pull request #1988: fix PolarisServiceWatcher bug and add ZookeeperServiceDiscovery ut
Posted by GitBox <gi...@apache.org>.
AlexStocks merged PR #1988:
URL: https://github.com/apache/dubbo-go/pull/1988
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org