From 9651ec2bb1a7c56e39d23269496587bd94bf4d41 Mon Sep 17 00:00:00 2001 From: LaurenceLiZhixin <382673304@qq.com> Date: Mon, 5 Apr 2021 14:38:16 +0800 Subject: [PATCH 1/2] fix: fix lint bug --- cluster/cluster_impl/base_cluster_invoker.go | 18 +++++++++--------- .../cluster_impl/failback_cluster_invoker.go | 10 +++++----- .../cluster_impl/failover_cluster_invoker.go | 8 ++++---- cluster/cluster_impl/failover_cluster_test.go | 4 ++-- .../cluster_impl/failsafe_cluster_invoker.go | 2 +- .../cluster_impl/forking_cluster_invoker.go | 4 ++-- cluster/cluster_impl/mock_cluster.go | 2 +- .../cluster_impl/zone_aware_cluster_invoker.go | 4 ++-- cluster/directory/base_directory.go | 14 +++++++------- cluster/directory/base_directory_test.go | 2 +- cluster/directory/static_directory.go | 6 +++--- cluster/loadbalance/consistent_hash.go | 6 +++--- cluster/loadbalance/consistent_hash_test.go | 6 +++--- cluster/loadbalance/least_active.go | 2 +- cluster/loadbalance/least_active_test.go | 8 ++++---- cluster/loadbalance/random_test.go | 6 +++--- cluster/loadbalance/round_robin.go | 4 ++-- cluster/loadbalance/round_robin_test.go | 4 ++-- cluster/loadbalance/util.go | 2 +- cluster/router/chain/chain.go | 4 ++-- common/node.go | 2 +- common/proxy/proxy_factory/default.go | 2 +- common/proxy/proxy_factory/pass_through.go | 2 +- config/config_loader_test.go | 2 +- config/reference_config.go | 2 +- config/service_config.go | 2 +- config_center/nacos/client.go | 2 +- config_center/zookeeper/impl.go | 2 +- config_center/zookeeper/impl_test.go | 2 +- config_center/zookeeper/listener_test.go | 2 +- filter/filter_impl/access_log_filter.go | 2 +- filter/filter_impl/active_filter.go | 4 ++-- filter/filter_impl/auth/consumer_sign.go | 2 +- filter/filter_impl/auth/provider_auth.go | 2 +- filter/filter_impl/execute_limit_filter.go | 2 +- filter/filter_impl/generic_service_filter.go | 2 +- filter/filter_impl/graceful_shutdown_filter.go | 2 +- filter/filter_impl/hystrix_filter.go | 4 ++-- filter/filter_impl/sentinel_filter.go | 4 ++-- filter/filter_impl/token_filter.go | 2 +- filter/filter_impl/tps_limit_filter.go | 4 ++-- filter/filter_impl/tracing_filter.go | 2 +- .../metadata_service_proxy_factory_test.go | 2 +- metadata/service/remote/service_proxy_test.go | 16 ++++++++-------- metrics/prometheus/reporter.go | 2 +- protocol/dubbo/dubbo_exporter.go | 4 ++-- protocol/dubbo/dubbo_invoker.go | 10 +++++----- protocol/dubbo/dubbo_protocol.go | 2 +- protocol/dubbo/dubbo_protocol_test.go | 6 +++--- protocol/dubbo3/dubbo3_exporter.go | 2 +- protocol/dubbo3/dubbo3_invoker.go | 4 ++-- protocol/dubbo3/dubbo3_protocol.go | 2 +- protocol/dubbo3/dubbo3_protocol_test.go | 4 ++-- protocol/grpc/grpc_exporter.go | 4 ++-- protocol/grpc/grpc_protocol.go | 2 +- protocol/grpc/grpc_protocol_test.go | 4 ++-- protocol/invoker.go | 6 +++--- protocol/invoker_test.go | 2 +- protocol/jsonrpc/jsonrpc_exporter.go | 4 ++-- protocol/jsonrpc/jsonrpc_invoker.go | 2 +- protocol/jsonrpc/jsonrpc_protocol.go | 2 +- protocol/jsonrpc/jsonrpc_protocol_test.go | 4 ++-- protocol/mock/mock_invoker.go | 8 ++++---- .../protocolwrapper/protocol_filter_wrapper.go | 10 +++++----- protocol/rest/rest_exporter.go | 4 ++-- protocol/rest/rest_invoker.go | 2 +- protocol/rest/rest_protocol.go | 2 +- protocol/rest/rest_protocol_test.go | 4 ++-- protocol/rest/server/rest_server.go | 2 +- protocol/rpc_status.go | 10 +++++----- registry/base_registry.go | 4 ++-- registry/consul/registry.go | 4 ++-- registry/directory/directory.go | 8 ++++---- registry/directory/directory_test.go | 4 ++-- registry/mock_registry.go | 2 +- registry/nacos/registry.go | 4 ++-- registry/protocol/protocol.go | 8 ++++---- registry/protocol/protocol_test.go | 4 ++-- .../service_discovery_registry.go | 2 +- registry/zookeeper/service_discovery.go | 2 +- remoting/etcdv3/facade.go | 2 +- remoting/kubernetes/client.go | 2 +- remoting/kubernetes/facade_test.go | 2 +- remoting/zookeeper/client.go | 2 +- remoting/zookeeper/facade.go | 2 +- remoting/zookeeper/facade_test.go | 2 +- 86 files changed, 174 insertions(+), 174 deletions(-) diff --git a/cluster/cluster_impl/base_cluster_invoker.go b/cluster/cluster_impl/base_cluster_invoker.go index 2df5f36b1d..fa6623cf29 100644 --- a/cluster/cluster_impl/base_cluster_invoker.go +++ b/cluster/cluster_impl/base_cluster_invoker.go @@ -51,8 +51,8 @@ func newBaseClusterInvoker(directory cluster.Directory) baseClusterInvoker { } } -func (invoker *baseClusterInvoker) GetUrl() *common.URL { - return invoker.directory.GetUrl() +func (invoker *baseClusterInvoker) GetURL() *common.URL { + return invoker.directory.GetURL() } func (invoker *baseClusterInvoker) Destroy() { @@ -75,7 +75,7 @@ func (invoker *baseClusterInvoker) checkInvokers(invokers []protocol.Invoker, in ip := common.GetLocalIp() return perrors.Errorf("Failed to invoke the method %v. No provider available for the service %v from "+ "registry %v on the consumer %v using the dubbo version %v .Please check if the providers have been started and registered.", - invocation.MethodName(), invoker.directory.GetUrl().SubURL.Key(), invoker.directory.GetUrl().String(), ip, constant.Version) + invocation.MethodName(), invoker.directory.GetURL().SubURL.Key(), invoker.directory.GetURL().String(), ip, constant.Version) } return nil } @@ -85,7 +85,7 @@ func (invoker *baseClusterInvoker) checkWhetherDestroyed() error { if invoker.destroyed.Load() { ip := common.GetLocalIp() return perrors.Errorf("Rpc cluster invoker for %v on consumer %v use dubbo version %v is now destroyed! can not invoke any more. ", - invoker.directory.GetUrl().Service(), ip, constant.Version) + invoker.directory.GetURL().Service(), ip, constant.Version) } return nil } @@ -96,7 +96,7 @@ func (invoker *baseClusterInvoker) doSelect(lb cluster.LoadBalance, invocation p return selectedInvoker } - url := invokers[0].GetUrl() + url := invokers[0].GetURL() sticky := url.GetParamBool(constant.STICKY_KEY, false) // Get the service method sticky config if have sticky = url.GetMethodParamBool(invocation.MethodName(), constant.STICKY_KEY, sticky) @@ -128,7 +128,7 @@ func (invoker *baseClusterInvoker) doSelectInvoker(lb cluster.LoadBalance, invoc return invokers[0] } protocol.SetInvokerUnhealthyStatus(invokers[0]) - logger.Errorf("the invokers of %s is nil. ", invokers[0].GetUrl().ServiceKey()) + logger.Errorf("the invokers of %s is nil. ", invokers[0].GetURL().ServiceKey()) return nil } @@ -151,7 +151,7 @@ func (invoker *baseClusterInvoker) doSelectInvoker(lb cluster.LoadBalance, invoc } if !reselectedInvoker.IsAvailable() { logger.Infof("the invoker of %s is not available, maybe some network error happened or the server is shutdown.", - invoker.GetUrl().Ip) + invoker.GetURL().Ip) protocol.SetInvokerUnhealthyStatus(reselectedInvoker) otherInvokers = getOtherInvokers(otherInvokers, reselectedInvoker) continue @@ -161,7 +161,7 @@ func (invoker *baseClusterInvoker) doSelectInvoker(lb cluster.LoadBalance, invoc } else { return selectedInvoker } - logger.Errorf("all %d invokers is unavailable for %s.", len(invokers), selectedInvoker.GetUrl().String()) + logger.Errorf("all %d invokers is unavailable for %s.", len(invokers), selectedInvoker.GetURL().String()) return nil } @@ -189,7 +189,7 @@ func isInvoked(selectedInvoker protocol.Invoker, invoked []protocol.Invoker) boo } func getLoadBalance(invoker protocol.Invoker, invocation protocol.Invocation) cluster.LoadBalance { - url := invoker.GetUrl() + url := invoker.GetURL() methodName := invocation.MethodName() // Get the service loadbalance config diff --git a/cluster/cluster_impl/failback_cluster_invoker.go b/cluster/cluster_impl/failback_cluster_invoker.go index 2ed1bae0d5..215de5bf12 100644 --- a/cluster/cluster_impl/failback_cluster_invoker.go +++ b/cluster/cluster_impl/failback_cluster_invoker.go @@ -56,14 +56,14 @@ func newFailbackClusterInvoker(directory cluster.Directory) protocol.Invoker { invoker := &failbackClusterInvoker{ baseClusterInvoker: newBaseClusterInvoker(directory), } - retriesConfig := invoker.GetUrl().GetParam(constant.RETRIES_KEY, constant.DEFAULT_FAILBACK_TIMES) + retriesConfig := invoker.GetURL().GetParam(constant.RETRIES_KEY, constant.DEFAULT_FAILBACK_TIMES) retries, err := strconv.Atoi(retriesConfig) if err != nil || retries < 0 { logger.Error("Your retries config is invalid,pls do a check. And will use the default fail back times configuration instead.") retries = constant.DEFAULT_FAILBACK_TIMES_INT } - failbackTasksConfig := invoker.GetUrl().GetParamInt(constant.FAIL_BACK_TASKS_KEY, constant.DEFAULT_FAILBACK_TASKS) + failbackTasksConfig := invoker.GetURL().GetParamInt(constant.FAIL_BACK_TASKS_KEY, constant.DEFAULT_FAILBACK_TASKS) if failbackTasksConfig <= 0 { failbackTasksConfig = constant.DEFAULT_FAILBACK_TASKS } @@ -114,7 +114,7 @@ func (invoker *failbackClusterInvoker) process(ctx context.Context) { func (invoker *failbackClusterInvoker) checkRetry(retryTask *retryTimerTask, err error) { logger.Errorf("Failed retry to invoke the method %v in the service %v, wait again. The exception: %v.\n", - retryTask.invocation.MethodName(), invoker.GetUrl().Service(), err.Error()) + retryTask.invocation.MethodName(), invoker.GetURL().Service(), err.Error()) retryTask.retries++ retryTask.lastT = time.Now() if retryTask.retries > invoker.maxRetries { @@ -133,12 +133,12 @@ func (invoker *failbackClusterInvoker) Invoke(ctx context.Context, invocation pr invokers := invoker.directory.List(invocation) if err := invoker.checkInvokers(invokers, invocation); err != nil { logger.Errorf("Failed to invoke the method %v in the service %v, wait for retry in background. Ignored exception: %v.\n", - invocation.MethodName(), invoker.GetUrl().Service(), err) + invocation.MethodName(), invoker.GetURL().Service(), err) return &protocol.RPCResult{} } // Get the service loadbalance config - url := invokers[0].GetUrl() + url := invokers[0].GetURL() lb := url.GetParam(constant.LOADBALANCE_KEY, constant.DEFAULT_LOADBALANCE) // Get the service method loadbalance config if have methodName := invocation.MethodName() diff --git a/cluster/cluster_impl/failover_cluster_invoker.go b/cluster/cluster_impl/failover_cluster_invoker.go index 3d070c1c27..45a94e55f9 100644 --- a/cluster/cluster_impl/failover_cluster_invoker.go +++ b/cluster/cluster_impl/failover_cluster_invoker.go @@ -84,14 +84,14 @@ func (invoker *failoverClusterInvoker) Invoke(ctx context.Context, invocation pr // DO INVOKE result = ivk.Invoke(ctx, invocation) if result.Error() != nil { - providers = append(providers, ivk.GetUrl().Key()) + providers = append(providers, ivk.GetURL().Key()) continue } return result } ip := common.GetLocalIp() - invokerSvc := invoker.GetUrl().Service() - invokerUrl := invoker.directory.GetUrl() + invokerSvc := invoker.GetURL().Service() + invokerUrl := invoker.directory.GetURL() if ivk == nil { logger.Errorf("Failed to invoke the method %s of the service %s .No provider is available.", methodName, invokerSvc) return &protocol.RPCResult{ @@ -114,7 +114,7 @@ func getRetries(invokers []protocol.Invoker, methodName string) int { return constant.DEFAULT_RETRIES_INT } - url := invokers[0].GetUrl() + url := invokers[0].GetURL() // get reties retriesConfig := url.GetParam(constant.RETRIES_KEY, constant.DEFAULT_RETRIES) // Get the service method loadbalance config if have diff --git a/cluster/cluster_impl/failover_cluster_test.go b/cluster/cluster_impl/failover_cluster_test.go index dd43e0ff8a..973a3a3e1e 100644 --- a/cluster/cluster_impl/failover_cluster_test.go +++ b/cluster/cluster_impl/failover_cluster_test.go @@ -64,7 +64,7 @@ func NewMockInvoker(url *common.URL, successCount int) *MockInvoker { } // nolint -func (bi *MockInvoker) GetUrl() *common.URL { +func (bi *MockInvoker) GetURL() *common.URL { return bi.url } @@ -103,7 +103,7 @@ func (bi *MockInvoker) Invoke(c context.Context, invocation protocol.Invocation) // nolint func (bi *MockInvoker) Destroy() { - logger.Infof("Destroy invoker: %v", bi.GetUrl().String()) + logger.Infof("Destroy invoker: %v", bi.GetURL().String()) bi.destroyed = true bi.available = false } diff --git a/cluster/cluster_impl/failsafe_cluster_invoker.go b/cluster/cluster_impl/failsafe_cluster_invoker.go index 29d888475c..89b227d153 100644 --- a/cluster/cluster_impl/failsafe_cluster_invoker.go +++ b/cluster/cluster_impl/failsafe_cluster_invoker.go @@ -55,7 +55,7 @@ func (invoker *failsafeClusterInvoker) Invoke(ctx context.Context, invocation pr return &protocol.RPCResult{} } - url := invokers[0].GetUrl() + url := invokers[0].GetURL() methodName := invocation.MethodName() // Get the service loadbalance config lb := url.GetParam(constant.LOADBALANCE_KEY, constant.DEFAULT_LOADBALANCE) diff --git a/cluster/cluster_impl/forking_cluster_invoker.go b/cluster/cluster_impl/forking_cluster_invoker.go index 3ffda580ce..6be6b36291 100644 --- a/cluster/cluster_impl/forking_cluster_invoker.go +++ b/cluster/cluster_impl/forking_cluster_invoker.go @@ -56,8 +56,8 @@ func (invoker *forkingClusterInvoker) Invoke(ctx context.Context, invocation pro } var selected []protocol.Invoker - forks := invoker.GetUrl().GetParamByIntValue(constant.FORKS_KEY, constant.DEFAULT_FORKS) - timeouts := invoker.GetUrl().GetParamInt(constant.TIMEOUT_KEY, constant.DEFAULT_TIMEOUT) + forks := invoker.GetURL().GetParamByIntValue(constant.FORKS_KEY, constant.DEFAULT_FORKS) + timeouts := invoker.GetURL().GetParamInt(constant.TIMEOUT_KEY, constant.DEFAULT_TIMEOUT) if forks < 0 || forks > len(invokers) { selected = invokers } else { diff --git a/cluster/cluster_impl/mock_cluster.go b/cluster/cluster_impl/mock_cluster.go index a7fa5d4f02..a6434175fb 100644 --- a/cluster/cluster_impl/mock_cluster.go +++ b/cluster/cluster_impl/mock_cluster.go @@ -35,5 +35,5 @@ func NewMockCluster() cluster.Cluster { // nolint func (cluster *mockCluster) Join(directory cluster.Directory) protocol.Invoker { - return protocol.NewBaseInvoker(directory.GetUrl()) + return protocol.NewBaseInvoker(directory.GetURL()) } diff --git a/cluster/cluster_impl/zone_aware_cluster_invoker.go b/cluster/cluster_impl/zone_aware_cluster_invoker.go index 9834d87173..9ea5557455 100644 --- a/cluster/cluster_impl/zone_aware_cluster_invoker.go +++ b/cluster/cluster_impl/zone_aware_cluster_invoker.go @@ -80,7 +80,7 @@ func (invoker *zoneAwareClusterInvoker) DoInvoke(ctx context.Context, invocation return &protocol.RPCResult{ Err: fmt.Errorf("no registry instance in zone or "+ "no available providers in the registry, zone: %v, "+ - " registries: %v", zone, invoker.GetUrl()), + " registries: %v", zone, invoker.GetURL()), } } } @@ -128,5 +128,5 @@ func (invoker *zoneAwareClusterInvoker) AfterInvoker(ctx context.Context, invoca } func matchParam(target, key, def string, invoker protocol.Invoker) bool { - return target == invoker.GetUrl().GetParam(key, def) + return target == invoker.GetURL().GetParam(key, def) } diff --git a/cluster/directory/base_directory.go b/cluster/directory/base_directory.go index 3a6a337db0..22d25686ce 100644 --- a/cluster/directory/base_directory.go +++ b/cluster/directory/base_directory.go @@ -62,8 +62,8 @@ func (dir *BaseDirectory) SetRouterChain(routerChain router.Chain) { dir.routerChain = routerChain } -// GetUrl Get URL -func (dir *BaseDirectory) GetUrl() *common.URL { +// GetURL Get URL +func (dir *BaseDirectory) GetURL() *common.URL { return dir.url } @@ -74,13 +74,13 @@ func (dir *BaseDirectory) GetDirectoryUrl() *common.URL { func (dir *BaseDirectory) isProperRouter(url *common.URL) bool { app := url.GetParam(constant.APPLICATION_KEY, "") - dirApp := dir.GetUrl().GetParam(constant.APPLICATION_KEY, "") - if len(dirApp) == 0 && dir.GetUrl().SubURL != nil { - dirApp = dir.GetUrl().SubURL.GetParam(constant.APPLICATION_KEY, "") + dirApp := dir.GetURL().GetParam(constant.APPLICATION_KEY, "") + if len(dirApp) == 0 && dir.GetURL().SubURL != nil { + dirApp = dir.GetURL().SubURL.GetParam(constant.APPLICATION_KEY, "") } - serviceKey := dir.GetUrl().ServiceKey() + serviceKey := dir.GetURL().ServiceKey() if len(serviceKey) == 0 { - serviceKey = dir.GetUrl().SubURL.ServiceKey() + serviceKey = dir.GetURL().SubURL.ServiceKey() } if len(app) > 0 && app == dirApp { return true diff --git a/cluster/directory/base_directory_test.go b/cluster/directory/base_directory_test.go index 256afb63dc..2cc27dc650 100644 --- a/cluster/directory/base_directory_test.go +++ b/cluster/directory/base_directory_test.go @@ -41,7 +41,7 @@ var ( func TestNewBaseDirectory(t *testing.T) { dir := NewBaseDirectory(url) - assert.Equal(t, url, dir.GetUrl()) + assert.Equal(t, url, dir.GetURL()) assert.Equal(t, url, dir.GetDirectoryUrl()) } diff --git a/cluster/directory/static_directory.go b/cluster/directory/static_directory.go index e184dc6af9..0b38ba2a10 100644 --- a/cluster/directory/static_directory.go +++ b/cluster/directory/static_directory.go @@ -37,7 +37,7 @@ func NewStaticDirectory(invokers []protocol.Invoker) *staticDirectory { var url *common.URL if len(invokers) > 0 { - url = invokers[0].GetUrl() + url = invokers[0].GetURL() } dir := &staticDirectory{ BaseDirectory: NewBaseDirectory(url), @@ -71,7 +71,7 @@ func (dir *staticDirectory) List(invocation protocol.Invocation) []protocol.Invo if routerChain == nil { return invokers } - dirUrl := dir.GetUrl() + dirUrl := dir.GetURL() return routerChain.Route(dirUrl, invocation) } @@ -90,7 +90,7 @@ func (dir *staticDirectory) BuildRouterChain(invokers []protocol.Invoker) error if len(invokers) == 0 { return perrors.Errorf("invokers == null") } - url := invokers[0].GetUrl() + url := invokers[0].GetURL() routerChain, e := chain.NewRouterChain(url) if e != nil { return e diff --git a/cluster/loadbalance/consistent_hash.go b/cluster/loadbalance/consistent_hash.go index 314728a0a1..681c618f6b 100644 --- a/cluster/loadbalance/consistent_hash.go +++ b/cluster/loadbalance/consistent_hash.go @@ -70,7 +70,7 @@ func NewConsistentHashLoadBalance() cluster.LoadBalance { // Select gets invoker based on load balancing strategy func (lb *ConsistentHashLoadBalance) Select(invokers []protocol.Invoker, invocation protocol.Invocation) protocol.Invoker { methodName := invocation.MethodName() - key := invokers[0].GetUrl().ServiceKey() + "." + methodName + key := invokers[0].GetURL().ServiceKey() + "." + methodName // hash the invokers bs := make([]byte, 0) @@ -105,7 +105,7 @@ func newConsistentHashSelector(invokers []protocol.Invoker, methodName string, selector := &ConsistentHashSelector{} selector.virtualInvokers = make(map[uint32]protocol.Invoker) selector.hashCode = hashCode - url := invokers[0].GetUrl() + url := invokers[0].GetURL() selector.replicaNum = url.GetMethodParamIntValue(methodName, HashNodes, 160) indices := re.Split(url.GetMethodParam(methodName, HashArguments, "0"), -1) for _, index := range indices { @@ -116,7 +116,7 @@ func newConsistentHashSelector(invokers []protocol.Invoker, methodName string, selector.argumentIndex = append(selector.argumentIndex, i) } for _, invoker := range invokers { - u := invoker.GetUrl() + u := invoker.GetURL() address := u.Ip + ":" + u.Port for i := 0; i < selector.replicaNum/4; i++ { digest := md5.Sum([]byte(address + strconv.Itoa(i))) diff --git a/cluster/loadbalance/consistent_hash_test.go b/cluster/loadbalance/consistent_hash_test.go index 0fbb74059c..b6ff69ee68 100644 --- a/cluster/loadbalance/consistent_hash_test.go +++ b/cluster/loadbalance/consistent_hash_test.go @@ -75,7 +75,7 @@ func (s *consistentHashSelectorSuite) TestSelectForKey() { s.selector.virtualInvokers[9999945] = protocol.NewBaseInvoker(url2) s.selector.keys = []uint32{99874, 9999945} result := s.selector.selectForKey(9999944) - s.Equal(result.GetUrl().String(), url8081Short+"?") + s.Equal(result.GetURL().String(), url8081Short+"?") } func TestConsistentHashLoadBalanceSuite(t *testing.T) { @@ -114,9 +114,9 @@ func (s *consistentHashLoadBalanceSuite) SetupTest() { func (s *consistentHashLoadBalanceSuite) TestSelect() { args := []interface{}{"name", "password", "age"} invoker := s.lb.Select(s.invokers, invocation.NewRPCInvocation("echo", args, nil)) - s.Equal(invoker.GetUrl().Location, fmt.Sprintf("%s:%d", ip, port8080)) + s.Equal(invoker.GetURL().Location, fmt.Sprintf("%s:%d", ip, port8080)) args = []interface{}{"ok", "abc"} invoker = s.lb.Select(s.invokers, invocation.NewRPCInvocation("echo", args, nil)) - s.Equal(invoker.GetUrl().Location, fmt.Sprintf("%s:%d", ip, port8082)) + s.Equal(invoker.GetURL().Location, fmt.Sprintf("%s:%d", ip, port8082)) } diff --git a/cluster/loadbalance/least_active.go b/cluster/loadbalance/least_active.go index f8fc015707..47ad7dde46 100644 --- a/cluster/loadbalance/least_active.go +++ b/cluster/loadbalance/least_active.go @@ -67,7 +67,7 @@ func (lb *leastActiveLoadBalance) Select(invokers []protocol.Invoker, invocation for i := 0; i < count; i++ { invoker := invokers[i] // Active number - active := protocol.GetMethodStatus(invoker.GetUrl(), invocation.MethodName()).GetActive() + active := protocol.GetMethodStatus(invoker.GetURL(), invocation.MethodName()).GetActive() // current weight (maybe in warmUp) weight := GetWeight(invoker, invocation) // There are smaller active services diff --git a/cluster/loadbalance/least_active_test.go b/cluster/loadbalance/least_active_test.go index 34be17a4f3..56e32fd7c1 100644 --- a/cluster/loadbalance/least_active_test.go +++ b/cluster/loadbalance/least_active_test.go @@ -41,7 +41,7 @@ func TestLeastActiveSelect(t *testing.T) { url, _ := common.NewURL(fmt.Sprintf("dubbo://%s:%d/org.apache.demo.HelloService", constant.LOCAL_HOST_VALUE, constant.DEFAULT_PORT)) invokers = append(invokers, protocol.NewBaseInvoker(url)) i := loadBalance.Select(invokers, &invocation.RPCInvocation{}) - assert.True(t, i.GetUrl().URLEqual(url)) + assert.True(t, i.GetURL().URLEqual(url)) for i := 1; i < 10; i++ { url, _ := common.NewURL(fmt.Sprintf("dubbo://192.168.1.%v:20000/org.apache.demo.HelloService", i)) @@ -61,7 +61,7 @@ func TestLeastActiveByWeight(t *testing.T) { } inv := invocation.NewRPCInvocationWithOptions(invocation.WithMethodName("test")) - protocol.BeginCount(invokers[2].GetUrl(), inv.MethodName()) + protocol.BeginCount(invokers[2].GetURL(), inv.MethodName()) loop = 10000 @@ -72,9 +72,9 @@ func TestLeastActiveByWeight(t *testing.T) { for i := 1; i <= loop; i++ { invoker := loadBalance.Select(invokers, inv) - if invoker.GetUrl().Protocol == "test1" { + if invoker.GetURL().Protocol == "test1" { firstCount++ - } else if invoker.GetUrl().Protocol == "test2" { + } else if invoker.GetURL().Protocol == "test2" { secondCount++ } } diff --git a/cluster/loadbalance/random_test.go b/cluster/loadbalance/random_test.go index c24fdf0556..5c2b7587bb 100644 --- a/cluster/loadbalance/random_test.go +++ b/cluster/loadbalance/random_test.go @@ -50,7 +50,7 @@ func TestRandomlbSelect(t *testing.T) { url, _ := common.NewURL(fmt.Sprintf(tmpUrlFormat, 0)) invokers = append(invokers, protocol.NewBaseInvoker(url)) i := randomlb.Select(invokers, &invocation.RPCInvocation{}) - assert.True(t, i.GetUrl().URLEqual(url)) + assert.True(t, i.GetURL().URLEqual(url)) for i := 1; i < 10; i++ { url, _ := common.NewURL(fmt.Sprintf(tmpUrlFormat, i)) @@ -78,7 +78,7 @@ func TestRandomlbSelectWeight(t *testing.T) { var selected float64 for i := 0; i < 10000; i++ { s := randomlb.Select(invokers, ivc) - if s.GetUrl().Ip == tmpIp { + if s.GetURL().Ip == tmpIp { selected++ } selectedInvoker = append(selectedInvoker, s) @@ -110,7 +110,7 @@ func TestRandomlbSelectWarmup(t *testing.T) { var selected float64 for i := 0; i < 10000; i++ { s := randomlb.Select(invokers, ivc) - if s.GetUrl().Ip == tmpIp { + if s.GetURL().Ip == tmpIp { selected++ } selectedInvoker = append(selectedInvoker, s) diff --git a/cluster/loadbalance/round_robin.go b/cluster/loadbalance/round_robin.go index f7653b619d..f1f0f63372 100644 --- a/cluster/loadbalance/round_robin.go +++ b/cluster/loadbalance/round_robin.go @@ -69,7 +69,7 @@ func (lb *roundRobinLoadBalance) Select(invokers []protocol.Invoker, invocation return invokers[0] } - key := invokers[0].GetUrl().Path + "." + invocation.MethodName() + key := invokers[0].GetURL().Path + "." + invocation.MethodName() cache, _ := methodWeightMap.LoadOrStore(key, &cachedInvokers{}) cachedInvokers := cache.(*cachedInvokers) @@ -88,7 +88,7 @@ func (lb *roundRobinLoadBalance) Select(invokers []protocol.Invoker, invocation weight = 0 } - identifier := invoker.GetUrl().Key() + identifier := invoker.GetURL().Key() loaded, found := cachedInvokers.LoadOrStore(identifier, &weightedRoundRobin{weight: weight}) weightRobin := loaded.(*weightedRoundRobin) if !found { diff --git a/cluster/loadbalance/round_robin_test.go b/cluster/loadbalance/round_robin_test.go index 5354bae458..921259d7d9 100644 --- a/cluster/loadbalance/round_robin_test.go +++ b/cluster/loadbalance/round_robin_test.go @@ -43,7 +43,7 @@ func TestRoundRobinSelect(t *testing.T) { constant.LOCAL_HOST_VALUE, constant.DEFAULT_PORT)) invokers = append(invokers, protocol.NewBaseInvoker(url)) i := loadBalance.Select(invokers, &invocation.RPCInvocation{}) - assert.True(t, i.GetUrl().URLEqual(url)) + assert.True(t, i.GetURL().URLEqual(url)) for i := 1; i < 10; i++ { url, _ := common.NewURL(fmt.Sprintf("dubbo://192.168.1.%v:20000/org.apache.demo.HelloService", i)) @@ -71,7 +71,7 @@ func TestRoundRobinByWeight(t *testing.T) { } for _, i := range invokers { - w, _ := strconv.Atoi(i.GetUrl().GetParam("weight", "-1")) + w, _ := strconv.Atoi(i.GetURL().GetParam("weight", "-1")) assert.True(t, selected[i] == w) } } diff --git a/cluster/loadbalance/util.go b/cluster/loadbalance/util.go index 2dd55d3934..887e2bcc2e 100644 --- a/cluster/loadbalance/util.go +++ b/cluster/loadbalance/util.go @@ -29,7 +29,7 @@ import ( // GetWeight gets weight for load balance strategy func GetWeight(invoker protocol.Invoker, invocation protocol.Invocation) int64 { var weight int64 - url := invoker.GetUrl() + url := invoker.GetURL() // Multiple registry scenario, load balance among multiple registries. isRegIvk := url.GetParamBool(constant.REGISTRY_KEY+"."+constant.REGISTRY_LABEL_KEY, false) if isRegIvk { diff --git a/cluster/router/chain/chain.go b/cluster/router/chain/chain.go index 0216c9a2a9..5e61cb66ef 100644 --- a/cluster/router/chain/chain.go +++ b/cluster/router/chain/chain.go @@ -185,9 +185,9 @@ func isInvokersChanged(left []protocol.Invoker, right []protocol.Invoker) bool { for _, r := range right { found := false - rurl := r.GetUrl() + rurl := r.GetURL() for _, l := range left { - lurl := l.GetUrl() + lurl := l.GetURL() if common.GetCompareURLEqualFunc()(lurl, rurl, constant.TIMESTAMP_KEY, constant.REMOTE_TIMESTAMP_KEY) { found = true break diff --git a/common/node.go b/common/node.go index b9c1f39bf9..aa18b61276 100644 --- a/common/node.go +++ b/common/node.go @@ -19,7 +19,7 @@ package common // Node use for process dubbo node type Node interface { - GetUrl() *URL + GetURL() *URL IsAvailable() bool Destroy() } diff --git a/common/proxy/proxy_factory/default.go b/common/proxy/proxy_factory/default.go index 4ef828f0ee..2277af122f 100644 --- a/common/proxy/proxy_factory/default.go +++ b/common/proxy/proxy_factory/default.go @@ -88,7 +88,7 @@ func (pi *ProxyInvoker) Invoke(ctx context.Context, invocation protocol.Invocati result.SetAttachments(invocation.Attachments()) // get providerUrl. The origin url may be is registry URL. - url := getProviderURL(pi.GetUrl()) + url := getProviderURL(pi.GetURL()) methodName := invocation.MethodName() proto := url.Protocol diff --git a/common/proxy/proxy_factory/pass_through.go b/common/proxy/proxy_factory/pass_through.go index 02fb265a05..9bdcddb0e9 100644 --- a/common/proxy/proxy_factory/pass_through.go +++ b/common/proxy/proxy_factory/pass_through.go @@ -80,7 +80,7 @@ type PassThroughProxyInvoker struct { func (pi *PassThroughProxyInvoker) Invoke(ctx context.Context, invocation protocol.Invocation) protocol.Result { result := &protocol.RPCResult{} result.SetAttachments(invocation.Attachments()) - url := getProviderURL(pi.GetUrl()) + url := getProviderURL(pi.GetURL()) arguments := invocation.Arguments() srv := common.ServiceMap.GetServiceByServiceKey(url.Protocol, url.ServiceKey()) diff --git a/config/config_loader_test.go b/config/config_loader_test.go index c43a4aef36..4a3de5aad2 100644 --- a/config/config_loader_test.go +++ b/config/config_loader_test.go @@ -475,7 +475,7 @@ func (m *mockMetadataService) getAllService(services *sync.Map) []*common.URL { type mockServiceDiscoveryRegistry struct{} -func (mr *mockServiceDiscoveryRegistry) GetUrl() *common.URL { +func (mr *mockServiceDiscoveryRegistry) GetURL() *common.URL { panic("implement me") } diff --git a/config/reference_config.go b/config/reference_config.go index 98396b3bd5..a2a163441a 100644 --- a/config/reference_config.go +++ b/config/reference_config.go @@ -152,7 +152,7 @@ func (c *ReferenceConfig) Refer(_ interface{}) { // not a registry url, must be direct invoke. hitClu = constant.FAILOVER_CLUSTER_NAME if len(invokers) > 0 { - u := invokers[0].GetUrl() + u := invokers[0].GetURL() if nil != &u { hitClu = u.GetParam(constant.CLUSTER_KEY, constant.ZONEAWARE_CLUSTER_NAME) } diff --git a/config/service_config.go b/config/service_config.go index e8523bdea7..d73190c48f 100644 --- a/config/service_config.go +++ b/config/service_config.go @@ -341,7 +341,7 @@ func (c *ServiceConfig) GetExportedUrls() []*common.URL { if c.exported.Load() { var urls []*common.URL for _, exporter := range c.exporters { - urls = append(urls, exporter.GetInvoker().GetUrl()) + urls = append(urls, exporter.GetInvoker().GetURL()) } return urls } diff --git a/config_center/nacos/client.go b/config_center/nacos/client.go index d6af806edd..b2e9e98a98 100644 --- a/config_center/nacos/client.go +++ b/config_center/nacos/client.go @@ -85,7 +85,7 @@ func ValidateNacosClient(container nacosClientFacade, opts ...option) error { opt(os) } - url := container.GetUrl() + url := container.GetURL() timeout, err := time.ParseDuration(url.GetParam(constant.REGISTRY_TIMEOUT_KEY, constant.DEFAULT_REG_TIMEOUT)) if err != nil { logger.Errorf("invalid timeout config %+v,got err %+v", diff --git a/config_center/zookeeper/impl.go b/config_center/zookeeper/impl.go index 082bfbecd3..d362310ad7 100644 --- a/config_center/zookeeper/impl.go +++ b/config_center/zookeeper/impl.go @@ -182,7 +182,7 @@ func (c *zookeeperDynamicConfiguration) Done() chan struct{} { return c.done } -func (c *zookeeperDynamicConfiguration) GetUrl() *common.URL { +func (c *zookeeperDynamicConfiguration) GetURL() *common.URL { return c.url } diff --git a/config_center/zookeeper/impl_test.go b/config_center/zookeeper/impl_test.go index 26d7870482..6c8734332f 100644 --- a/config_center/zookeeper/impl_test.go +++ b/config_center/zookeeper/impl_test.go @@ -55,7 +55,7 @@ func initZkData(group string, t *testing.T) (*zk.TestCluster, *zookeeperDynamicC assert.True(t, ok) assert.NoError(t, err) assert.True(t, zreg.IsAvailable()) - assert.Equal(t, zreg.GetUrl(), regurl) + assert.Equal(t, zreg.GetURL(), regurl) assert.True(t, zreg.RestartCallBack()) zreg.SetParser(&parser.DefaultConfigurationParser{}) diff --git a/config_center/zookeeper/listener_test.go b/config_center/zookeeper/listener_test.go index a8c0754938..07c717999a 100644 --- a/config_center/zookeeper/listener_test.go +++ b/config_center/zookeeper/listener_test.go @@ -47,7 +47,7 @@ func initZkDynamicConfiguration(t *testing.T) (*zk.TestCluster, *zookeeperDynami assert.True(t, ok) assert.NoError(t, err) assert.True(t, zreg.IsAvailable()) - assert.Equal(t, zreg.GetUrl(), regurl) + assert.Equal(t, zreg.GetURL(), regurl) assert.True(t, zreg.RestartCallBack()) zreg.SetParser(&parser.DefaultConfigurationParser{}) diff --git a/filter/filter_impl/access_log_filter.go b/filter/filter_impl/access_log_filter.go index 6aa4e65222..17ebdef8d8 100644 --- a/filter/filter_impl/access_log_filter.go +++ b/filter/filter_impl/access_log_filter.go @@ -80,7 +80,7 @@ type AccessLogFilter struct { // Invoke will check whether user wants to use this filter. // If we find the value of key constant.ACCESS_LOG_KEY, we will log the invocation info func (ef *AccessLogFilter) Invoke(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result { - accessLog := invoker.GetUrl().GetParam(constant.ACCESS_LOG_KEY, "") + accessLog := invoker.GetURL().GetParam(constant.ACCESS_LOG_KEY, "") // the user do not if len(accessLog) > 0 { diff --git a/filter/filter_impl/active_filter.go b/filter/filter_impl/active_filter.go index a391cb3ee3..7b65d0c854 100644 --- a/filter/filter_impl/active_filter.go +++ b/filter/filter_impl/active_filter.go @@ -46,7 +46,7 @@ type ActiveFilter struct{} func (ef *ActiveFilter) Invoke(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result { logger.Infof("invoking active filter. %v,%v", invocation.MethodName(), len(invocation.Arguments())) invocation.(*invocation2.RPCInvocation).SetAttachments(dubboInvokeStartTime, strconv.FormatInt(protocol.CurrentTimeMillis(), 10)) - protocol.BeginCount(invoker.GetUrl(), invocation.MethodName()) + protocol.BeginCount(invoker.GetURL(), invocation.MethodName()) return invoker.Invoke(ctx, invocation) } @@ -59,7 +59,7 @@ func (ef *ActiveFilter) OnResponse(ctx context.Context, result protocol.Result, return result } elapsed := protocol.CurrentTimeMillis() - startTime - protocol.EndCount(invoker.GetUrl(), invocation.MethodName(), elapsed, result.Error() == nil) + protocol.EndCount(invoker.GetURL(), invocation.MethodName(), elapsed, result.Error() == nil) return result } diff --git a/filter/filter_impl/auth/consumer_sign.go b/filter/filter_impl/auth/consumer_sign.go index 3e298cdc3d..70df2d87ff 100644 --- a/filter/filter_impl/auth/consumer_sign.go +++ b/filter/filter_impl/auth/consumer_sign.go @@ -40,7 +40,7 @@ func init() { // Invoke retrieves the configured Authenticator to add signature to invocation func (csf *ConsumerSignFilter) Invoke(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result { logger.Infof("invoking ConsumerSign filter.") - url := invoker.GetUrl() + url := invoker.GetURL() err := doAuthWork(url, func(authenticator filter.Authenticator) error { return authenticator.Sign(invocation, url) diff --git a/filter/filter_impl/auth/provider_auth.go b/filter/filter_impl/auth/provider_auth.go index 9a6490db0e..2f3f1d9ce1 100644 --- a/filter/filter_impl/auth/provider_auth.go +++ b/filter/filter_impl/auth/provider_auth.go @@ -39,7 +39,7 @@ func init() { // Invoke retrieves the configured Authenticator to verify the signature in an invocation func (paf *ProviderAuthFilter) Invoke(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result { logger.Infof("invoking providerAuth filter.") - url := invoker.GetUrl() + url := invoker.GetURL() err := doAuthWork(url, func(authenticator filter.Authenticator) error { return authenticator.Authenticate(invocation, url) diff --git a/filter/filter_impl/execute_limit_filter.go b/filter/filter_impl/execute_limit_filter.go index fdd472c485..ff12c0310c 100644 --- a/filter/filter_impl/execute_limit_filter.go +++ b/filter/filter_impl/execute_limit_filter.go @@ -82,7 +82,7 @@ type ExecuteState struct { // Invoke judges whether the current processing requests over the threshold func (ef *ExecuteLimitFilter) Invoke(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result { methodConfigPrefix := "methods." + invocation.MethodName() + "." - ivkURL := invoker.GetUrl() + ivkURL := invoker.GetURL() limitTarget := ivkURL.ServiceKey() var limitRateConfig string diff --git a/filter/filter_impl/generic_service_filter.go b/filter/filter_impl/generic_service_filter.go index 89b009b8d1..e843f2e220 100644 --- a/filter/filter_impl/generic_service_filter.go +++ b/filter/filter_impl/generic_service_filter.go @@ -71,7 +71,7 @@ func (ef *GenericServiceFilter) Invoke(ctx context.Context, invoker protocol.Inv oldParams []hessian.Object ) - url := invoker.GetUrl() + url := invoker.GetURL() methodName = invocation.Arguments()[0].(string) // get service svc := common.ServiceMap.GetServiceByServiceKey(url.Protocol, url.ServiceKey()) diff --git a/filter/filter_impl/graceful_shutdown_filter.go b/filter/filter_impl/graceful_shutdown_filter.go index f79123c8f2..727d1638c1 100644 --- a/filter/filter_impl/graceful_shutdown_filter.go +++ b/filter/filter_impl/graceful_shutdown_filter.go @@ -57,7 +57,7 @@ type gracefulShutdownFilter struct { func (gf *gracefulShutdownFilter) Invoke(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result { if gf.rejectNewRequest() { logger.Info("The application is closing, new request will be rejected.") - return gf.getRejectHandler().RejectedExecution(invoker.GetUrl(), invocation) + return gf.getRejectHandler().RejectedExecution(invoker.GetURL(), invocation) } atomic.AddInt32(&gf.activeCount, 1) return invoker.Invoke(ctx, invocation) diff --git a/filter/filter_impl/hystrix_filter.go b/filter/filter_impl/hystrix_filter.go index 3a7c0c4829..e79fe2949a 100644 --- a/filter/filter_impl/hystrix_filter.go +++ b/filter/filter_impl/hystrix_filter.go @@ -132,12 +132,12 @@ type HystrixFilter struct { // Invoke is an implementation of filter, provides Hystrix pattern latency and fault tolerance func (hf *HystrixFilter) Invoke(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result { - cmdName := fmt.Sprintf("%s&method=%s", invoker.GetUrl().Key(), invocation.MethodName()) + cmdName := fmt.Sprintf("%s&method=%s", invoker.GetURL().Key(), invocation.MethodName()) // Do the configuration if the circuit breaker is created for the first time if _, load := hf.ifNewMap.LoadOrStore(cmdName, true); !load { configLoadMutex.Lock() - filterConf := getConfig(invoker.GetUrl().Service(), invocation.MethodName(), hf.COrP) + filterConf := getConfig(invoker.GetURL().Service(), invocation.MethodName(), hf.COrP) for _, ptn := range filterConf.Error { reg, err := regexp.Compile(ptn) if err != nil { diff --git a/filter/filter_impl/sentinel_filter.go b/filter/filter_impl/sentinel_filter.go index cbe1c38741..a82a286909 100644 --- a/filter/filter_impl/sentinel_filter.go +++ b/filter/filter_impl/sentinel_filter.go @@ -216,9 +216,9 @@ func getResourceName(invoker protocol.Invoker, invocation protocol.Invocation, p sb.WriteString(prefix) if getInterfaceGroupAndVersionEnabled() { - interfaceResourceName = getColonSeparatedKey(invoker.GetUrl()) + interfaceResourceName = getColonSeparatedKey(invoker.GetURL()) } else { - interfaceResourceName = invoker.GetUrl().Service() + interfaceResourceName = invoker.GetURL().Service() } sb.WriteString(interfaceResourceName) sb.WriteString(":") diff --git a/filter/filter_impl/token_filter.go b/filter/filter_impl/token_filter.go index b5e05605c2..cc026b7f94 100644 --- a/filter/filter_impl/token_filter.go +++ b/filter/filter_impl/token_filter.go @@ -47,7 +47,7 @@ type TokenFilter struct{} // Invoke verifies the incoming token with the service configured token func (tf *TokenFilter) Invoke(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result { - invokerTkn := invoker.GetUrl().GetParam(constant.TOKEN_KEY, "") + invokerTkn := invoker.GetURL().GetParam(constant.TOKEN_KEY, "") if len(invokerTkn) > 0 { attachs := invocation.Attachments() remoteTkn, exist := attachs[constant.TOKEN_KEY] diff --git a/filter/filter_impl/tps_limit_filter.go b/filter/filter_impl/tps_limit_filter.go index 210e1579bb..6bbf8b11bb 100644 --- a/filter/filter_impl/tps_limit_filter.go +++ b/filter/filter_impl/tps_limit_filter.go @@ -58,11 +58,11 @@ type TpsLimitFilter struct{} // Invoke gets the configured limter to impose TPS limiting func (t TpsLimitFilter) Invoke(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result { - url := invoker.GetUrl() + url := invoker.GetURL() tpsLimiter := url.GetParam(constant.TPS_LIMITER_KEY, "") rejectedExeHandler := url.GetParam(constant.TPS_REJECTED_EXECUTION_HANDLER_KEY, constant.DEFAULT_KEY) if len(tpsLimiter) > 0 { - allow := extension.GetTpsLimiter(tpsLimiter).IsAllowable(invoker.GetUrl(), invocation) + allow := extension.GetTpsLimiter(tpsLimiter).IsAllowable(invoker.GetURL(), invocation) if allow { return invoker.Invoke(ctx, invocation) } diff --git a/filter/filter_impl/tracing_filter.go b/filter/filter_impl/tracing_filter.go index 8a30c965da..cc1a13f201 100644 --- a/filter/filter_impl/tracing_filter.go +++ b/filter/filter_impl/tracing_filter.go @@ -57,7 +57,7 @@ func (tf *tracingFilter) Invoke(ctx context.Context, invoker protocol.Invoker, i spanCtx context.Context span opentracing.Span ) - operationName := invoker.GetUrl().ServiceKey() + "#" + invocation.MethodName() + operationName := invoker.GetURL().ServiceKey() + "#" + invocation.MethodName() wiredCtx := ctx.Value(constant.TRACING_REMOTE_SPAN_CTX) preSpan := opentracing.SpanFromContext(ctx) diff --git a/metadata/service/inmemory/metadata_service_proxy_factory_test.go b/metadata/service/inmemory/metadata_service_proxy_factory_test.go index 75c6677884..011903f833 100644 --- a/metadata/service/inmemory/metadata_service_proxy_factory_test.go +++ b/metadata/service/inmemory/metadata_service_proxy_factory_test.go @@ -79,7 +79,7 @@ func (m mockProtocol) Destroy() { type mockInvoker struct{} -func (m *mockInvoker) GetUrl() *common.URL { +func (m *mockInvoker) GetURL() *common.URL { panic("implement me") } diff --git a/metadata/service/remote/service_proxy_test.go b/metadata/service/remote/service_proxy_test.go index 39cc46a6bc..546ee05352 100644 --- a/metadata/service/remote/service_proxy_test.go +++ b/metadata/service/remote/service_proxy_test.go @@ -110,34 +110,34 @@ func (m *mockMetadataReportFactory) CreateMetadataReport(*common.URL) report.Met type mockMetadataReport struct{} -func (m mockMetadataReport) StoreProviderMetadata(*identifier.MetadataIDentifier, string) error { +func (m mockMetadataReport) StoreProviderMetadata(*identifier.MetadataIdentifier, string) error { panic("implement me") } -func (m mockMetadataReport) StoreConsumerMetadata(*identifier.MetadataIDentifier, string) error { +func (m mockMetadataReport) StoreConsumerMetadata(*identifier.MetadataIdentifier, string) error { panic("implement me") } -func (m mockMetadataReport) SaveServiceMetadata(*identifier.ServiceMetadataIDentifier, *common.URL) error { +func (m mockMetadataReport) SaveServiceMetadata(*identifier.ServiceMetadataIdentifier, *common.URL) error { return nil } -func (m mockMetadataReport) RemoveServiceMetadata(*identifier.ServiceMetadataIDentifier) error { +func (m mockMetadataReport) RemoveServiceMetadata(*identifier.ServiceMetadataIdentifier) error { panic("implement me") } -func (m mockMetadataReport) GetExportedURLs(*identifier.ServiceMetadataIDentifier) ([]string, error) { +func (m mockMetadataReport) GetExportedURLs(*identifier.ServiceMetadataIdentifier) ([]string, error) { return []string{"mock://localhost1", "mock://localhost2"}, nil } -func (m mockMetadataReport) SaveSubscribedData(*identifier.SubscriberMetadataIDentifier, string) error { +func (m mockMetadataReport) SaveSubscribedData(*identifier.SubscriberMetadataIdentifier, string) error { return nil } -func (m mockMetadataReport) GetSubscribedURLs(*identifier.SubscriberMetadataIDentifier) ([]string, error) { +func (m mockMetadataReport) GetSubscribedURLs(*identifier.SubscriberMetadataIdentifier) ([]string, error) { panic("implement me") } -func (m mockMetadataReport) GetServiceDefinition(*identifier.MetadataIDentifier) (string, error) { +func (m mockMetadataReport) GetServiceDefinition(*identifier.MetadataIdentifier) (string, error) { return "definition", nil } diff --git a/metrics/prometheus/reporter.go b/metrics/prometheus/reporter.go index 266c8206c5..c50589e03f 100644 --- a/metrics/prometheus/reporter.go +++ b/metrics/prometheus/reporter.go @@ -86,7 +86,7 @@ type PrometheusReporter struct { // the role in url must be consumer or provider // or it will be ignored func (reporter *PrometheusReporter) Report(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation, cost time.Duration, res protocol.Result) { - url := invoker.GetUrl() + url := invoker.GetURL() var sumVec *prometheus.SummaryVec var hisVec *prometheus.HistogramVec if isProvider(url) { diff --git a/protocol/dubbo/dubbo_exporter.go b/protocol/dubbo/dubbo_exporter.go index 1873a63fe1..34dc07d237 100644 --- a/protocol/dubbo/dubbo_exporter.go +++ b/protocol/dubbo/dubbo_exporter.go @@ -42,9 +42,9 @@ func NewDubboExporter(key string, invoker protocol.Invoker, exporterMap *sync.Ma // Unexport unexport dubbo service exporter. func (de *DubboExporter) Unexport() { - interfaceName := de.GetInvoker().GetUrl().GetParam(constant.INTERFACE_KEY, "") + interfaceName := de.GetInvoker().GetURL().GetParam(constant.INTERFACE_KEY, "") de.BaseExporter.Unexport() - err := common.ServiceMap.UnRegister(interfaceName, DUBBO, de.GetInvoker().GetUrl().ServiceKey()) + err := common.ServiceMap.UnRegister(interfaceName, DUBBO, de.GetInvoker().GetURL().ServiceKey()) if err != nil { logger.Errorf("[DubboExporter.Unexport] error: %v", err) } diff --git a/protocol/dubbo/dubbo_invoker.go b/protocol/dubbo/dubbo_invoker.go index 12bab314b5..40f8423d3f 100644 --- a/protocol/dubbo/dubbo_invoker.go +++ b/protocol/dubbo/dubbo_invoker.go @@ -120,9 +120,9 @@ func (di *DubboInvoker) Invoke(ctx context.Context, invocation protocol.Invocati inv := invocation.(*invocation_impl.RPCInvocation) // init param - inv.SetAttachments(constant.PATH_KEY, di.GetUrl().GetParam(constant.INTERFACE_KEY, "")) + inv.SetAttachments(constant.PATH_KEY, di.GetURL().GetParam(constant.INTERFACE_KEY, "")) for _, k := range attachmentKey { - if v := di.GetUrl().GetParam(k, ""); len(v) > 0 { + if v := di.GetURL().GetParam(k, ""); len(v) > 0 { inv.SetAttachments(k, v) } } @@ -130,7 +130,7 @@ func (di *DubboInvoker) Invoke(ctx context.Context, invocation protocol.Invocati // put the ctx into attachment di.appendCtx(ctx, inv) - url := di.GetUrl() + url := di.GetURL() // default hessian2 serialization, compatible if url.GetParam(constant.SERIALIZATION_KEY, "") == "" { url.SetParam(constant.SERIALIZATION_KEY, constant.HESSIAN2_SERIALIZATION) @@ -168,7 +168,7 @@ func (di *DubboInvoker) Invoke(ctx context.Context, invocation protocol.Invocati // get timeout including methodConfig func (di *DubboInvoker) getTimeout(invocation *invocation_impl.RPCInvocation) time.Duration { - timeout := di.GetUrl().GetParam(strings.Join([]string{constant.METHOD_KEYS, invocation.MethodName(), constant.TIMEOUT_KEY}, "."), "") + timeout := di.GetURL().GetParam(strings.Join([]string{constant.METHOD_KEYS, invocation.MethodName(), constant.TIMEOUT_KEY}, "."), "") if len(timeout) != 0 { if t, err := time.ParseDuration(timeout); err == nil { // config timeout into attachment @@ -199,7 +199,7 @@ func (di *DubboInvoker) Destroy() { activeNumber := client.DecreaseActiveNumber() di.setClient(nil) if activeNumber == 0 { - exchangeClientMap.Delete(di.GetUrl().Location) + exchangeClientMap.Delete(di.GetURL().Location) client.Close() } } diff --git a/protocol/dubbo/dubbo_protocol.go b/protocol/dubbo/dubbo_protocol.go index ce0ce47825..3e92918c9b 100644 --- a/protocol/dubbo/dubbo_protocol.go +++ b/protocol/dubbo/dubbo_protocol.go @@ -77,7 +77,7 @@ func NewDubboProtocol() *DubboProtocol { // Export export dubbo service. func (dp *DubboProtocol) Export(invoker protocol.Invoker) protocol.Exporter { - url := invoker.GetUrl() + url := invoker.GetURL() serviceKey := url.ServiceKey() exporter := NewDubboExporter(serviceKey, invoker, dp.ExporterMap()) dp.SetExporterMap(serviceKey, exporter) diff --git a/protocol/dubbo/dubbo_protocol_test.go b/protocol/dubbo/dubbo_protocol_test.go index f564c6da7a..005418b9f8 100644 --- a/protocol/dubbo/dubbo_protocol_test.go +++ b/protocol/dubbo/dubbo_protocol_test.go @@ -93,7 +93,7 @@ func TestDubboProtocol_Export(t *testing.T) { assert.NoError(t, err) exporter := proto.Export(protocol.NewBaseInvoker(url)) // make sure url - eq := exporter.GetInvoker().GetUrl().URLEqual(url) + eq := exporter.GetInvoker().GetURL().URLEqual(url) assert.True(t, eq) // second service: the same path and the different version @@ -101,7 +101,7 @@ func TestDubboProtocol_Export(t *testing.T) { assert.NoError(t, err) exporter2 := proto.Export(protocol.NewBaseInvoker(url2)) // make sure url - eq2 := exporter2.GetInvoker().GetUrl().URLEqual(url2) + eq2 := exporter2.GetInvoker().GetURL().URLEqual(url2) assert.True(t, eq2) // make sure exporterMap after 'Unexport' @@ -143,7 +143,7 @@ func TestDubboProtocol_Refer(t *testing.T) { assert.NoError(t, err) invoker := proto.Refer(url) // make sure url - eq := invoker.GetUrl().URLEqual(url) + eq := invoker.GetURL().URLEqual(url) assert.True(t, eq) // make sure invokers after 'Destroy' diff --git a/protocol/dubbo3/dubbo3_exporter.go b/protocol/dubbo3/dubbo3_exporter.go index 37dda5c305..e9de94c50a 100644 --- a/protocol/dubbo3/dubbo3_exporter.go +++ b/protocol/dubbo3/dubbo3_exporter.go @@ -49,7 +49,7 @@ func NewDubboExporter(key string, invoker protocol.Invoker, exporterMap *sync.Ma // Unexport unexport dubbo3 service exporter. func (de *DubboExporter) Unexport() { - url := de.GetInvoker().GetUrl() + url := de.GetInvoker().GetURL() serviceId := url.GetParam(constant.BEAN_NAME_KEY, "") interfaceName := url.GetParam(constant.INTERFACE_KEY, "") de.BaseExporter.Unexport() diff --git a/protocol/dubbo3/dubbo3_invoker.go b/protocol/dubbo3/dubbo3_invoker.go index 2dd9ffa50d..149202987f 100644 --- a/protocol/dubbo3/dubbo3_invoker.go +++ b/protocol/dubbo3/dubbo3_invoker.go @@ -142,7 +142,7 @@ func (di *DubboInvoker) Invoke(ctx context.Context, invocation protocol.Invocati } // append interface id to ctx - ctx = context.WithValue(ctx, constant.DubboCtxKey(constant.INTERFACE_KEY), di.BaseInvoker.GetUrl().GetParam(constant.INTERFACE_KEY, "")) + ctx = context.WithValue(ctx, constant.DubboCtxKey(constant.INTERFACE_KEY), di.BaseInvoker.GetURL().GetParam(constant.INTERFACE_KEY, "")) in := make([]reflect.Value, 0, 16) in = append(in, reflect.ValueOf(ctx)) @@ -167,7 +167,7 @@ func (di *DubboInvoker) Invoke(ctx context.Context, invocation protocol.Invocati // get timeout including methodConfig func (di *DubboInvoker) getTimeout(invocation *invocation_impl.RPCInvocation) time.Duration { - timeout := di.GetUrl().GetParam(strings.Join([]string{constant.METHOD_KEYS, invocation.MethodName(), constant.TIMEOUT_KEY}, "."), "") + timeout := di.GetURL().GetParam(strings.Join([]string{constant.METHOD_KEYS, invocation.MethodName(), constant.TIMEOUT_KEY}, "."), "") if len(timeout) != 0 { if t, err := time.ParseDuration(timeout); err == nil { // config timeout into attachment diff --git a/protocol/dubbo3/dubbo3_protocol.go b/protocol/dubbo3/dubbo3_protocol.go index 5a19772856..d977f45d99 100644 --- a/protocol/dubbo3/dubbo3_protocol.go +++ b/protocol/dubbo3/dubbo3_protocol.go @@ -68,7 +68,7 @@ func NewDubboProtocol() *DubboProtocol { // Export export dubbo3 service. func (dp *DubboProtocol) Export(invoker protocol.Invoker) protocol.Exporter { - url := invoker.GetUrl() + url := invoker.GetURL() serviceKey := url.ServiceKey() exporter := NewDubboExporter(serviceKey, invoker, dp.ExporterMap(), dp.serviceMap) dp.SetExporterMap(serviceKey, exporter) diff --git a/protocol/dubbo3/dubbo3_protocol_test.go b/protocol/dubbo3/dubbo3_protocol_test.go index 486565f8a9..61fbebcec3 100644 --- a/protocol/dubbo3/dubbo3_protocol_test.go +++ b/protocol/dubbo3/dubbo3_protocol_test.go @@ -50,7 +50,7 @@ func TestDubboProtocolExport(t *testing.T) { time.Sleep(time.Second) // make sure url - eq := exporter.GetInvoker().GetUrl().URLEqual(url) + eq := exporter.GetInvoker().GetURL().URLEqual(url) assert.True(t, eq) // make sure exporterMap after 'Unexport' @@ -75,7 +75,7 @@ func TestDubboProtocolRefer(t *testing.T) { invoker := proto.Refer(url) // make sure url - eq := invoker.GetUrl().URLEqual(url) + eq := invoker.GetURL().URLEqual(url) assert.True(t, eq) // make sure invokers after 'Destroy' diff --git a/protocol/grpc/grpc_exporter.go b/protocol/grpc/grpc_exporter.go index 5beb4fedb1..76da1fb13f 100644 --- a/protocol/grpc/grpc_exporter.go +++ b/protocol/grpc/grpc_exporter.go @@ -42,9 +42,9 @@ func NewGrpcExporter(key string, invoker protocol.Invoker, exporterMap *sync.Map // Unexport and unregister gRPC service from registry and memory. func (gg *GrpcExporter) Unexport() { - interfaceName := gg.GetInvoker().GetUrl().GetParam(constant.INTERFACE_KEY, "") + interfaceName := gg.GetInvoker().GetURL().GetParam(constant.INTERFACE_KEY, "") gg.BaseExporter.Unexport() - err := common.ServiceMap.UnRegister(interfaceName, GRPC, gg.GetInvoker().GetUrl().ServiceKey()) + err := common.ServiceMap.UnRegister(interfaceName, GRPC, gg.GetInvoker().GetURL().ServiceKey()) if err != nil { logger.Errorf("[GrpcExporter.Unexport] error: %v", err) } diff --git a/protocol/grpc/grpc_protocol.go b/protocol/grpc/grpc_protocol.go index ec1f5aadf2..d06a8353a4 100644 --- a/protocol/grpc/grpc_protocol.go +++ b/protocol/grpc/grpc_protocol.go @@ -58,7 +58,7 @@ func NewGRPCProtocol() *GrpcProtocol { // Export gRPC service for remote invocation func (gp *GrpcProtocol) Export(invoker protocol.Invoker) protocol.Exporter { - url := invoker.GetUrl() + url := invoker.GetURL() serviceKey := url.ServiceKey() exporter := NewGrpcExporter(serviceKey, invoker, gp.ExporterMap()) gp.SetExporterMap(serviceKey, exporter) diff --git a/protocol/grpc/grpc_protocol_test.go b/protocol/grpc/grpc_protocol_test.go index 71f05d0df4..9b17ee4a99 100644 --- a/protocol/grpc/grpc_protocol_test.go +++ b/protocol/grpc/grpc_protocol_test.go @@ -79,7 +79,7 @@ func TestGrpcProtocolExport(t *testing.T) { time.Sleep(time.Second) // make sure url - eq := exporter.GetInvoker().GetUrl().URLEqual(url) + eq := exporter.GetInvoker().GetURL().URLEqual(url) assert.True(t, eq) // make sure exporterMap after 'Unexport' @@ -108,7 +108,7 @@ func TestGrpcProtocolRefer(t *testing.T) { invoker := proto.Refer(url) // make sure url - eq := invoker.GetUrl().URLEqual(url) + eq := invoker.GetURL().URLEqual(url) assert.True(t, eq) // make sure invokers after 'Destroy' diff --git a/protocol/invoker.go b/protocol/invoker.go index e799991686..6bf4d2c2c5 100644 --- a/protocol/invoker.go +++ b/protocol/invoker.go @@ -71,8 +71,8 @@ func NewBaseInvoker(url *common.URL) *BaseInvoker { return ivk } -// GetUrl gets base invoker URL -func (bi *BaseInvoker) GetUrl() *common.URL { +// GetURL gets base invoker URL +func (bi *BaseInvoker) GetURL() *common.URL { return bi.url } @@ -93,7 +93,7 @@ func (bi *BaseInvoker) Invoke(context context.Context, invocation Invocation) Re // Destroy changes available and destroyed flag func (bi *BaseInvoker) Destroy() { - logger.Infof("Destroy invoker: %s", bi.GetUrl()) + logger.Infof("Destroy invoker: %s", bi.GetURL()) bi.destroyed.Store(true) bi.available.Store(false) } diff --git a/protocol/invoker_test.go b/protocol/invoker_test.go index c2a587dc99..5d78bde1e7 100644 --- a/protocol/invoker_test.go +++ b/protocol/invoker_test.go @@ -34,7 +34,7 @@ func TestBaseInvoker(t *testing.T) { assert.Nil(t, err) ivk := NewBaseInvoker(url) - assert.NotNil(t, ivk.GetUrl()) + assert.NotNil(t, ivk.GetURL()) assert.True(t, ivk.IsAvailable()) assert.False(t, ivk.IsDestroyed()) diff --git a/protocol/jsonrpc/jsonrpc_exporter.go b/protocol/jsonrpc/jsonrpc_exporter.go index 6b91d266a7..32a637e474 100644 --- a/protocol/jsonrpc/jsonrpc_exporter.go +++ b/protocol/jsonrpc/jsonrpc_exporter.go @@ -42,9 +42,9 @@ func NewJsonrpcExporter(key string, invoker protocol.Invoker, exporterMap *sync. // Unexport exported JSON RPC service. func (je *JsonrpcExporter) Unexport() { - interfaceName := je.GetInvoker().GetUrl().GetParam(constant.INTERFACE_KEY, "") + interfaceName := je.GetInvoker().GetURL().GetParam(constant.INTERFACE_KEY, "") je.BaseExporter.Unexport() - err := common.ServiceMap.UnRegister(interfaceName, JSONRPC, je.GetInvoker().GetUrl().ServiceKey()) + err := common.ServiceMap.UnRegister(interfaceName, JSONRPC, je.GetInvoker().GetURL().ServiceKey()) if err != nil { logger.Errorf("[JsonrpcExporter.Unexport] error: %v", err) } diff --git a/protocol/jsonrpc/jsonrpc_invoker.go b/protocol/jsonrpc/jsonrpc_invoker.go index f194d6dc21..5579d5b5d6 100644 --- a/protocol/jsonrpc/jsonrpc_invoker.go +++ b/protocol/jsonrpc/jsonrpc_invoker.go @@ -48,7 +48,7 @@ func (ji *JsonrpcInvoker) Invoke(ctx context.Context, invocation protocol.Invoca var result protocol.RPCResult inv := invocation.(*invocation_impl.RPCInvocation) - url := ji.GetUrl() + url := ji.GetURL() req := ji.client.NewRequest(url, inv.MethodName(), inv.Arguments()) ctxNew := context.WithValue(ctx, constant.DUBBOGO_CTX_KEY, map[string]string{ "X-Proxy-ID": "dubbogo", diff --git a/protocol/jsonrpc/jsonrpc_protocol.go b/protocol/jsonrpc/jsonrpc_protocol.go index 313d32fc7c..ecf950b47b 100644 --- a/protocol/jsonrpc/jsonrpc_protocol.go +++ b/protocol/jsonrpc/jsonrpc_protocol.go @@ -61,7 +61,7 @@ func NewJsonrpcProtocol() *JsonrpcProtocol { // Export JSON RPC service for remote invocation func (jp *JsonrpcProtocol) Export(invoker protocol.Invoker) protocol.Exporter { - url := invoker.GetUrl() + url := invoker.GetURL() serviceKey := strings.TrimPrefix(url.Path, "/") exporter := NewJsonrpcExporter(serviceKey, invoker, jp.ExporterMap()) diff --git a/protocol/jsonrpc/jsonrpc_protocol_test.go b/protocol/jsonrpc/jsonrpc_protocol_test.go index 10a9016913..76cbba7ccf 100644 --- a/protocol/jsonrpc/jsonrpc_protocol_test.go +++ b/protocol/jsonrpc/jsonrpc_protocol_test.go @@ -46,7 +46,7 @@ func TestJsonrpcProtocolExport(t *testing.T) { exporter := proto.Export(protocol.NewBaseInvoker(url)) // make sure url - eq := exporter.GetInvoker().GetUrl().URLEqual(url) + eq := exporter.GetInvoker().GetURL().URLEqual(url) assert.True(t, eq) // make sure exporterMap after 'Unexport' @@ -82,7 +82,7 @@ func TestJsonrpcProtocolRefer(t *testing.T) { invoker := proto.Refer(url) // make sure url - eq := invoker.GetUrl().URLEqual(url) + eq := invoker.GetURL().URLEqual(url) assert.True(t, eq) // make sure invokers after 'Destroy' diff --git a/protocol/mock/mock_invoker.go b/protocol/mock/mock_invoker.go index 8a0973bd12..0e3397c9a2 100644 --- a/protocol/mock/mock_invoker.go +++ b/protocol/mock/mock_invoker.go @@ -58,16 +58,16 @@ func (m *MockInvoker) EXPECT() *MockInvokerMockRecorder { return m.recorder } -// GetUrl mocks base method -func (m *MockInvoker) GetUrl() *common.URL { - ret := m.ctrl.Call(m, "GetUrl") +// GetURL mocks base method +func (m *MockInvoker) GetURL() *common.URL { + ret := m.ctrl.Call(m, "GetURL") ret0, _ := ret[0].(*common.URL) return ret0 } // GetUrl indicates an expected call of GetUrl func (mr *MockInvokerMockRecorder) GetUrl() *gomock.Call { - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetUrl", reflect.TypeOf((*MockInvoker)(nil).GetUrl)) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetURL", reflect.TypeOf((*MockInvoker)(nil).GetURL)) } // IsAvailable mocks base method diff --git a/protocol/protocolwrapper/protocol_filter_wrapper.go b/protocol/protocolwrapper/protocol_filter_wrapper.go index 448bd6f5a9..95c8178d90 100644 --- a/protocol/protocolwrapper/protocol_filter_wrapper.go +++ b/protocol/protocolwrapper/protocol_filter_wrapper.go @@ -48,7 +48,7 @@ type ProtocolFilterWrapper struct { // Export service for remote invocation func (pfw *ProtocolFilterWrapper) Export(invoker protocol.Invoker) protocol.Exporter { if pfw.protocol == nil { - pfw.protocol = extension.GetProtocol(invoker.GetUrl().Protocol) + pfw.protocol = extension.GetProtocol(invoker.GetURL().Protocol) } invoker = buildInvokerChain(invoker, constant.SERVICE_FILTER_KEY) return pfw.protocol.Export(invoker) @@ -72,7 +72,7 @@ func (pfw *ProtocolFilterWrapper) Destroy() { } func buildInvokerChain(invoker protocol.Invoker, key string) protocol.Invoker { - filterName := invoker.GetUrl().GetParam(key, "") + filterName := invoker.GetURL().GetParam(key, "") if filterName == "" { return invoker } @@ -104,9 +104,9 @@ type FilterInvoker struct { filter filter.Filter } -// GetUrl is used to get url from FilterInvoker -func (fi *FilterInvoker) GetUrl() *common.URL { - return fi.invoker.GetUrl() +// GetURL is used to get url from FilterInvoker +func (fi *FilterInvoker) GetURL() *common.URL { + return fi.invoker.GetURL() } // IsAvailable is used to get available status diff --git a/protocol/rest/rest_exporter.go b/protocol/rest/rest_exporter.go index 7a49a20635..1076f8fc9b 100644 --- a/protocol/rest/rest_exporter.go +++ b/protocol/rest/rest_exporter.go @@ -42,9 +42,9 @@ func NewRestExporter(key string, invoker protocol.Invoker, exporterMap *sync.Map // Unexport unexport the RestExporter func (re *RestExporter) Unexport() { - interfaceName := re.GetInvoker().GetUrl().GetParam(constant.INTERFACE_KEY, "") + interfaceName := re.GetInvoker().GetURL().GetParam(constant.INTERFACE_KEY, "") re.BaseExporter.Unexport() - err := common.ServiceMap.UnRegister(interfaceName, REST, re.GetInvoker().GetUrl().ServiceKey()) + err := common.ServiceMap.UnRegister(interfaceName, REST, re.GetInvoker().GetURL().ServiceKey()) if err != nil { logger.Errorf("[RestExporter.Unexport] error: %v", err) } diff --git a/protocol/rest/rest_invoker.go b/protocol/rest/rest_invoker.go index 898890e417..a650f70a98 100644 --- a/protocol/rest/rest_invoker.go +++ b/protocol/rest/rest_invoker.go @@ -83,7 +83,7 @@ func (ri *RestInvoker) Invoke(ctx context.Context, invocation protocol.Invocatio body = inv.Arguments()[methodConfig.Body] } req := &client.RestClientRequest{ - Location: ri.GetUrl().Location, + Location: ri.GetURL().Location, Method: methodConfig.MethodType, Path: methodConfig.Path, PathParams: pathParams, diff --git a/protocol/rest/rest_protocol.go b/protocol/rest/rest_protocol.go index a87eb09f06..f77df66836 100644 --- a/protocol/rest/rest_protocol.go +++ b/protocol/rest/rest_protocol.go @@ -66,7 +66,7 @@ func NewRestProtocol() *RestProtocol { // Export export rest service func (rp *RestProtocol) Export(invoker protocol.Invoker) protocol.Exporter { - url := invoker.GetUrl() + url := invoker.GetURL() serviceKey := url.ServiceKey() exporter := NewRestExporter(serviceKey, invoker, rp.ExporterMap()) id := url.GetParam(constant.BEAN_NAME_KEY, "") diff --git a/protocol/rest/rest_protocol_test.go b/protocol/rest/rest_protocol_test.go index f765a5daf6..f23db0d4ea 100644 --- a/protocol/rest/rest_protocol_test.go +++ b/protocol/rest/rest_protocol_test.go @@ -56,7 +56,7 @@ func TestRestProtocolRefer(t *testing.T) { invoker := proto.Refer(url) // make sure url - eq := invoker.GetUrl().URLEqual(url) + eq := invoker.GetURL().URLEqual(url) assert.True(t, eq) // make sure invokers after 'Destroy' @@ -104,7 +104,7 @@ func TestRestProtocolExport(t *testing.T) { proxyFactory := extension.GetProxyFactory("default") exporter := proto.Export(proxyFactory.GetInvoker(url)) // make sure url - eq := exporter.GetInvoker().GetUrl().URLEqual(url) + eq := exporter.GetInvoker().GetURL().URLEqual(url) assert.True(t, eq) // make sure exporterMap after 'Unexport' fmt.Println(url.Path) diff --git a/protocol/rest/server/rest_server.go b/protocol/rest/server/rest_server.go index b0bf0e07bd..e5fe40d54c 100644 --- a/protocol/rest/server/rest_server.go +++ b/protocol/rest/server/rest_server.go @@ -89,7 +89,7 @@ func GetRouteFunc(invoker protocol.Invoker, methodConfig *rest_config.RestMethod err error args []interface{} ) - svc := common.ServiceMap.GetServiceByServiceKey(invoker.GetUrl().Protocol, invoker.GetUrl().ServiceKey()) + svc := common.ServiceMap.GetServiceByServiceKey(invoker.GetURL().Protocol, invoker.GetURL().ServiceKey()) // get method method := svc.Method()[methodConfig.MethodName] argsTypes := method.ArgsType() diff --git a/protocol/rpc_status.go b/protocol/rpc_status.go index 3994f8dd7b..2a704338e9 100644 --- a/protocol/rpc_status.go +++ b/protocol/rpc_status.go @@ -203,21 +203,21 @@ func CleanAllStatus() { // GetInvokerHealthyStatus get invoker's conn healthy status func GetInvokerHealthyStatus(invoker Invoker) bool { - _, found := invokerBlackList.Load(invoker.GetUrl().Key()) + _, found := invokerBlackList.Load(invoker.GetURL().Key()) return !found } // SetInvokerUnhealthyStatus add target invoker to black list func SetInvokerUnhealthyStatus(invoker Invoker) { - invokerBlackList.Store(invoker.GetUrl().Key(), invoker) - logger.Info("Add invoker ip = ", invoker.GetUrl().Location, " to black list") + invokerBlackList.Store(invoker.GetURL().Key(), invoker) + logger.Info("Add invoker ip = ", invoker.GetURL().Location, " to black list") blackListCacheDirty.Store(true) } // RemoveInvokerUnhealthyStatus remove unhealthy status of target invoker from blacklist func RemoveInvokerUnhealthyStatus(invoker Invoker) { - invokerBlackList.Delete(invoker.GetUrl().Key()) - logger.Info("Remove invoker ip = ", invoker.GetUrl().Location, " from black list") + invokerBlackList.Delete(invoker.GetURL().Key()) + logger.Info("Remove invoker ip = ", invoker.GetURL().Location, " from black list") blackListCacheDirty.Store(true) } diff --git a/registry/base_registry.go b/registry/base_registry.go index a16a998511..325bab63d5 100644 --- a/registry/base_registry.go +++ b/registry/base_registry.go @@ -112,8 +112,8 @@ func (r *BaseRegistry) InitBaseRegistry(url *common.URL, facadeRegistry FacadeBa return r } -// GetUrl for get registry's url -func (r *BaseRegistry) GetUrl() *common.URL { +// GetURL for get registry's url +func (r *BaseRegistry) GetURL() *common.URL { return r.URL } diff --git a/registry/consul/registry.go b/registry/consul/registry.go index 4d3718e58c..a50536fb63 100644 --- a/registry/consul/registry.go +++ b/registry/consul/registry.go @@ -177,8 +177,8 @@ func (r *consulRegistry) getListener(url *common.URL) (registry.Listener, error) return listener, err } -// GetUrl get registry URL of consul registry center -func (r *consulRegistry) GetUrl() *common.URL { +// GetURL get registry URL of consul registry center +func (r *consulRegistry) GetURL() *common.URL { return r.URL } diff --git a/registry/directory/directory.go b/registry/directory/directory.go index 811716b8a1..da05c02d21 100644 --- a/registry/directory/directory.go +++ b/registry/directory/directory.go @@ -289,7 +289,7 @@ func (dir *RegistryDirectory) toGroupInvokers() []protocol.Invoker { }) for _, invoker := range newInvokersList { - group := invoker.GetUrl().GetParam(constant.GROUP_KEY, "") + group := invoker.GetURL().GetParam(constant.GROUP_KEY, "") groupInvokersMap[group] = append(groupInvokersMap[group], invoker) } @@ -302,7 +302,7 @@ func (dir *RegistryDirectory) toGroupInvokers() []protocol.Invoker { } else { for _, invokers := range groupInvokersMap { staticDir := directory.NewStaticDirectory(invokers) - cst := extension.GetCluster(dir.GetUrl().SubURL.GetParam(constant.CLUSTER_KEY, constant.DEFAULT_CLUSTER)) + cst := extension.GetCluster(dir.GetURL().SubURL.GetParam(constant.CLUSTER_KEY, constant.DEFAULT_CLUSTER)) err = staticDir.BuildRouterChain(invokers) if err != nil { logger.Error(err) @@ -368,11 +368,11 @@ func (dir *RegistryDirectory) doCacheInvoker(newUrl *common.URL) (protocol.Invok } else { // if cached invoker has the same URL with the new URL, then no need to re-refer, and no need to destroy // the old invoker. - if common.GetCompareURLEqualFunc()(newUrl, cacheInvoker.(protocol.Invoker).GetUrl()) { + if common.GetCompareURLEqualFunc()(newUrl, cacheInvoker.(protocol.Invoker).GetURL()) { return nil, true } - logger.Debugf("service will be updated in cache invokers: new invoker url is %s, old invoker url is %s", newUrl, cacheInvoker.(protocol.Invoker).GetUrl()) + logger.Debugf("service will be updated in cache invokers: new invoker url is %s, old invoker url is %s", newUrl, cacheInvoker.(protocol.Invoker).GetURL()) newInvoker := extension.GetProtocol(protocolwrapper.FILTER).Refer(newUrl) if newInvoker != nil { dir.cacheInvokersMap.Store(key, newInvoker) diff --git a/registry/directory/directory_test.go b/registry/directory/directory_test.go index 81b9ece042..e733cf5f94 100644 --- a/registry/directory/directory_test.go +++ b/registry/directory/directory_test.go @@ -91,7 +91,7 @@ func Test_MergeProviderUrl(t *testing.T) { time.Sleep(1e9) assert.Len(t, registryDirectory.cacheInvokers, 1) if len(registryDirectory.cacheInvokers) > 0 { - assert.Equal(t, "mock", registryDirectory.cacheInvokers[0].GetUrl().GetParam(constant.CLUSTER_KEY, "")) + assert.Equal(t, "mock", registryDirectory.cacheInvokers[0].GetURL().GetParam(constant.CLUSTER_KEY, "")) } } @@ -113,7 +113,7 @@ Loop1: Loop2: for { if len(registryDirectory.cacheInvokers) > 0 { - if "mock1" == registryDirectory.cacheInvokers[0].GetUrl().GetParam(constant.CLUSTER_KEY, "") { + if "mock1" == registryDirectory.cacheInvokers[0].GetURL().GetParam(constant.CLUSTER_KEY, "") { assert.Len(t, registryDirectory.cacheInvokers, 1) assert.True(t, true) break Loop2 diff --git a/registry/mock_registry.go b/registry/mock_registry.go index 953f42889a..ea3d5eb622 100644 --- a/registry/mock_registry.go +++ b/registry/mock_registry.go @@ -71,7 +71,7 @@ func (r *MockRegistry) IsAvailable() bool { } // nolint -func (r *MockRegistry) GetUrl() *common.URL { +func (r *MockRegistry) GetURL() *common.URL { return nil } diff --git a/registry/nacos/registry.go b/registry/nacos/registry.go index 4bc88d71b1..1d2aabd492 100644 --- a/registry/nacos/registry.go +++ b/registry/nacos/registry.go @@ -212,8 +212,8 @@ func (nr *nacosRegistry) UnSubscribe(url *common.URL, notifyListener registry.No return perrors.New("UnSubscribe not support in nacosRegistry") } -// GetUrl gets its registration URL -func (nr *nacosRegistry) GetUrl() *common.URL { +// GetURL gets its registration URL +func (nr *nacosRegistry) GetURL() *common.URL { return nr.URL } diff --git a/registry/protocol/protocol.go b/registry/protocol/protocol.go index 0282e4293a..f140affa5e 100644 --- a/registry/protocol/protocol.go +++ b/registry/protocol/protocol.go @@ -265,7 +265,7 @@ func (nl *overrideSubscribeListener) doOverrideIfNecessary() { providerUrl := getProviderUrl(nl.originInvoker) key := getCacheKey(providerUrl) if exporter, ok := nl.protocol.bounds.Load(key); ok { - currentUrl := exporter.(protocol.Exporter).GetInvoker().GetUrl() + currentUrl := exporter.(protocol.Exporter).GetInvoker().GetURL() // Compatible with the 2.6.x if nl.configurator != nil { nl.configurator.Configure(providerUrl) @@ -283,7 +283,7 @@ func (nl *overrideSubscribeListener) doOverrideIfNecessary() { } if currentUrl.String() != providerUrl.String() { - newRegUrl := nl.originInvoker.GetUrl().Clone() + newRegUrl := nl.originInvoker.GetURL().Clone() setProviderUrl(newRegUrl, providerUrl) nl.protocol.reExport(nl.originInvoker, newRegUrl) } @@ -374,7 +374,7 @@ func (proto *registryProtocol) Destroy() { func getRegistryUrl(invoker protocol.Invoker) *common.URL { // here add * for return a new url - url := invoker.GetUrl() + url := invoker.GetURL() // if the protocol == registry, set protocol the registry value in url.params if url.Protocol == constant.REGISTRY_PROTOCOL { url.Protocol = url.GetParam(constant.REGISTRY_KEY, "") @@ -383,7 +383,7 @@ func getRegistryUrl(invoker protocol.Invoker) *common.URL { } func getProviderUrl(invoker protocol.Invoker) *common.URL { - url := invoker.GetUrl() + url := invoker.GetURL() // be careful params maps in url is map type return url.SubURL.Clone() } diff --git a/registry/protocol/protocol_test.go b/registry/protocol/protocol_test.go index c42590517d..bf8e4a9cdd 100644 --- a/registry/protocol/protocol_test.go +++ b/registry/protocol/protocol_test.go @@ -63,7 +63,7 @@ func referNormal(t *testing.T, regProtocol *registryProtocol) { invoker := regProtocol.Refer(url) assert.IsType(t, &protocol.BaseInvoker{}, invoker) - assert.Equal(t, invoker.GetUrl().String(), url.String()) + assert.Equal(t, invoker.GetURL().String(), url.String()) } func TestRefer(t *testing.T) { @@ -133,7 +133,7 @@ func exporterNormal(t *testing.T, regProtocol *registryProtocol) *common.URL { exporter := regProtocol.Export(invoker) assert.IsType(t, &protocol.BaseExporter{}, exporter) - assert.Equal(t, exporter.GetInvoker().GetUrl().String(), suburl.String()) + assert.Equal(t, exporter.GetInvoker().GetURL().String(), suburl.String()) return url } diff --git a/registry/servicediscovery/service_discovery_registry.go b/registry/servicediscovery/service_discovery_registry.go index e3f2af3cc1..b540ccac46 100644 --- a/registry/servicediscovery/service_discovery_registry.go +++ b/registry/servicediscovery/service_discovery_registry.go @@ -143,7 +143,7 @@ func (s *serviceDiscoveryRegistry) GetServiceDiscovery() registry.ServiceDiscove return s.serviceDiscovery } -func (s *serviceDiscoveryRegistry) GetUrl() *common.URL { +func (s *serviceDiscoveryRegistry) GetURL() *common.URL { return s.url } diff --git a/registry/zookeeper/service_discovery.go b/registry/zookeeper/service_discovery.go index 463016f755..92207c832f 100644 --- a/registry/zookeeper/service_discovery.go +++ b/registry/zookeeper/service_discovery.go @@ -156,7 +156,7 @@ func (zksd *zookeeperServiceDiscovery) RestartCallBack() bool { } // nolint -func (zksd *zookeeperServiceDiscovery) GetUrl() *common.URL { +func (zksd *zookeeperServiceDiscovery) GetURL() *common.URL { return zksd.url } diff --git a/remoting/etcdv3/facade.go b/remoting/etcdv3/facade.go index 8bd1e3a23c..5f41176b7d 100644 --- a/remoting/etcdv3/facade.go +++ b/remoting/etcdv3/facade.go @@ -62,7 +62,7 @@ LOOP: case <-r.Client().Done(): r.ClientLock().Lock() clientName := gxetcd.RegistryETCDV3Client - timeout, _ := time.ParseDuration(r.GetUrl().GetParam(constant.REGISTRY_TIMEOUT_KEY, constant.DEFAULT_REG_TIMEOUT)) + timeout, _ := time.ParseDuration(r.GetURL().GetParam(constant.REGISTRY_TIMEOUT_KEY, constant.DEFAULT_REG_TIMEOUT)) endpoints := r.Client().GetEndPoints() r.Client().Close() r.SetClient(nil) diff --git a/remoting/kubernetes/client.go b/remoting/kubernetes/client.go index aabbc00579..39fd6f2560 100644 --- a/remoting/kubernetes/client.go +++ b/remoting/kubernetes/client.go @@ -166,7 +166,7 @@ func ValidateClient(container clientFacade) error { // new Client if client == nil || client.Valid() { - newClient, err := newClient(container.GetUrl()) + newClient, err := newClient(container.GetURL()) if err != nil { logger.Warnf("new kubernetes client: %v)", err) return perrors.WithMessage(err, "new kubernetes client") diff --git a/remoting/kubernetes/facade_test.go b/remoting/kubernetes/facade_test.go index d0d710cb26..367e44f4fa 100644 --- a/remoting/kubernetes/facade_test.go +++ b/remoting/kubernetes/facade_test.go @@ -42,7 +42,7 @@ func (r *mockFacade) SetClient(client *Client) { r.client = client } -func (r *mockFacade) GetUrl() *common.URL { +func (r *mockFacade) GetURL() *common.URL { return r.URL } diff --git a/remoting/zookeeper/client.go b/remoting/zookeeper/client.go index 5d39666ebd..bbc9b0a8ac 100644 --- a/remoting/zookeeper/client.go +++ b/remoting/zookeeper/client.go @@ -48,7 +48,7 @@ var ( // ValidateZookeeperClient validates client and sets options func ValidateZookeeperClient(container ZkClientFacade, zkName string) error { lock := container.ZkClientLock() - url := container.GetUrl() + url := container.GetURL() lock.Lock() defer lock.Unlock() diff --git a/remoting/zookeeper/facade.go b/remoting/zookeeper/facade.go index 3bc7995561..f66a2c9d9c 100644 --- a/remoting/zookeeper/facade.go +++ b/remoting/zookeeper/facade.go @@ -38,7 +38,7 @@ type ZkClientFacade interface { WaitGroup() *sync.WaitGroup // for wait group control, zk client listener & zk client container Done() chan struct{} // for registry destroy RestartCallBack() bool - GetUrl() *common.URL + GetURL() *common.URL } // HandleClientRestart keeps the connection between client and server diff --git a/remoting/zookeeper/facade_test.go b/remoting/zookeeper/facade_test.go index 6463e57453..af8f8870c8 100644 --- a/remoting/zookeeper/facade_test.go +++ b/remoting/zookeeper/facade_test.go @@ -90,7 +90,7 @@ func (r *mockFacade) Done() chan struct{} { return r.done } -func (r *mockFacade) GetUrl() *common.URL { +func (r *mockFacade) GetURL() *common.URL { return r.URL } From d2c4dff4cd3ab6d5d6ad6685f01b7a8e2d9bd2f3 Mon Sep 17 00:00:00 2001 From: LaurenceLiZhixin <382673304@qq.com> Date: Mon, 5 Apr 2021 14:45:59 +0800 Subject: [PATCH 2/2] fix: change GetID function --- registry/file/service_discovery.go | 6 +++--- registry/servicediscovery/service_discovery_registry.go | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/registry/file/service_discovery.go b/registry/file/service_discovery.go index f68498d30f..40811dab8c 100644 --- a/registry/file/service_discovery.go +++ b/registry/file/service_discovery.go @@ -144,11 +144,11 @@ func (fssd *fileSystemServiceDiscovery) Register(instance registry.ServiceInstan // nolint func getServiceInstanceId(si registry.ServiceInstance) string { - if si.GetId() == "" { + if si.GetID() == "" { return si.GetHost() + "." + strconv.Itoa(si.GetPort()) } - return si.GetId() + return si.GetID() } // nolint @@ -181,7 +181,7 @@ func (fssd *fileSystemServiceDiscovery) Unregister(instance registry.ServiceInst return perrors.WithStack(err) } - delete(fssd.fileMap, instance.GetId()) + delete(fssd.fileMap, instance.GetID()) return nil } diff --git a/registry/servicediscovery/service_discovery_registry.go b/registry/servicediscovery/service_discovery_registry.go index b540ccac46..72b8dc6d4d 100644 --- a/registry/servicediscovery/service_discovery_registry.go +++ b/registry/servicediscovery/service_discovery_registry.go @@ -457,7 +457,7 @@ func (s *serviceDiscoveryRegistry) initRevisionExportedURLsByInst(serviceInstanc if len(revisionExportedURLsMap) > 0 { // The case is that current ServiceInstance with the different revision logger.Warnf("The ServiceInstance[id: %s, host : %s , port : %s] has different revision : %s"+ - ", please make sure the service [name : %s] is changing or not.", serviceInstance.GetId(), + ", please make sure the service [name : %s] is changing or not.", serviceInstance.GetID(), serviceInstance.GetHost(), serviceInstance.GetPort(), revision, serviceInstance.GetServiceName()) } else { firstGet = true @@ -467,14 +467,14 @@ func (s *serviceDiscoveryRegistry) initRevisionExportedURLsByInst(serviceInstanc revisionExportedURLsMap[revision] = revisionExportedURLs logger.Debugf("Get the exported URLs[size : %s, first : %s] from the target service "+ "instance [id: %s , service : %s , host : %s , port : %s , revision : %s]", - len(revisionExportedURLs), firstGet, serviceInstance.GetId(), serviceInstance.GetServiceName(), + len(revisionExportedURLs), firstGet, serviceInstance.GetID(), serviceInstance.GetServiceName(), serviceInstance.GetHost(), serviceInstance.GetPort(), revision) } } else { // Else, The cache is hit logger.Debugf("Get the exported URLs[size : %s] from cache, the instance"+ "[id: %s , service : %s , host : %s , port : %s , revision : %s]", len(revisionExportedURLs), firstGet, - serviceInstance.GetId(), serviceInstance.GetServiceName(), serviceInstance.GetHost(), + serviceInstance.GetID(), serviceInstance.GetServiceName(), serviceInstance.GetHost(), serviceInstance.GetPort(), revision) } return revisionExportedURLs