jasondeng1997 commented on code in PR #2100:
URL: https://github.com/apache/dubbo-go/pull/2100#discussion_r1017420964
##########
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:
ok
##########
remoting/polaris/polaris.yaml:
##########
@@ -93,3 +82,5 @@ consumer:
plugin:
subscribeLocalChannel:
channelBufferSize: 50
+ statReporter:
Review Comment:
ok
--
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]