chuntaojun commented on code in PR #2100:
URL: https://github.com/apache/dubbo-go/pull/2100#discussion_r1017369034
##########
registry/polaris/listener.go:
##########
@@ -38,29 +39,35 @@ import (
)
type polarisListener struct {
- watcher *PolarisServiceWatcher
- listenUrl *common.URL
- events *gxchan.UnboundedChan
- closeCh chan struct{}
+ watcher *PolarisServiceWatcher
+ events *gxchan.UnboundedChan
+ closeCh chan struct{}
}
// NewPolarisListener new polaris listener
-func NewPolarisListener(url *common.URL) (*polarisListener, error) {
+func NewPolarisListener(watcher *PolarisServiceWatcher) (*polarisListener,
error) {
listener := &polarisListener{
- listenUrl: url,
- events: gxchan.NewUnboundedChan(32),
- closeCh: make(chan struct{}),
+ watcher: watcher,
+ events: gxchan.NewUnboundedChan(32),
+ closeCh: make(chan struct{}),
}
-
+ listener.startListen()
return listener, nil
}
+func (pl *polarisListener) startListen() {
+ pl.watcher.AddSubscriber(func(et remoting.EventType, ins
[]model.Instance) {
+ for i := range ins {
+ pl.events.In() <-
&config_center.ConfigChangeEvent{Value: generateUrl(ins[i]), ConfigType: et}
+ }
+ })
+}
// Next returns next service event once received
func (pl *polarisListener) Next() (*registry.ServiceEvent, error) {
for {
select {
case <-pl.closeCh:
- logger.Warnf("polaris listener is close!listenUrl:%+v",
pl.listenUrl)
+ logger.Warnf("polaris listener is close!listenUrl:%+v")
Review Comment:
这个日志打印调整下
##########
remoting/polaris/polaris.yaml:
##########
@@ -93,3 +82,5 @@ consumer:
plugin:
subscribeLocalChannel:
channelBufferSize: 50
+ statReporter:
Review Comment:
放错位置了,就在原来的基础上改,不要调整 statReporter 的位置
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]