fix: change name
diff --git a/cluster/cluster_impl/zone_aware_cluster_invoker.go b/cluster/cluster_impl/zone_aware_cluster_invoker.go
index 0f52b04..050f831 100644
--- a/cluster/cluster_impl/zone_aware_cluster_invoker.go
+++ b/cluster/cluster_impl/zone_aware_cluster_invoker.go
@@ -43,7 +43,7 @@
invoke := &zoneAwareClusterInvoker{
baseClusterInvoker: newBaseClusterInvoker(directory),
}
- // add self to interceptor
+ // add local to interceptor
invoke.interceptor = invoke
return invoke
}
diff --git a/cluster/router/self/factory.go b/cluster/router/local/factory.go
similarity index 64%
rename from cluster/router/self/factory.go
rename to cluster/router/local/factory.go
index 439d1c6..73864c8 100644
--- a/cluster/router/self/factory.go
+++ b/cluster/router/local/factory.go
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package self
+package local
import (
"github.com/apache/dubbo-go/cluster/router"
@@ -25,19 +25,19 @@
)
func init() {
- extension.SetRouterFactory(constant.SelfPriorityRouterName, newSelfPriorityRouteFactory)
+ extension.SetRouterFactory(constant.LocalPriorityRouterName, newLocalPriorityRouteFactory)
}
-// SelfPriorityRouteFactory
-type SelfPriorityRouteFactory struct {
+// LocalPriorityRouteFactory
+type LocalPriorityRouteFactory struct {
}
-// newSelfPriorityRouteFactory construct a new SelfDiscRouteFactory
-func newSelfPriorityRouteFactory() router.PriorityRouterFactory {
- return &SelfPriorityRouteFactory{}
+// newLocalPriorityRouteFactory construct a new LocalDiscRouteFactory
+func newLocalPriorityRouteFactory() router.PriorityRouterFactory {
+ return &LocalPriorityRouteFactory{}
}
-// NewPriorityRouter construct a new NewSelfDiscRouter via url
-func (f *SelfPriorityRouteFactory) NewPriorityRouter(url *common.URL) (router.PriorityRouter, error) {
- return NewSelfPriorityRouter(url)
+// NewPriorityRouter construct a new NewLocalDiscRouter via url
+func (f *LocalPriorityRouteFactory) NewPriorityRouter(url *common.URL) (router.PriorityRouter, error) {
+ return NewLocalPriorityRouter(url)
}
diff --git a/cluster/router/self/factory_test.go b/cluster/router/local/factory_test.go
similarity index 93%
rename from cluster/router/self/factory_test.go
rename to cluster/router/local/factory_test.go
index 1c74e79..a5a683b 100644
--- a/cluster/router/self/factory_test.go
+++ b/cluster/router/local/factory_test.go
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package self
+package local
import (
"context"
@@ -68,7 +68,7 @@
}
// nolint
-func TestSelfDiscRouteFactory(t *testing.T) {
- factory := newSelfPriorityRouteFactory()
+func TestLocalDiscRouteFactory(t *testing.T) {
+ factory := newLocalPriorityRouteFactory()
assert.NotNil(t, factory)
}
diff --git a/cluster/router/self/self_priority_route.go b/cluster/router/local/self_priority_route.go
similarity index 61%
rename from cluster/router/self/self_priority_route.go
rename to cluster/router/local/self_priority_route.go
index c6f146c..87eaaf7 100644
--- a/cluster/router/self/self_priority_route.go
+++ b/cluster/router/local/self_priority_route.go
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package self
+package local
import (
"github.com/RoaringBitmap/roaring"
@@ -30,21 +30,21 @@
)
const (
- selfPriority = "self-priority"
- name = "self-priority-router"
+ localPriority = "local-priority"
+ name = "local-priority-router"
)
-// SelfPriorityRouter provides a ip-same-first routing logic
+// LocalPriorityRouter provides a ip-same-first routing logic
// if there is not provider with same ip as consumer, it would not filter any invoker
// if exists same ip invoker, it would retains this invoker only
-type SelfPriorityRouter struct {
+type LocalPriorityRouter struct {
url *common.URL
localIP string
}
-// NewSelfPriorityRouter construct an SelfPriorityRouter via url
-func NewSelfPriorityRouter(url *common.URL) (router.PriorityRouter, error) {
- r := &SelfPriorityRouter{
+// NewLocalPriorityRouter construct an LocalPriorityRouter via url
+func NewLocalPriorityRouter(url *common.URL) (router.PriorityRouter, error) {
+ r := &LocalPriorityRouter{
url: url,
localIP: url.Ip,
}
@@ -52,10 +52,10 @@
}
// Route gets a list of match-logic invoker
-func (r *SelfPriorityRouter) Route(invokers *roaring.Bitmap, cache router.Cache, url *common.URL, invocation protocol.Invocation) *roaring.Bitmap {
+func (r *LocalPriorityRouter) Route(invokers *roaring.Bitmap, cache router.Cache, url *common.URL, invocation protocol.Invocation) *roaring.Bitmap {
addrPool := cache.FindAddrPool(r)
- // Add selfPriority invoker to the list
- selectedInvokers := utils.JoinIfNotEqual(addrPool[selfPriority], invokers)
+ // Add localPriority invoker to the list
+ selectedInvokers := utils.JoinIfNotEqual(addrPool[localPriority], invokers)
// If all invokers are considered not match, downgrade to all invoker
if selectedInvokers.IsEmpty() {
logger.Warnf(" Now all invokers are not match, so downgraded to all! Service: [%s]", url.ServiceKey())
@@ -65,42 +65,42 @@
}
// Pool separates same ip invoker from others.
-func (r *SelfPriorityRouter) Pool(invokers []protocol.Invoker) (router.AddrPool, router.AddrMetadata) {
+func (r *LocalPriorityRouter) Pool(invokers []protocol.Invoker) (router.AddrPool, router.AddrMetadata) {
rb := make(router.AddrPool, 8)
- rb[selfPriority] = roaring.NewBitmap()
- selfIpFound := false
+ rb[localPriority] = roaring.NewBitmap()
+ localIpFound := false
for i, invoker := range invokers {
if invoker.GetUrl().Ip == r.localIP {
- rb[selfPriority].Add(uint32(i))
- selfIpFound = true
+ rb[localPriority].Add(uint32(i))
+ localIpFound = true
}
}
- if selfIpFound {
- // found self desc
- logger.Debug("found self ip ")
+ if localIpFound {
+ // found local desc
+ logger.Debug("found local ip ")
return rb, nil
}
for i, _ := range invokers {
- rb[selfPriority].Add(uint32(i))
+ rb[localPriority].Add(uint32(i))
}
return rb, nil
}
-// ShouldPool will always return true to make sure self call logic constantly.
-func (r *SelfPriorityRouter) ShouldPool() bool {
+// ShouldPool will always return true to make sure local call logic constantly.
+func (r *LocalPriorityRouter) ShouldPool() bool {
return true
}
-func (r *SelfPriorityRouter) Name() string {
+func (r *LocalPriorityRouter) Name() string {
return name
}
// Priority
-func (r *SelfPriorityRouter) Priority() int64 {
+func (r *LocalPriorityRouter) Priority() int64 {
return 0
}
// URL Return URL in router
-func (r *SelfPriorityRouter) URL() *common.URL {
+func (r *LocalPriorityRouter) URL() *common.URL {
return r.url
}
diff --git a/cluster/router/self/self_priority_route_test.go b/cluster/router/local/self_priority_route_test.go
similarity index 68%
rename from cluster/router/self/self_priority_route_test.go
rename to cluster/router/local/self_priority_route_test.go
index ef7c6d8..88535d3 100644
--- a/cluster/router/self/self_priority_route_test.go
+++ b/cluster/router/local/self_priority_route_test.go
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package self
+package local
import (
"fmt"
@@ -36,34 +36,34 @@
)
const (
- selfDiscRoute1010IP = "192.168.10.10"
- selfDiscRoute1011IP = "192.168.10.11"
- selfDiscRoute1012IP = "192.168.10.12"
- selfDiscRouteMethodNameTest = "test"
- selfDiscRouteUrlFormat = "dubbo://%s:20000/com.ikurento.user.UserProvider"
+ localDiscRoute1010IP = "192.168.10.10"
+ localDiscRoute1011IP = "192.168.10.11"
+ localDiscRoute1012IP = "192.168.10.12"
+ localDiscRouteMethodNameTest = "test"
+ localDiscRouteUrlFormat = "dubbo://%s:20000/com.ikurento.user.UserProvider"
)
-func TestSelfDiscRouterRoute(t *testing.T) {
+func TestLocalDiscRouterRoute(t *testing.T) {
defer protocol.CleanAllStatus()
- consumerURL, _ := common.NewURL(fmt.Sprintf(selfDiscRouteUrlFormat, selfDiscRoute1010IP))
- url1, _ := common.NewURL(fmt.Sprintf(selfDiscRouteUrlFormat, selfDiscRoute1010IP))
- url2, _ := common.NewURL(fmt.Sprintf(selfDiscRouteUrlFormat, selfDiscRoute1011IP))
- url3, _ := common.NewURL(fmt.Sprintf(selfDiscRouteUrlFormat, selfDiscRoute1012IP))
- hcr, _ := NewSelfPriorityRouter(consumerURL)
+ consumerURL, _ := common.NewURL(fmt.Sprintf(localDiscRouteUrlFormat, localDiscRoute1010IP))
+ url1, _ := common.NewURL(fmt.Sprintf(localDiscRouteUrlFormat, localDiscRoute1010IP))
+ url2, _ := common.NewURL(fmt.Sprintf(localDiscRouteUrlFormat, localDiscRoute1011IP))
+ url3, _ := common.NewURL(fmt.Sprintf(localDiscRouteUrlFormat, localDiscRoute1012IP))
+ hcr, _ := NewLocalPriorityRouter(consumerURL)
var invokers []protocol.Invoker
invoker1 := NewMockInvoker(url1)
invoker2 := NewMockInvoker(url2)
invoker3 := NewMockInvoker(url3)
invokers = append(invokers, invoker1, invoker2, invoker3)
- inv := invocation.NewRPCInvocation(selfDiscRouteMethodNameTest, nil, nil)
- res := hcr.Route(utils.ToBitmap(invokers), setUpAddrCache(hcr.(*SelfPriorityRouter), invokers), consumerURL, inv)
+ inv := invocation.NewRPCInvocation(localDiscRouteMethodNameTest, nil, nil)
+ res := hcr.Route(utils.ToBitmap(invokers), setUpAddrCache(hcr.(*LocalPriorityRouter), invokers), consumerURL, inv)
// now only same ip invoker is selected
assert.True(t, len(res.ToArray()) == 1)
// now all invoker with ip that not match client are selected
invokers = invokers[1:]
- res = hcr.Route(utils.ToBitmap(invokers), setUpAddrCache(hcr.(*SelfPriorityRouter), invokers), consumerURL, inv)
+ res = hcr.Route(utils.ToBitmap(invokers), setUpAddrCache(hcr.(*LocalPriorityRouter), invokers), consumerURL, inv)
assert.True(t, len(res.ToArray()) == 2)
}
diff --git a/common/constant/key.go b/common/constant/key.go
index 109c581..59b95e4 100644
--- a/common/constant/key.go
+++ b/common/constant/key.go
@@ -214,8 +214,8 @@
ListenableRouterName = "listenable"
// HealthCheckRouterName Specify the name of HealthCheckRouter
HealthCheckRouterName = "health_check"
- // SelfPriorityRouterName Specify the name of SelfPriorityRouter
- SelfPriorityRouterName = "self_priority"
+ // LocalPriorityRouterName Specify the name of LocalPriorityRouter
+ LocalPriorityRouterName = "self_priority"
// TagRouterName Specify the name of TagRouter
TagRouterName = "tag"
// TagRouterRuleSuffix Specify tag router suffix
diff --git a/metadata/service/remote/service.go b/metadata/service/remote/service.go
index bb520d3..e2a7a64 100644
--- a/metadata/service/remote/service.go
+++ b/metadata/service/remote/service.go
@@ -107,7 +107,7 @@
// UnsubscribeURL will be implemented by in memory service
func (mts *MetadataService) UnsubscribeURL(url *common.URL) error {
- // TODO remove call self.
+ // TODO remove call local.
return nil
//return mts.UnsubscribeURL(url)
}