Merge remote-tracking branch 'origin/3.0' into 3.0
diff --git a/registry/polaris/core.go b/registry/polaris/core.go
index e87fac7..7e9f304 100644
--- a/registry/polaris/core.go
+++ b/registry/polaris/core.go
@@ -32,13 +32,13 @@
"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 @@
subscribeParam: param,
consumer: consumer,
lock: &sync.RWMutex{},
- subscribers: make([]subscriber, 0),
+ subscribers: make([]item, 0),
execOnce: &sync.Once{},
}
return watcher, nil
diff --git a/registry/polaris/core_test.go b/registry/polaris/core_test.go
index 0e806a3..26a573c 100644
--- a/registry/polaris/core_test.go
+++ b/registry/polaris/core_test.go
@@ -17,11 +17,15 @@
)
func TestPolarisServiceWatcher_AddSubscriber(t *testing.T) {
+ var (
+ newParam api.WatchServiceRequest
+ newConsumer api.ConsumerAPI
+ )
type fields struct {
consumer api.ConsumerAPI
subscribeParam *api.WatchServiceRequest
lock *sync.RWMutex
- subscribers []subscriber
+ subscribers []item
execOnce *sync.Once
}
type args struct {
@@ -38,7 +42,7 @@
subscribeParam: &newParam,
consumer: newConsumer,
lock: &sync.RWMutex{},
- subscribers: make([]subscriber, 0),
+ subscribers: make([]item, 0),
execOnce: &sync.Once{},
}
assert.Empty(t, watcher)
diff --git a/registry/polaris/registry.go b/registry/polaris/registry.go
index 210c0da..255acdb 100644
--- a/registry/polaris/registry.go
+++ b/registry/polaris/registry.go
@@ -150,8 +150,11 @@
// 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
- var newConsumer api.ConsumerAPI
+ var (
+ newParam api.WatchServiceRequest
+ newConsumer api.ConsumerAPI
+ )
+
role, _ := strconv.Atoi(url.GetParam(constant.RegistryRoleKey, ""))
if role != common.CONSUMER {
return nil