Merge branch '3.0' into feat/adasvc
# Conflicts:
# cluster/cluster/base/cluster_invoker.go
# cluster/cluster/failback/cluster_invoker.go
# cluster/cluster/failover/cluster_invoker.go
# cluster/cluster/failsafe/cluster_invoker.go
# cluster/cluster/forking/cluster_invoker.go
# cluster/cluster/forking/cluster_test.go
# common/constant/default.go
# common/constant/key.go
# common/metadata_info.go
# common/url.go
# common/url_test.go
# config/metadata_report_config.go
# config/reference_config.go
# config/registry_config.go
# config/service_config.go
# config_center/configurator/override.go
# filter/execlmt/filter_test.go
# filter/generic/util.go
# filter/tps/limiter/method_service_test.go
# metadata/report/etcd/report.go
# metadata/report/zookeeper/report.go
# metadata/service/local/metadata_service_proxy_factory.go
# metadata/service/local/service.go
# metadata/service/remote/service.go
# metrics/prometheus/reporter.go
# protocol/dubbo/dubbo_codec.go
# protocol/dubbo/dubbo_invoker.go
# protocol/dubbo3/dubbo3_invoker.go
# protocol/dubbo3/dubbo3_protocol.go
# protocol/invocation/rpcinvocation.go
# protocol/invocation/rpcinvocation_test.go
# protocol/jsonrpc/server.go
# registry/directory/directory.go
# registry/nacos/registry.go
# registry/nacos/registry_test.go
# registry/protocol/protocol.go
# registry/servicediscovery/service_discovery_registry.go
# registry/servicediscovery/synthesizer/rest/rest_subscribed_urls_synthesizer.go
# registry/servicediscovery/synthesizer/rest/rest_subscribed_urls_synthesizer_test.go
# remoting/getty/dubbo_codec_for_test.go
# remoting/getty/readwriter_test.go
# remoting/kubernetes/facade_test.go
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b60ab2d..14e4d17 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,7 +1,152 @@
# Release Notes
---
-## 3.0.0
+## 3.0.0-rc3
+
+### Feature:
+
+- Triple features
+
+ - [New triple pb generation tool](https://github.com/dubbogo/tools/pull/17)
+
+ Refer to [QuickStart of dubbo-go 3.0](https://dubbogo.github.io/zh-cn/docs/user/quickstart/3.0/quickstart.html), and [Dubbo-go-samples](https://github.com/apache/dubbo-go-samples) to try protoc-gen-go-triple pb generator plugin.
+
+ - [Response exception from client](https://github.com/dubbogo/triple/pull/30)
+
+ Triple client can get the error stacks from server, pointing to real error occurs position.
+
+ - [Multi params support](https://github.com/apache/dubbo-go/pull/1344)
+
+- [New metrics support](https://github.com/apache/dubbo-go/pull/1540)
+
+ Refer to [Docs of dubbo-go 3.0 Metrics](https://dubbogo.github.io/zh-cn/docs/user/samples/metrics.html), and [dubbo-go-samples/metrics](https://github.com/apache/dubbo-go-samples/tree/master/metrics)] to try new metrics support.
+
+- [Remove sleep to wait for service discovery logic](https://github.com/apache/dubbo-go/pull/1531)
+
+ Set reference check default to true and remove extra time.Sleep logic in client side during service-discovery [remove time.Sleep](https://github.com/apache/dubbo-go-samples/pull/276/files)
+
+ - [Registry Waittime configurable](https://github.com/apache/dubbo-go/pull/1516/files)
+
+- [Dynamic Route Config](https://github.com/apache/dubbo-go/pull/1519)
+
+ Refer to [Docs of dubbo-go 3.0 Router](https://dubbogo.github.io/zh-cn/docs/user/samples/mesh_router.html), and [dubbo-go-samples/meshrouter](https://github.com/apache/dubbo-go-samples/tree/master/route/meshroute) to try dynamic mesh router support.
+
+- [New config API support](https://github.com/apache/dubbo-go/pull/1499) [New root config API builder](https://github.com/apache/dubbo-go/pull/1491)
+
+ Refer to [Docs of dubbo-go 3.0 Configuration](https://dubbogo.github.io/zh-cn/docs/user/concept/configuration.html), and [dubbo-go-samples/config-api](https://github.com/apache/dubbo-go-samples/tree/master/config-api) to try new config API.
+
+- [Support custom registry group name on Nacos](https://github.com/apache/dubbo-go/pull/1353)
+
+- [GRPC supports multi pb](https://github.com/apache/dubbo-go/pull/1361)
+
+- [New logger support](https://github.com/apache/dubbo-go/pull/1335)
+
+ Refer to [Docs of dubbo-go 3.0 logger](https://dubbogo.github.io/zh-cn/docs/user/samples/custom-logger.html), and [dubbo-go-samples/logger](https://github.com/apache/dubbo-go-samples/tree/master/logger) to try new logger support.
+
+- [Generic invocation supports](https://github.com/apache/dubbo-go/pull/1315)
+
+ Refer to [Docs of dubbo-go 3.0 generic](https://dubbogo.github.io/zh-cn/docs/user/samples/generic.html), and [dubbo-go-samples/generic](https://github.com/apache/dubbo-go-samples/tree/master/generic) to try new generic support.
+
+- [Support key generate function in service event](https://github.com/apache/dubbo-go/pull/1286)
+
+
+
+### Enhancement:
+
+- [Configuration Enhancement](https://github.com/apache/dubbo-go/commit/1397e8bba97f14b7656a5afc9bc92530bb693092)
+
+ One of the biggest update in this release is the configuration optimization. We discarded the old configuration and introduced a new one. Currently, the new configuration has been updated to [the master branch of samples](https://github.com/apache/dubbo-go-samples) (corresponding to latest dubbo-go 3.0), and there are introductions and detailed examples on the our website [dubbogo.github](https://dubbogo.github.io).
+
+- Triple:
+
+ - [Triple CPU usage optimization](https://github.com/dubbogo/triple/pull/32/files)
+
+ Set default tcp read buffer to 4k to decrease gc, and descrease CPU usage by 60% of 3.0.0-rc2
+
+ - [Add Triple Debug Log](https://github.com/dubbogo/triple/pull/29)
+
+- [Support Apollo secret](https://github.com/apache/dubbo-go/pull/1533)
+
+- [Use class Name as the default reference name ](https://github.com/apache/dubbo-go/pull/1339)
+
+ You can set service/refernce key to provider/consumer's struct name: [Config samples](https://github.com/apache/dubbo-go-samples/blob/master/helloworld/go-server/conf/dubbogo.yml#L15) & [Target provider struct](https://github.com/apache/dubbo-go-samples/blob/master/helloworld/go-server/cmd/server.go#L45),
+
+ And there is no needs to define (p*Provider) Reference() method from now on.
+
+- [Set default logger level to info](https://github.com/apache/dubbo-go/pull/1549/files#diff-d5ab135265094924568957f56eaef061c7948d2664daa995fbe0de4c7ab2d272R82)
+- [Refactor of filter package sturcture](https://github.com/apache/dubbo-go/pull/1299)
+- [Refactor of cluster package structure](https://github.com/apache/dubbo-go/pull/1507)
+
+
+
+### Bugfix:
+
+- [Heartbeat's timeout will modify consumer's timeout](https://github.com/apache/dubbo-go/pull/1532)
+
+- [Remove zk test to ensure ut could be run locally](https://github.com/apache/dubbo-go/pull/1357)
+
+- [Add Application Registry](https://github.com/apache/dubbo-go/pull/1493)
+
+- [Change serviceName like java style on nacos](https://github.com/apache/dubbo-go/pull/1352)
+
+- [Url serialization bug](https://github.com/apache/dubbo-go/pull/1292)
+
+- [Change the key of a mock echo filter](https://github.com/apache/dubbo-go/pull/1381)
+
+- [Fix: fix the exception when tcp timeout is less than 1s for 3.0 #1362](https://github.com/apache/dubbo-go/pull/1380)
+
+- [Registry timeout not pars](https://github.com/apache/dubbo-go/pull/1392)
+
+- [Fix Isprovider check](https://github.com/apache/dubbo-go/pull/1500)
+
+- [Delete zk registry when set defualt consumer/provider config](https://github.com/apache/dubbo-go/pull/1324/files)
+
+
+## 3.0.0-rc2
+
+### New Features
+
+- [Add Triple Msgpack Codec](https://github.com/apache/dubbo-go/pull/1242)
+- [Add Triple user defined serializer support](https://github.com/apache/dubbo-go/pull/1242)
+- [Add gRPC provider reference in codes generated by protoc-gen-dubbo3](https://github.com/apache/dubbo-go/pull/1240)
+- [Add integration tests using dubbo-go-samples](https://github.com/apache/dubbo-go/pull/1223)
+- [Add service discovery support etcd remote reporter](https://github.com/apache/dubbo-go/pull/1221)
+- [Add service discovery support nacos remote reporter](https://github.com/apache/dubbo-go/pull/1218)
+- [Add grpc server reflection register logic](https://github.com/apache/dubbo-go/pull/1216)
+
+### Enhancement
+
+- [Make remote metadata center configurable](https://github.com/apache/dubbo-go/pull/1258)
+- [Enhance nacos connection](https://github.com/apache/dubbo-go/pull/1255)
+- [Add unit tests for zk metadata report](https://github.com/apache/dubbo-go/pull/1229)
+- [Restructuring remoting metadata service](https://github.com/apache/dubbo-go/pull/1227)
+- [Dependency prompting for unit tests](https://github.com/apache/dubbo-go/pull/1212)
+- [Make cluster interceptor a chain](https://github.com/apache/dubbo-go/pull/1211)
+- [Improve etcd version and change create to put](https://github.com/apache/dubbo-go/pull/1203)
+- [Remove reflect in grpc server](https://github.com/apache/dubbo-go/pull/1200)
+- [Change lb hash logic](https://github.com/apache/dubbo-go/pull/1267)
+
+### Bugfixes
+
+- [Fix: zk invoker refer check fail,and service will be added in cache invokers fail problem](https://github.com/apache/dubbo-go/pull/1249)
+- [Fix: app level service discovery local mod URL serialize fail problem](https://github.com/apache/dubbo-go/pull/1238)
+- [Fix: m1 cpu exec fail problem](https://github.com/apache/dubbo-go/pull/1236)
+- [Fix: metadata info struct contains unsupported field](https://github.com/apache/dubbo-go/pull/1234)
+- [Fix: go race in directory](https://github.com/apache/dubbo-go/pull/1222)
+- [Fix: zk name changes from default to conn location](https://github.com/apache/dubbo-go/pull/1263)
+
+### Dependencies
+
+- [bump actions/cache from 2.1.5 to 2.1.6](https://github.com/apache/dubbo-go/pull/1230)
+
+Milestone:
+
+- [https://github.com/apache/dubbo-go/milestone/12](https://github.com/apache/dubbo-go/milestone/12?closed=1)
+
+
+
+
+## 3.0.0-rc1
### New Features
- [Add triple protocol](https://github.com/apache/dubbo-go/pull/1071)
diff --git a/cluster/cluster/available/cluster_invoker_test.go b/cluster/cluster/available/cluster_invoker_test.go
index 22d6981..ca60a8d 100644
--- a/cluster/cluster/available/cluster_invoker_test.go
+++ b/cluster/cluster/available/cluster_invoker_test.go
@@ -43,7 +43,7 @@
)
var availableUrl, _ = common.NewURL(fmt.Sprintf("dubbo://%s:%d/com.ikurento.user.UserProvider",
- constant.LOCAL_HOST_VALUE, constant.DEFAULT_PORT))
+ constant.LocalHostValue, constant.DefaultPort))
func registerAvailable(invoker *mock.MockInvoker) protocol.Invoker {
extension.SetLoadbalance("random", random.NewLoadBalance)
diff --git a/cluster/cluster/base/cluster_invoker.go b/cluster/cluster/base/cluster_invoker.go
index 059d0d9..cb7de4f 100644
--- a/cluster/cluster/base/cluster_invoker.go
+++ b/cluster/cluster/base/cluster_invoker.go
@@ -155,11 +155,9 @@
}
return reselectedInvoker
}
- } else {
- return selectedInvoker
}
- logger.Errorf("all %d invokers is unavailable for %s.", len(invokers), selectedInvoker.GetURL().String())
- return nil
+
+ return selectedInvoker
}
func isInvoked(selectedInvoker protocol.Invoker, invoked []protocol.Invoker) bool {
@@ -176,7 +174,7 @@
methodName := invocation.MethodName()
// Get the service loadbalance config
- lb := url.GetParam(constant.LoadbalanceKey, constant.DEFAULT_LOADBALANCE)
+ lb := url.GetParam(constant.LoadbalanceKey, constant.DefaultLoadbalance)
// Get the service method loadbalance config if have
if v := url.GetMethodParam(methodName, constant.LoadbalanceKey, ""); len(v) > 0 {
diff --git a/cluster/cluster/broadcast/cluster_invoker_test.go b/cluster/cluster/broadcast/cluster_invoker_test.go
index 356151d..0339c9f 100644
--- a/cluster/cluster/broadcast/cluster_invoker_test.go
+++ b/cluster/cluster/broadcast/cluster_invoker_test.go
@@ -43,7 +43,7 @@
)
var broadcastUrl, _ = common.NewURL(
- fmt.Sprintf("dubbo://%s:%d/com.ikurento.user.UserProvider", constant.LOCAL_HOST_VALUE, constant.DEFAULT_PORT))
+ fmt.Sprintf("dubbo://%s:%d/com.ikurento.user.UserProvider", constant.LocalHostValue, constant.DefaultPort))
func registerBroadcast(mockInvokers ...*mock.MockInvoker) protocol.Invoker {
extension.SetLoadbalance("random", random.NewLoadBalance)
diff --git a/cluster/cluster/failback/cluster_invoker.go b/cluster/cluster/failback/cluster_invoker.go
index d9382ec..6d55ae4 100644
--- a/cluster/cluster/failback/cluster_invoker.go
+++ b/cluster/cluster/failback/cluster_invoker.go
@@ -58,16 +58,16 @@
invoker := &clusterInvoker{
ClusterInvoker: base.NewClusterInvoker(directory),
}
- retriesConfig := invoker.GetURL().GetParam(constant.RetriesKey, constant.DEFAULT_FAILBACK_TIMES)
+ retriesConfig := invoker.GetURL().GetParam(constant.RetriesKey, constant.DefaultFailbackTimes)
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
+ retries = constant.DefaultFailbackTimesInt
}
- failbackTasksConfig := invoker.GetURL().GetParamInt(constant.FAIL_BACK_TASKS_KEY, constant.DEFAULT_FAILBACK_TASKS)
+ failbackTasksConfig := invoker.GetURL().GetParamInt(constant.FailBackTasksKey, constant.DefaultFailbackTasks)
if failbackTasksConfig <= 0 {
- failbackTasksConfig = constant.DEFAULT_FAILBACK_TASKS
+ failbackTasksConfig = constant.DefaultFailbackTasks
}
invoker.maxRetries = int64(retries)
invoker.failbackTasks = failbackTasksConfig
@@ -141,7 +141,7 @@
// Get the service loadbalance config
url := invokers[0].GetURL()
- lb := url.GetParam(constant.LoadbalanceKey, constant.DEFAULT_LOADBALANCE)
+ lb := url.GetParam(constant.LoadbalanceKey, constant.DefaultLoadbalance)
// Get the service method loadbalance config if have
methodName := invocation.MethodName()
if v := url.GetMethodParam(methodName, constant.LoadbalanceKey, ""); v != "" {
diff --git a/cluster/cluster/failback/cluster_test.go b/cluster/cluster/failback/cluster_test.go
index b43d196..45d02d7 100644
--- a/cluster/cluster/failback/cluster_test.go
+++ b/cluster/cluster/failback/cluster_test.go
@@ -46,7 +46,7 @@
)
var failbackUrl, _ = common.NewURL(
- fmt.Sprintf("dubbo://%s:%d/com.ikurento.user.UserProvider", constant.LOCAL_HOST_VALUE, constant.DEFAULT_PORT))
+ fmt.Sprintf("dubbo://%s:%d/com.ikurento.user.UserProvider", constant.LocalHostValue, constant.DefaultPort))
// registerFailback register failbackCluster to cluster extension.
func registerFailback(invoker *mock.MockInvoker) protocol.Invoker {
diff --git a/cluster/cluster/failfast/cluster_test.go b/cluster/cluster/failfast/cluster_test.go
index a739dac..b19ca47 100644
--- a/cluster/cluster/failfast/cluster_test.go
+++ b/cluster/cluster/failfast/cluster_test.go
@@ -44,7 +44,7 @@
)
var failfastUrl, _ = common.NewURL(
- fmt.Sprintf("dubbo://%s:%d/com.ikurento.user.UserProvider", constant.LOCAL_HOST_VALUE, constant.DEFAULT_PORT))
+ fmt.Sprintf("dubbo://%s:%d/com.ikurento.user.UserProvider", constant.LocalHostValue, constant.DefaultPort))
// registerFailfast register failfastCluster to cluster extension.
func registerFailfast(invoker *mock.MockInvoker) protocol.Invoker {
diff --git a/cluster/cluster/failover/cluster_invoker.go b/cluster/cluster/failover/cluster_invoker.go
index 4c33000..b3a2821 100644
--- a/cluster/cluster/failover/cluster_invoker.go
+++ b/cluster/cluster/failover/cluster_invoker.go
@@ -111,12 +111,12 @@
func getRetries(invokers []protocol.Invoker, methodName string) int {
if len(invokers) <= 0 {
- return constant.DEFAULT_RETRIES_INT
+ return constant.DefaultRetriesInt
}
url := invokers[0].GetURL()
// get reties
- retriesConfig := url.GetParam(constant.RetriesKey, constant.DEFAULT_RETRIES)
+ retriesConfig := url.GetParam(constant.RetriesKey, constant.DefaultRetries)
// Get the service method loadbalance config if have
if v := url.GetMethodParam(methodName, constant.RetriesKey, ""); len(v) != 0 {
retriesConfig = v
@@ -125,7 +125,7 @@
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 retries configuration instead.")
- retries = constant.DEFAULT_RETRIES_INT
+ retries = constant.DefaultRetriesInt
}
if retries > len(invokers) {
diff --git a/cluster/cluster/failsafe/cluster_invoker.go b/cluster/cluster/failsafe/cluster_invoker.go
index c714443..c129e43 100644
--- a/cluster/cluster/failsafe/cluster_invoker.go
+++ b/cluster/cluster/failsafe/cluster_invoker.go
@@ -58,7 +58,7 @@
url := invokers[0].GetURL()
methodName := invocation.MethodName()
// Get the service loadbalance config
- lb := url.GetParam(constant.LoadbalanceKey, constant.DEFAULT_LOADBALANCE)
+ lb := url.GetParam(constant.LoadbalanceKey, constant.DefaultLoadbalance)
// Get the service method loadbalance config if have
if v := url.GetMethodParam(methodName, constant.LoadbalanceKey, ""); v != "" {
lb = v
diff --git a/cluster/cluster/failsafe/cluster_test.go b/cluster/cluster/failsafe/cluster_test.go
index 275995a..7ad4f9f 100644
--- a/cluster/cluster/failsafe/cluster_test.go
+++ b/cluster/cluster/failsafe/cluster_test.go
@@ -44,7 +44,7 @@
)
var failsafeUrl, _ = common.NewURL(
- fmt.Sprintf("dubbo://%s:%d/com.ikurento.user.UserProvider", constant.LOCAL_HOST_VALUE, constant.DEFAULT_PORT))
+ fmt.Sprintf("dubbo://%s:%d/com.ikurento.user.UserProvider", constant.LocalHostValue, constant.DefaultPort))
// registerFailsafe register failsafeCluster to cluster extension.
func registerFailsafe(invoker *mock.MockInvoker) protocol.Invoker {
diff --git a/cluster/cluster/forking/cluster_invoker.go b/cluster/cluster/forking/cluster_invoker.go
index 8cda8b5..0c06db2 100644
--- a/cluster/cluster/forking/cluster_invoker.go
+++ b/cluster/cluster/forking/cluster_invoker.go
@@ -56,8 +56,8 @@
}
var selected []protocol.Invoker
- forks := invoker.GetURL().GetParamByIntValue(constant.FORKS_KEY, constant.DEFAULT_FORKS)
- timeouts := invoker.GetURL().GetParamInt(constant.TimeoutKey, constant.DEFAULT_TIMEOUT)
+ forks := invoker.GetURL().GetParamByIntValue(constant.ForksKey, constant.DefaultForks)
+ timeouts := invoker.GetURL().GetParamInt(constant.TimeoutKey, constant.DefaultTimeout)
if forks < 0 || forks > len(invokers) {
selected = invokers
} else {
diff --git a/cluster/cluster/forking/cluster_test.go b/cluster/cluster/forking/cluster_test.go
index 78412bb..f85c287 100644
--- a/cluster/cluster/forking/cluster_test.go
+++ b/cluster/cluster/forking/cluster_test.go
@@ -45,7 +45,7 @@
)
var forkingUrl, _ = common.NewURL(
- fmt.Sprintf("dubbo://%s:%d/com.ikurento.user.UserProvider", constant.LOCAL_HOST_VALUE, constant.DEFAULT_PORT))
+ fmt.Sprintf("dubbo://%s:%d/com.ikurento.user.UserProvider", constant.LocalHostValue, constant.DefaultPort))
func registerForking(mockInvokers ...*mock.MockInvoker) protocol.Invoker {
extension.SetLoadbalance(constant.LoadBalanceKeyRoundRobin, roundrobin.NewLoadBalance)
@@ -71,8 +71,8 @@
invokers := make([]*mock.MockInvoker, 0)
mockResult := &protocol.RPCResult{Rest: clusterpkg.Rest{Tried: 0, Success: true}}
- forkingUrl.AddParam(constant.FORKS_KEY, strconv.Itoa(3))
- // forkingUrl.AddParam(constant.TimeoutKey, strconv.Itoa(constant.DEFAULT_TIMEOUT))
+ forkingUrl.AddParam(constant.ForksKey, strconv.Itoa(3))
+ // forkingUrl.AddParam(constant.TimeoutKey, strconv.Itoa(constant.DefaultTimeout))
var wg sync.WaitGroup
wg.Add(2)
@@ -101,7 +101,7 @@
invokers := make([]*mock.MockInvoker, 0)
mockResult := &protocol.RPCResult{Rest: clusterpkg.Rest{Tried: 0, Success: true}}
- forkingUrl.AddParam(constant.FORKS_KEY, strconv.Itoa(3))
+ forkingUrl.AddParam(constant.ForksKey, strconv.Itoa(3))
var wg sync.WaitGroup
wg.Add(2)
@@ -132,7 +132,7 @@
invokers := make([]*mock.MockInvoker, 0)
mockResult := &protocol.RPCResult{Rest: clusterpkg.Rest{Tried: 0, Success: true}}
- forkingUrl.AddParam(constant.FORKS_KEY, strconv.Itoa(3))
+ forkingUrl.AddParam(constant.ForksKey, strconv.Itoa(3))
var wg sync.WaitGroup
wg.Add(2)
diff --git a/cluster/cluster/zoneaware/cluster_interceptor.go b/cluster/cluster/zoneaware/cluster_interceptor.go
index eabe4e5..d71f2ec 100644
--- a/cluster/cluster/zoneaware/cluster_interceptor.go
+++ b/cluster/cluster/zoneaware/cluster_interceptor.go
@@ -31,7 +31,7 @@
}
func (z *interceptor) Invoke(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result {
- key := constant.REGISTRY_KEY + "." + constant.ZONE_FORCE_KEY
+ key := constant.RegistryKey + "." + constant.ZoneForceKey
force := ctx.Value(key)
if force != nil {
diff --git a/cluster/cluster/zoneaware/cluster_invoker.go b/cluster/cluster/zoneaware/cluster_invoker.go
index d6a72d1..420aaa7 100644
--- a/cluster/cluster/zoneaware/cluster_invoker.go
+++ b/cluster/cluster/zoneaware/cluster_invoker.go
@@ -57,14 +57,14 @@
// First, pick the invoker (XXXClusterInvoker) that comes from the local registry, distinguish by a 'preferred' key.
for _, invoker := range invokers {
- key := constant.REGISTRY_KEY + "." + constant.PREFERRED_KEY
+ key := constant.RegistryKey + "." + constant.PreferredKey
if invoker.IsAvailable() && matchParam("true", key, "false", invoker) {
return invoker.Invoke(ctx, invocation)
}
}
// providers in the registry with the same zone
- key := constant.REGISTRY_KEY + "." + constant.ZONE_KEY
+ key := constant.RegistryKey + "." + constant.ZoneKey
zone := invocation.AttachmentsByKey(key, "")
if "" != zone {
for _, invoker := range invokers {
@@ -73,7 +73,7 @@
}
}
- force := invocation.AttachmentsByKey(constant.REGISTRY_KEY+"."+constant.ZONE_FORCE_KEY, "")
+ force := invocation.AttachmentsByKey(constant.RegistryKey+"."+constant.ZoneForceKey, "")
if "true" == force {
return &protocol.RPCResult{
Err: fmt.Errorf("no registry instance in zone or "+
diff --git a/cluster/cluster/zoneaware/cluster_invoker_test.go b/cluster/cluster/zoneaware/cluster_invoker_test.go
index 084035b..edc9af0 100644
--- a/cluster/cluster/zoneaware/cluster_invoker_test.go
+++ b/cluster/cluster/zoneaware/cluster_invoker_test.go
@@ -48,7 +48,7 @@
// defer ctrl.Finish()
mockResult := &protocol.RPCResult{
- Attrs: map[string]interface{}{constant.PREFERRED_KEY: "true"},
+ Attrs: map[string]interface{}{constant.PreferredKey: "true"},
Rest: clusterpkg.Rest{Tried: 0, Success: true},
}
@@ -59,7 +59,7 @@
invoker.EXPECT().IsAvailable().Return(true).AnyTimes()
invoker.EXPECT().GetUrl().Return(url).AnyTimes()
if 0 == i {
- url.SetParam(constant.REGISTRY_KEY+"."+constant.PREFERRED_KEY, "true")
+ url.SetParam(constant.RegistryKey+"."+constant.PreferredKey, "true")
invoker.EXPECT().Invoke(gomock.Any()).DoAndReturn(
func(invocation protocol.Invocation) protocol.Result {
return mockResult
@@ -100,22 +100,22 @@
invoker := mock.NewMockInvoker(ctrl)
invoker.EXPECT().IsAvailable().Return(true).AnyTimes()
invoker.EXPECT().GetUrl().Return(url).AnyTimes()
- url.SetParam(constant.REGISTRY_KEY+"."+constant.REGISTRY_LABEL_KEY, "true")
+ url.SetParam(constant.RegistryKey+"."+constant.RegistryLabelKey, "true")
if 1 == i {
- url.SetParam(constant.REGISTRY_KEY+"."+constant.WEIGHT_KEY, w1)
+ url.SetParam(constant.RegistryKey+"."+constant.WeightKey, w1)
invoker.EXPECT().Invoke(gomock.Any()).DoAndReturn(
func(invocation protocol.Invocation) protocol.Result {
return &protocol.RPCResult{
- Attrs: map[string]interface{}{constant.WEIGHT_KEY: w1},
+ Attrs: map[string]interface{}{constant.WeightKey: w1},
Rest: clusterpkg.Rest{Tried: 0, Success: true},
}
}).MaxTimes(100)
} else {
- url.SetParam(constant.REGISTRY_KEY+"."+constant.WEIGHT_KEY, w2)
+ url.SetParam(constant.RegistryKey+"."+constant.WeightKey, w2)
invoker.EXPECT().Invoke(gomock.Any()).DoAndReturn(
func(invocation protocol.Invocation) protocol.Result {
return &protocol.RPCResult{
- Attrs: map[string]interface{}{constant.WEIGHT_KEY: w2},
+ Attrs: map[string]interface{}{constant.WeightKey: w2},
Rest: clusterpkg.Rest{Tried: 0, Success: true},
}
}).MaxTimes(100)
@@ -131,10 +131,10 @@
loop := 50
for i := 0; i < loop; i++ {
result := clusterInvoker.Invoke(context.Background(), &invocation.RPCInvocation{})
- if w2 == result.Attachment(constant.WEIGHT_KEY, "0") {
+ if w2 == result.Attachment(constant.WeightKey, "0") {
w2Count++
}
- if w1 == result.Attachment(constant.WEIGHT_KEY, "0") {
+ if w1 == result.Attachment(constant.WeightKey, "0") {
w1Count++
}
assert.NoError(t, result.Error())
@@ -155,7 +155,7 @@
for i := 0; i < 2; i++ {
zoneValue := zoneArray[i]
url, _ := common.NewURL(fmt.Sprintf("dubbo://192.168.1.%v:20000/com.ikurento.user.UserProvider", i))
- url.SetParam(constant.REGISTRY_KEY+"."+constant.ZONE_KEY, zoneValue)
+ url.SetParam(constant.RegistryKey+"."+constant.ZoneKey, zoneValue)
invoker := mock.NewMockInvoker(ctrl)
invoker.EXPECT().IsAvailable().Return(true).AnyTimes()
@@ -163,7 +163,7 @@
invoker.EXPECT().Invoke(gomock.Any()).DoAndReturn(
func(invocation protocol.Invocation) protocol.Result {
return &protocol.RPCResult{
- Attrs: map[string]interface{}{constant.ZONE_KEY: zoneValue},
+ Attrs: map[string]interface{}{constant.ZoneKey: zoneValue},
Rest: clusterpkg.Rest{Tried: 0, Success: true},
}
})
@@ -177,11 +177,11 @@
inv := &invocation.RPCInvocation{}
// zone hangzhou
hz := zoneArray[0]
- inv.SetAttachments(constant.REGISTRY_KEY+"."+constant.ZONE_KEY, hz)
+ inv.SetAttachments(constant.RegistryKey+"."+constant.ZoneKey, hz)
result := clusterInvoker.Invoke(context.Background(), inv)
- assert.Equal(t, hz, result.Attachment(constant.ZONE_KEY, ""))
+ assert.Equal(t, hz, result.Attachment(constant.ZoneKey, ""))
}
func TestZoneWareInvokerWithZoneForceFail(t *testing.T) {
@@ -206,9 +206,9 @@
inv := &invocation.RPCInvocation{}
// zone hangzhou
- inv.SetAttachments(constant.REGISTRY_KEY+"."+constant.ZONE_KEY, "hangzhou")
+ inv.SetAttachments(constant.RegistryKey+"."+constant.ZoneKey, "hangzhou")
// zone force
- inv.SetAttachments(constant.REGISTRY_KEY+"."+constant.ZONE_FORCE_KEY, "true")
+ inv.SetAttachments(constant.RegistryKey+"."+constant.ZoneForceKey, "true")
result := clusterInvoker.Invoke(context.Background(), inv)
diff --git a/cluster/cluster_impl/import.go b/cluster/cluster_impl/import.go
index a7b16b4..68908ab 100644
--- a/cluster/cluster_impl/import.go
+++ b/cluster/cluster_impl/import.go
@@ -30,5 +30,3 @@
_ "dubbo.apache.org/dubbo-go/v3/cluster/cluster/forking"
_ "dubbo.apache.org/dubbo-go/v3/cluster/cluster/zoneaware"
)
-
-func init() {}
diff --git a/cluster/directory/base/directory_test.go b/cluster/directory/base/directory_test.go
index 731f042..b4feb44 100644
--- a/cluster/directory/base/directory_test.go
+++ b/cluster/directory/base/directory_test.go
@@ -35,8 +35,8 @@
var (
url, _ = common.NewURL(
- fmt.Sprintf("dubbo://%s:%d/com.ikurento.user.UserProvider", constant.LOCAL_HOST_VALUE, constant.DEFAULT_PORT))
- anyURL, _ = common.NewURL(fmt.Sprintf("condition://%s/com.foo.BarService", constant.ANYHOST_VALUE))
+ fmt.Sprintf("dubbo://%s:%d/com.ikurento.user.UserProvider", constant.LocalHostValue, constant.DefaultPort))
+ anyURL, _ = common.NewURL(fmt.Sprintf("condition://%s/com.foo.BarService", constant.AnyhostValue))
)
func TestNewBaseDirectory(t *testing.T) {
@@ -58,7 +58,7 @@
ru := u
ru.AddParam("rule", rule)
ru.AddParam("force", "true")
- ru.AddParam(constant.ROUTER_KEY, "router")
+ ru.AddParam(constant.RouterKey, "router")
return ru
}
diff --git a/cluster/loadbalance/consistenthashing/loadbalance.go b/cluster/loadbalance/consistenthashing/loadbalance.go
index 965f55d..ece1d15 100644
--- a/cluster/loadbalance/consistenthashing/loadbalance.go
+++ b/cluster/loadbalance/consistenthashing/loadbalance.go
@@ -39,7 +39,7 @@
var (
selectors = make(map[string]*selector)
- re = regexp.MustCompile(constant.COMMA_SPLIT_PATTERN)
+ re = regexp.MustCompile(constant.CommaSplitPattern)
)
func init() {
diff --git a/cluster/loadbalance/leastactive/loadbalance_test.go b/cluster/loadbalance/leastactive/loadbalance_test.go
index 223692b..ede1c5d 100644
--- a/cluster/loadbalance/leastactive/loadbalance_test.go
+++ b/cluster/loadbalance/leastactive/loadbalance_test.go
@@ -38,7 +38,7 @@
var invokers []protocol.Invoker
- url, _ := common.NewURL(fmt.Sprintf("dubbo://%s:%d/org.apache.demo.HelloService", constant.LOCAL_HOST_VALUE, constant.DEFAULT_PORT))
+ url, _ := common.NewURL(fmt.Sprintf("dubbo://%s:%d/org.apache.demo.HelloService", constant.LocalHostValue, constant.DefaultPort))
invokers = append(invokers, protocol.NewBaseInvoker(url))
i := loadBalance.Select(invokers, &invocation.RPCInvocation{})
assert.True(t, i.GetURL().URLEqual(url))
diff --git a/cluster/loadbalance/random/loadbalance_test.go b/cluster/loadbalance/random/loadbalance_test.go
index 37ad264..79ecbc1 100644
--- a/cluster/loadbalance/random/loadbalance_test.go
+++ b/cluster/loadbalance/random/loadbalance_test.go
@@ -69,7 +69,7 @@
}
urlParams := url.Values{}
- urlParams.Set("methods.test."+constant.WEIGHT_KEY, "10000000000000")
+ urlParams.Set("methods.test."+constant.WeightKey, "10000000000000")
urll, _ := common.NewURL(tmpUrl, common.WithParams(urlParams))
invokers = append(invokers, protocol.NewBaseInvoker(urll))
ivc := invocation.NewRPCInvocationWithOptions(invocation.WithMethodName("test"))
@@ -101,7 +101,7 @@
}
urlParams := url.Values{}
- urlParams.Set(constant.REMOTE_TIMESTAMP_KEY, strconv.FormatInt(time.Now().Add(time.Minute*(-9)).Unix(), 10))
+ urlParams.Set(constant.RemoteTimestampKey, strconv.FormatInt(time.Now().Add(time.Minute*(-9)).Unix(), 10))
urll, _ := common.NewURL(tmpUrl, common.WithParams(urlParams))
invokers = append(invokers, protocol.NewBaseInvoker(urll))
ivc := invocation.NewRPCInvocationWithOptions(invocation.WithMethodName("test"))
diff --git a/cluster/loadbalance/roundrobin/loadbalance_test.go b/cluster/loadbalance/roundrobin/loadbalance_test.go
index fea5485..00fd592 100644
--- a/cluster/loadbalance/roundrobin/loadbalance_test.go
+++ b/cluster/loadbalance/roundrobin/loadbalance_test.go
@@ -40,7 +40,7 @@
var invokers []protocol.Invoker
url, _ := common.NewURL(fmt.Sprintf("dubbo://%s:%d/org.apache.demo.HelloService",
- constant.LOCAL_HOST_VALUE, constant.DEFAULT_PORT))
+ constant.LocalHostValue, constant.DefaultPort))
invokers = append(invokers, protocol.NewBaseInvoker(url))
i := loadBalance.Select(invokers, &invocation.RPCInvocation{})
assert.True(t, i.GetURL().URLEqual(url))
diff --git a/cluster/loadbalance/util.go b/cluster/loadbalance/util.go
index 3cc49e1..4726c8d 100644
--- a/cluster/loadbalance/util.go
+++ b/cluster/loadbalance/util.go
@@ -31,18 +31,18 @@
var weight int64
url := invoker.GetURL()
// Multiple registry scenario, load balance among multiple registries.
- isRegIvk := url.GetParamBool(constant.REGISTRY_KEY+"."+constant.REGISTRY_LABEL_KEY, false)
+ isRegIvk := url.GetParamBool(constant.RegistryKey+"."+constant.RegistryLabelKey, false)
if isRegIvk {
- weight = url.GetParamInt(constant.REGISTRY_KEY+"."+constant.WEIGHT_KEY, constant.DEFAULT_WEIGHT)
+ weight = url.GetParamInt(constant.RegistryKey+"."+constant.WeightKey, constant.DefaultWeight)
} else {
- weight = url.GetMethodParamInt64(invocation.MethodName(), constant.WEIGHT_KEY, constant.DEFAULT_WEIGHT)
+ weight = url.GetMethodParamInt64(invocation.MethodName(), constant.WeightKey, constant.DefaultWeight)
if weight > 0 {
// get service register time an do warm up time
now := time.Now().Unix()
- timestamp := url.GetParamInt(constant.REMOTE_TIMESTAMP_KEY, now)
+ timestamp := url.GetParamInt(constant.RemoteTimestampKey, now)
if uptime := now - timestamp; uptime > 0 {
- warmup := url.GetParamInt(constant.WARMUP_KEY, constant.DEFAULT_WARMUP)
+ warmup := url.GetParamInt(constant.WarmupKey, constant.DefaultWarmup)
if uptime < warmup {
if ww := float64(uptime) / float64(warmup) / float64(weight); ww < 1 {
weight = 1
diff --git a/cluster/router/chain/chain.go b/cluster/router/chain/chain.go
index e366a2a..cc4ea5f 100644
--- a/cluster/router/chain/chain.go
+++ b/cluster/router/chain/chain.go
@@ -113,8 +113,10 @@
for key, routerFactory := range routerFactories {
r, err := routerFactory().NewPriorityRouter()
- if r == nil || err != nil {
- logger.Errorf("router chain build router fail! routerFactories key:%s error:%v", key, err)
+ if err != nil {
+ logger.Errorf("Build router chain failed with routerFactories key:%s and error:%v", key, err)
+ continue
+ } else if r == nil {
continue
}
routers = append(routers, r)
diff --git a/cluster/router/v3router/judger/attachment_match_judger.go b/cluster/router/v3router/judger/attachment_match_judger.go
index 31f46e0..d283739 100644
--- a/cluster/router/v3router/judger/attachment_match_judger.go
+++ b/cluster/router/v3router/judger/attachment_match_judger.go
@@ -27,13 +27,13 @@
}
// nolint
-func (amj *AttachmentMatchJudger) Judge(invocation protocol.Invocation) bool {
+func (j *AttachmentMatchJudger) Judge(invocation protocol.Invocation) bool {
invAttaMap := invocation.Attachments()
- if amj.EagleeyeContext != nil && !judge(amj.EagleeyeContext, invAttaMap) {
+ if j.EagleeyeContext != nil && !judge(j.EagleeyeContext, invAttaMap) {
return false
}
- return amj.DubboContext == nil || judge(amj.DubboContext, invAttaMap)
+ return j.DubboContext == nil || judge(j.DubboContext, invAttaMap)
}
func judge(condition map[string]*config.StringMatch, invAttaMap map[string]interface{}) bool {
diff --git a/cluster/router/v3router/judger/bool_match_judger.go b/cluster/router/v3router/judger/bool_match_judger.go
index 5c4bb46..a49a6b6 100644
--- a/cluster/router/v3router/judger/bool_match_judger.go
+++ b/cluster/router/v3router/judger/bool_match_judger.go
@@ -27,8 +27,8 @@
}
// nolint
-func (lsmj *BoolMatchJudger) Judge(input bool) bool {
- return input == lsmj.Exact
+func (j *BoolMatchJudger) Judge(input bool) bool {
+ return input == j.Exact
}
// nolint
diff --git a/cluster/router/v3router/judger/double_match_judger.go b/cluster/router/v3router/judger/double_match_judger.go
index d5ec384..c143fba 100644
--- a/cluster/router/v3router/judger/double_match_judger.go
+++ b/cluster/router/v3router/judger/double_match_judger.go
@@ -27,15 +27,15 @@
}
// nolint
-func (dmj *DoubleMatchJudger) Judge(input float64) bool {
- if dmj.Exact != 0 {
- return input == dmj.Exact
+func (j *DoubleMatchJudger) Judge(input float64) bool {
+ if j.Exact != 0 {
+ return input == j.Exact
}
- if dmj.Range != nil {
- return newDoubleRangeMatchJudger(dmj.Range).Judge(input)
+ if j.Range != nil {
+ return newDoubleRangeMatchJudger(j.Range).Judge(input)
}
// todo mod match ??
- //if dmj.Mode != 0 {
+ //if j.Mode != 0 {
//
//}
return true
diff --git a/cluster/router/v3router/judger/double_range_match_judger.go b/cluster/router/v3router/judger/double_range_match_judger.go
index 8897fc3..3e14978 100644
--- a/cluster/router/v3router/judger/double_range_match_judger.go
+++ b/cluster/router/v3router/judger/double_range_match_judger.go
@@ -27,8 +27,8 @@
}
// nolint
-func (drmj *DoubleRangeMatchJudger) Judge(input float64) bool {
- return input >= drmj.Start && input < drmj.End
+func (j *DoubleRangeMatchJudger) Judge(input float64) bool {
+ return input >= j.Start && input < j.End
}
// nolint
diff --git a/cluster/router/v3router/judger/list_double_match_judger.go b/cluster/router/v3router/judger/list_double_match_judger.go
index b968334..b0d5db6 100644
--- a/cluster/router/v3router/judger/list_double_match_judger.go
+++ b/cluster/router/v3router/judger/list_double_match_judger.go
@@ -27,8 +27,8 @@
}
// nolint
-func (lsmj *ListDoubleMatchJudger) Judge(input float64) bool {
- for _, v := range lsmj.Oneof {
+func (j *ListDoubleMatchJudger) Judge(input float64) bool {
+ for _, v := range j.Oneof {
if newDoubleMatchJudger(v).Judge(input) {
return true
}
diff --git a/cluster/router/v3router/judger/list_string_match_judger.go b/cluster/router/v3router/judger/list_string_match_judger.go
index a1df1e9..c7b66ec 100644
--- a/cluster/router/v3router/judger/list_string_match_judger.go
+++ b/cluster/router/v3router/judger/list_string_match_judger.go
@@ -27,8 +27,8 @@
}
// nolint
-func (lsmj *ListStringMatchJudger) Judge(input string) bool {
- for _, v := range lsmj.Oneof {
+func (j *ListStringMatchJudger) Judge(input string) bool {
+ for _, v := range j.Oneof {
if NewStringMatchJudger(v).Judge(input) {
return true
}
diff --git a/cluster/router/v3router/judger/method_match_judger.go b/cluster/router/v3router/judger/method_match_judger.go
index e069ef9..3225bea 100644
--- a/cluster/router/v3router/judger/method_match_judger.go
+++ b/cluster/router/v3router/judger/method_match_judger.go
@@ -28,22 +28,22 @@
}
// Judge Method Match Judger only judge on
-func (mmj *MethodMatchJudger) Judge(invocation protocol.Invocation) bool {
- if mmj.NameMatch != nil {
- strJudger := NewStringMatchJudger(mmj.NameMatch)
+func (j *MethodMatchJudger) Judge(invocation protocol.Invocation) bool {
+ if j.NameMatch != nil {
+ strJudger := NewStringMatchJudger(j.NameMatch)
if !strJudger.Judge(invocation.MethodName()) {
return false
}
}
// todo now argc Must not be zero, else it will cause unexpected result
- if mmj.Argc != 0 && len(invocation.ParameterValues()) != mmj.Argc {
+ if j.Argc != 0 && len(invocation.ParameterValues()) != j.Argc {
return false
}
- if mmj.Args != nil {
+ if j.Args != nil {
params := invocation.ParameterValues()
- for _, v := range mmj.Args {
+ for _, v := range j.Args {
index := int(v.Index)
if index > len(params) || index < 1 {
return false
@@ -72,11 +72,11 @@
}
}
// todo Argp match judge ??? conflict to args?
- //if mmj.Argp != nil {
+ //if j.Argp != nil {
//
//}
// todo Headers match judge: reserve for triple
- //if mmj.Headers != nil {
+ //if j.Headers != nil {
//
//}
return true
diff --git a/cluster/router/v3router/judger/string_match_judger.go b/cluster/router/v3router/judger/string_match_judger.go
index fae5278..74302d1 100644
--- a/cluster/router/v3router/judger/string_match_judger.go
+++ b/cluster/router/v3router/judger/string_match_judger.go
@@ -32,21 +32,21 @@
}
// nolint
-func (smj *StringMatchJudger) Judge(input string) bool {
- if smj.Exact != "" {
- return input == smj.Exact
+func (j *StringMatchJudger) Judge(input string) bool {
+ if j.Exact != "" {
+ return input == j.Exact
}
- if smj.Prefix != "" {
- return strings.HasPrefix(input, smj.Prefix)
+ if j.Prefix != "" {
+ return strings.HasPrefix(input, j.Prefix)
}
- if smj.Regex != "" {
- ok, err := regexp.MatchString(smj.Regex, input)
+ if j.Regex != "" {
+ ok, err := regexp.MatchString(j.Regex, input)
return ok && err == nil
}
- if smj.NoEmpty != "" {
+ if j.NoEmpty != "" {
return input != ""
}
- if smj.Empty != "" {
+ if j.Empty != "" {
return input == ""
}
return true
diff --git a/cluster/router/v3router/router_chain.go b/cluster/router/v3router/router_chain.go
index 973f98e..8662be2 100644
--- a/cluster/router/v3router/router_chain.go
+++ b/cluster/router/v3router/router_chain.go
@@ -29,6 +29,7 @@
import (
"dubbo.apache.org/dubbo-go/v3/cluster/router"
"dubbo.apache.org/dubbo-go/v3/common"
+ conf "dubbo.apache.org/dubbo-go/v3/common/config"
"dubbo.apache.org/dubbo-go/v3/common/constant"
"dubbo.apache.org/dubbo-go/v3/common/logger"
"dubbo.apache.org/dubbo-go/v3/config"
@@ -48,9 +49,10 @@
// 1. add mesh route listener
r := &RouterChain{}
rootConfig := config.GetRootConfig()
- dynamicConfiguration, err := rootConfig.ConfigCenter.GetDynamicConfiguration()
- if err != nil {
- return nil, err
+ dynamicConfiguration := conf.GetEnvInstance().GetDynamicConfiguration()
+ if dynamicConfiguration == nil {
+ logger.Infof("Config center does not start, please check if the configuration center has been properly configured in dubbogo.yml")
+ return nil, nil
}
dynamicConfiguration.AddListener(rootConfig.Application.Name, r)
diff --git a/cluster/router/v3router/uniform_rule.go b/cluster/router/v3router/uniform_rule.go
index 4dddc35..53f940b 100644
--- a/cluster/router/v3router/uniform_rule.go
+++ b/cluster/router/v3router/uniform_rule.go
@@ -46,8 +46,8 @@
// match read from VirtualServiceRule's Match config
// it judges if this invocation matches the router rule request defined in config one by one
-func (vsr *VirtualServiceRule) match(url *common.URL, invocation protocol.Invocation) bool {
- for _, v := range vsr.routerItem.Match {
+func (r *VirtualServiceRule) match(url *common.URL, invocation protocol.Invocation) bool {
+ for _, v := range r.routerItem.Match {
// method match judge
if v.Method != nil {
methodMatchJudger := judger.NewMethodMatchJudger(v.Method)
@@ -79,9 +79,9 @@
// tryGetSubsetFromRouterOfOneDestination is a recursion function
// try from destination 's header to final fallback destination, when success, it return result destination, else return error
-func (vsr *VirtualServiceRule) tryGetSubsetFromRouterOfOneDestination(desc *config.DubboDestination, invokers []protocol.Invoker) ([]protocol.Invoker, int, error) {
+func (r *VirtualServiceRule) tryGetSubsetFromRouterOfOneDestination(desc *config.DubboDestination, invokers []protocol.Invoker) ([]protocol.Invoker, int, error) {
subSet := desc.Destination.Subset
- labels, ok := vsr.uniformRule.DestinationLabelListMap[subSet]
+ labels, ok := r.uniformRule.DestinationLabelListMap[subSet]
resultInvokers := make([]protocol.Invoker, 0)
if ok {
for _, v := range invokers {
@@ -95,7 +95,7 @@
}
if desc.Destination.Fallback != nil {
- return vsr.tryGetSubsetFromRouterOfOneDestination(desc.Destination.Fallback, invokers)
+ return r.tryGetSubsetFromRouterOfOneDestination(desc.Destination.Fallback, invokers)
}
return nil, 0, perrors.New("No invoker matches and no fallback destination to choose!")
}
@@ -146,10 +146,10 @@
return w.pairs[0].invokerList
}
-func (vsr *VirtualServiceRule) getRuleTargetInvokers(invokers []protocol.Invoker) ([]protocol.Invoker, error) {
+func (r *VirtualServiceRule) getRuleTargetInvokers(invokers []protocol.Invoker) ([]protocol.Invoker, error) {
// weightInvokerPairResult is the collection routerDesc of all destination fields,
weightInvokerPairResult := weightInvokerPairResults{}
- for _, v := range vsr.routerItem.Router {
+ for _, v := range r.routerItem.Router {
// v is one destination 's header e.g.
/*
route:
@@ -176,7 +176,7 @@
host: demo
subset: v6
*/
- invokerListOfOneDest, weight, err := vsr.tryGetSubsetFromRouterOfOneDestination(v, invokers)
+ invokerListOfOneDest, weight, err := r.tryGetSubsetFromRouterOfOneDestination(v, invokers)
if err != nil {
return nil, err
}
diff --git a/common/constant/default.go b/common/constant/default.go
index a9facf9..58784e7 100644
--- a/common/constant/default.go
+++ b/common/constant/default.go
@@ -18,80 +18,79 @@
package constant
const (
- DUBBO = "dubbo"
- PROVIDER_PROTOCOL = "provider"
- // compatible with 2.6.x
- OVERRIDE_PROTOCOL = "override"
- EMPTY_PROTOCOL = "empty"
- ROUTER_PROTOCOL = "router"
+ Dubbo = "dubbo"
+ ProviderProtocol = "provider"
+ // OverrideProtocol is compatible with 2.6.x
+ OverrideProtocol = "override"
+ EmptyProtocol = "empty"
+ RouterProtocol = "router"
)
const (
- DEFAULT_WEIGHT = 100 //
- DEFAULT_WARMUP = 10 * 60 // in java here is 10*60*1000 because of System.currentTimeMillis() is measured in milliseconds & in go time.Unix() is second
+ DefaultWeight = 100 //
+ DefaultWarmup = 10 * 60 // in java here is 10*60*1000 because of System.currentTimeMillis() is measured in milliseconds & in go time.Unix() is second
)
const (
- DEFAULT_LOADBALANCE = "random"
- DEFAULT_RETRIES = "2"
- DEFAULT_RETRIES_INT = 2
- DEFAULT_PROTOCOL = "dubbo"
- DEFAULT_REG_TIMEOUT = "10s"
- DEFAULT_REG_TTL = "15m"
- DEFAULT_CLUSTER = "failover"
- DEFAULT_FAILBACK_TIMES = "3"
- DEFAULT_FAILBACK_TIMES_INT = 3
- DEFAULT_FAILBACK_TASKS = 100
- DEFAULT_REST_CLIENT = "resty"
- DEFAULT_REST_SERVER = "go-restful"
- DEFAULT_PORT = 20000
- DEFAULT_METADATAPORT = 20005
- DEFAULT_SERIALIZATION = HESSIAN2_SERIALIZATION
+ DefaultLoadbalance = "random"
+ DefaultRetries = "2"
+ DefaultRetriesInt = 2
+ DefaultProtocol = "dubbo"
+ DefaultRegTimeout = "10s"
+ DefaultRegTTL = "15m"
+ DefaultCluster = "failover"
+ DefaultFailbackTimes = "3"
+ DefaultFailbackTimesInt = 3
+ DefaultFailbackTasks = 100
+ DefaultRestClient = "resty"
+ DefaultRestServer = "go-restful"
+ DefaultPort = 20000
+ DefaultMetadataport = 20005
)
const (
- DEFAULT_KEY = "default"
- PREFIX_DEFAULT_KEY = "default."
- DEFAULT_SERVICE_FILTERS = EchoFilterKey + "," + MetricsFilterKey + "," + TokenFilterKey + "," + AccessLogFilterKey + "," + TpsLimitFilterKey + "," + GenericServiceFilterKey + "," + ExecuteLimitFilterKey + "," + GracefulShutdownProviderFilterKey
+ DefaultKey = "default"
+ PrefixDefaultKey = "default."
+ DefaultServiceFilters = EchoFilterKey + "," + MetricsFilterKey + "," + TokenFilterKey + "," + AccessLogFilterKey + "," + TpsLimitFilterKey + "," + GenericServiceFilterKey + "," + ExecuteLimitFilterKey + "," + GracefulShutdownProviderFilterKey
DefaultReferenceFilters = GracefulShutdownConsumerFilterKey
GenericReferenceFilters = GenericFilterKey
- GENERIC = "$invoke"
- ECHO = "$echo"
+ Generic = "$invoke"
+ Echo = "$echo"
)
const (
- ANY_VALUE = "*"
- ANYHOST_VALUE = "0.0.0.0"
- LOCAL_HOST_VALUE = "192.168.1.1"
- REMOVE_VALUE_PREFIX = "-"
+ AnyValue = "*"
+ AnyhostValue = "0.0.0.0"
+ LocalHostValue = "192.168.1.1"
+ RemoveValuePrefix = "-"
)
const (
- CONFIGURATORS_CATEGORY = "configurators"
- ROUTER_CATEGORY = "category"
- DEFAULT_CATEGORY = PROVIDER_CATEGORY
- DYNAMIC_CONFIGURATORS_CATEGORY = "dynamicconfigurators"
- APP_DYNAMIC_CONFIGURATORS_CATEGORY = "appdynamicconfigurators"
- PROVIDER_CATEGORY = "providers"
- CONSUMER_CATEGORY = "consumers"
+ ConfiguratorsCategory = "configurators"
+ RouterCategory = "category"
+ DefaultCategory = ProviderCategory
+ DynamicConfiguratorsCategory = "dynamicconfigurators"
+ AppDynamicConfiguratorsCategory = "appdynamicconfigurators"
+ ProviderCategory = "providers"
+ ConsumerCategory = "consumers"
)
const (
- COMMA_SPLIT_PATTERN = "\\s*[,]+\\s*"
+ CommaSplitPattern = "\\s*[,]+\\s*"
)
const (
- SIMPLE_METADATA_SERVICE_NAME = "MetadataService"
- DEFAULT_REVISION = "N/A"
+ SimpleMetadataServiceName = "MetadataService"
+ DefaultRevision = "N/A"
)
const (
- SERVICE_DISCOVERY_DEFAULT_GROUP = "DEFAULT_GROUP"
+ ServiceDiscoveryDefaultGroup = "DEFAULT_GROUP"
)
const (
- DEFAULT_PROVIDER_CONF_FILE_PATH = "../profiles/dev/server.yml"
- DEFAULT_CONSUMER_CONF_FILE_PATH = "../profiles/dev/client.yml"
- DEFAULT_LOG_CONF_FILE_PATH = "../profiles/dev/log.yml"
- DEFAULT_ROUTER_CONF_FILE_PATH = "../profiles/dev/router.yml"
+ DefaultProviderConfFilePath = "../profiles/dev/server.yml"
+ DefaultConsumerConfFilePath = "../profiles/dev/client.yml"
+ DefaultLogConfFilePath = "../profiles/dev/log.yml"
+ DefaultRouterConfFilePath = "../profiles/dev/router.yml"
)
diff --git a/common/constant/env.go b/common/constant/env.go
index c2fb18b..9e20a6d 100644
--- a/common/constant/env.go
+++ b/common/constant/env.go
@@ -19,8 +19,8 @@
// nolint
const (
- // CONFIG_FILE_ENV_KEY is key of environment variable dubbogo configure file path
- CONFIG_FILE_ENV_KEY = "DUBBO_GO_CONFIG_PATH"
- // APP_LOG_CONF_FILE ...
- APP_LOG_CONF_FILE = "APP_LOG_CONF_FILE"
+ // ConfigFileEnvKey is key of environment variable dubbogo configure file path
+ ConfigFileEnvKey = "DUBBO_GO_CONFIG_PATH"
+ // AppLogConfFile ...
+ AppLogConfFile = "AppLogConfFile"
)
diff --git a/common/constant/key.go b/common/constant/key.go
index 5b2bdef..8d3c2e8 100644
--- a/common/constant/key.go
+++ b/common/constant/key.go
@@ -24,42 +24,40 @@
)
const (
- GroupKey = "group"
- VersionKey = "version"
- InterfaceKey = "interface"
- MESSAGE_SIZE_KEY = "message_size"
- PATH_KEY = "path"
- SERVICE_KEY = "service"
- METHODS_KEY = "methods"
- TimeoutKey = "timeout"
- CATEGORY_KEY = "category"
- CHECK_KEY = "check"
- ENABLED_KEY = "enabled"
- SideKey = "side"
- OVERRIDE_PROVIDERS_KEY = "providerAddresses"
- BeanNameKey = "bean.name"
- GenericKey = "generic"
- CLASSIFIER_KEY = "classifier"
- TOKEN_KEY = "token"
- LOCAL_ADDR = "local-addr"
- REMOTE_ADDR = "remote-addr"
- DEFAULT_REMOTING_TIMEOUT = 3000
- ReleaseKey = "release"
- ANYHOST_KEY = "anyhost"
- PORT_KEY = "port"
- PROTOCOL_KEY = "protocol"
- PATH_SEPARATOR = "/"
- COMMA_SEPARATOR = ","
- // DUBBO_KEY = "dubbo"
- SSL_ENABLED_KEY = "ssl-enabled"
- // PARAMS_TYPE_Key key used in pass through invoker factory, to define param type
- PARAMS_TYPE_Key = "parameter-type-names"
- DEFAULT_Key = "default"
- MetadatatypeKey = "metadata-type"
+ GroupKey = "group"
+ VersionKey = "version"
+ InterfaceKey = "interface"
+ MessageSizeKey = "message_size"
+ PathKey = "path"
+ ServiceKey = "service"
+ MethodsKey = "methods"
+ TimeoutKey = "timeout"
+ CategoryKey = "category"
+ CheckKey = "check"
+ EnabledKey = "enabled"
+ SideKey = "side"
+ OverrideProvidersKey = "providerAddresses"
+ BeanNameKey = "bean.name"
+ GenericKey = "generic"
+ ClassifierKey = "classifier"
+ TokenKey = "token"
+ LocalAddr = "local-addr"
+ RemoteAddr = "remote-addr"
+ DefaultRemotingTimeout = 3000
+ ReleaseKey = "release"
+ AnyhostKey = "anyhost"
+ PortKey = "port"
+ ProtocolKey = "protocol"
+ PathSeparator = "/"
+ CommaSeparator = ","
+ SslEnabledKey = "ssl-enabled"
+ // ParamsTypeKey key used in pass through invoker factory, to define param type
+ ParamsTypeKey = "parameter-type-names"
+ MetadataTypeKey = "metadata-type"
)
const (
- SERVICE_FILTER_KEY = "service.filter"
+ ServiceFilterKey = "service.filter"
ReferenceFilterKey = "reference.filter"
)
@@ -88,95 +86,95 @@
)
const (
- TimestampKey = "timestamp"
- REMOTE_TIMESTAMP_KEY = "remote.timestamp"
- ClusterKey = "cluster"
- LoadbalanceKey = "loadbalance"
- WEIGHT_KEY = "weight"
- WARMUP_KEY = "warmup"
- RetriesKey = "retries"
- StickyKey = "sticky"
- BEAN_NAME = "bean.name"
- FAIL_BACK_TASKS_KEY = "failbacktasks"
- FORKS_KEY = "forks"
- DEFAULT_FORKS = 2
- DEFAULT_TIMEOUT = 1000
- TPS_LIMITER_KEY = "tps.limiter"
- TPS_REJECTED_EXECUTION_HANDLER_KEY = "tps.limit.rejected.handler"
- TPS_LIMIT_RATE_KEY = "tps.limit.rate"
- DEFAULT_TPS_LIMIT_RATE = "-1"
- TPS_LIMIT_INTERVAL_KEY = "tps.limit.interval"
- DEFAULT_TPS_LIMIT_INTERVAL = "60000"
- TPS_LIMIT_STRATEGY_KEY = "tps.limit.strategy"
- EXECUTE_LIMIT_KEY = "execute.limit"
- DEFAULT_EXECUTE_LIMIT = "-1"
- EXECUTE_REJECTED_EXECUTION_HANDLER_KEY = "execute.limit.rejected.handler"
- SerializationKey = "serialization"
- PID_KEY = "pid"
- SYNC_REPORT_KEY = "sync.report"
- RETRY_PERIOD_KEY = "retry.period"
- RETRY_TIMES_KEY = "retry.times"
- CYCLE_REPORT_KEY = "cycle.report"
- DEFAULT_BLACK_LIST_RECOVER_BLOCK = 16
+ TimestampKey = "timestamp"
+ RemoteTimestampKey = "remote.timestamp"
+ ClusterKey = "cluster"
+ LoadbalanceKey = "loadbalance"
+ WeightKey = "weight"
+ WarmupKey = "warmup"
+ RetriesKey = "retries"
+ StickyKey = "sticky"
+ BeanName = "bean.name"
+ FailBackTasksKey = "failbacktasks"
+ ForksKey = "forks"
+ DefaultForks = 2
+ DefaultTimeout = 1000
+ TPSLimiterKey = "tps.limiter"
+ TPSRejectedExecutionHandlerKey = "tps.limit.rejected.handler"
+ TPSLimitRateKey = "tps.limit.rate"
+ DefaultTPSLimitRate = "-1"
+ TPSLimitIntervalKey = "tps.limit.interval"
+ DefaultTPSLimitInterval = "60000"
+ TPSLimitStrategyKey = "tps.limit.strategy"
+ ExecuteLimitKey = "execute.limit"
+ DefaultExecuteLimit = "-1"
+ ExecuteRejectedExecutionHandlerKey = "execute.limit.rejected.handler"
+ SerializationKey = "serialization"
+ PIDKey = "pid"
+ SyncReportKey = "sync.report"
+ RetryPeriodKey = "retry.period"
+ RetryTimesKey = "retry.times"
+ CycleReportKey = "cycle.report"
+ DefaultBlackListRecoverBlock = 16
)
const (
- DUBBOGO_CTX_KEY = DubboCtxKey("dubbogo-ctx")
+ DubboGoCtxKey = DubboCtxKey("dubbogo-ctx")
)
const (
- REGISTRY_KEY = "registry"
+ RegistryKey = "registry"
RegistryProtocol = "registry"
ServiceRegistryProtocol = "service-discovery-registry"
RoleKey = "registry.role"
- REGISTRY_DEFAULT_KEY = "registry.default"
- REGISTRY_TIMEOUT_KEY = "registry.timeout"
- REGISTRY_LABEL_KEY = "label"
- PREFERRED_KEY = "preferred"
- ZONE_KEY = "zone"
- ZONE_FORCE_KEY = "zone.force"
- REGISTRY_TTL_KEY = "registry.ttl"
- SIMPLIFIED_KEY = "simplified"
- NAMESPACE_KEY = "namespace"
- REGISTRY_GROUP_KEY = "registry.group"
+ RegistryDefaultKey = "registry.default"
+ RegistryTimeoutKey = "registry.timeout"
+ RegistryLabelKey = "label"
+ PreferredKey = "preferred"
+ ZoneKey = "zone"
+ ZoneForceKey = "zone.force"
+ RegistryTTLKey = "registry.ttl"
+ SimplifiedKey = "simplified"
+ NamespaceKey = "namespace"
+ RegistryGroupKey = "registry.group"
)
const (
- ApplicationKey = "application"
- OrganizationKey = "organization"
- NameKey = "name"
- ModuleKey = "module"
- AppVersionKey = "app.version"
- OwnerKey = "owner"
- EnvironmentKey = "environment"
- METHOD_KEY = "method"
- METHOD_KEYS = "methods"
- RULE_KEY = "rule"
- RUNTIME_KEY = "runtime"
- BACKUP_KEY = "backup"
- ROUTERS_CATEGORY = "routers"
- ROUTE_PROTOCOL = "route"
- CONDITION_ROUTE_PROTOCOL = "condition"
- TAG_ROUTE_PROTOCOL = "tag"
- PROVIDERS_CATEGORY = "providers"
- ROUTER_KEY = "router"
- EXPORT_KEY = "export"
+ ApplicationKey = "application"
+ OrganizationKey = "organization"
+ NameKey = "name"
+ ModuleKey = "module"
+ AppVersionKey = "app.version"
+ OwnerKey = "owner"
+ EnvironmentKey = "environment"
+ MethodKey = "method"
+ MethodKeys = "methods"
+ RuleKey = "rule"
+ RuntimeKey = "runtime"
+ BackupKey = "backup"
+ RoutersCategory = "routers"
+ RouteProtocol = "route"
+ ConditionRouteProtocol = "condition"
+ TagRouteProtocol = "tag"
+ ProvidersCategory = "providers"
+ RouterKey = "router"
+ ExportKey = "export"
)
const (
- CONFIG_NAMESPACE_KEY = "namespace"
- CONFIG_GROUP_KEY = "group"
- CONFIG_APP_ID_KEY = "appId"
- CONFIG_CLUSTER_KEY = "cluster"
- CONFIG_TIMEOUT_KEY = "timeout"
- CONFIG_USERNAME_KEY = "username"
- CONFIG_PASSWORD_KEY = "password"
- CONFIG_LOG_DIR_KEY = "logDir"
- CONFIG_VERSION_KEY = "configVersion"
- COMPATIBLE_CONFIG_KEY = "compatible_config"
- CONFIG_SECRET_KEY = "secret"
- CONFIG_BACKUP_CONFIG_KEY = "isBackupConfig"
- CONFIG_BACKUP_CONFIG_PATH_KEY = "backupConfigPath"
+ ConfigNamespaceKey = "namespace"
+ ConfigGroupKey = "group"
+ ConfigAppIDKey = "appId"
+ ConfigClusterKey = "cluster"
+ ConfigTimeoutKey = "timeout"
+ ConfigUsernameKey = "username"
+ ConfigPasswordKey = "password"
+ ConfigLogDirKey = "logDir"
+ ConfigVersionKey = "configVersion"
+ CompatibleConfigKey = "compatible_config"
+ ConfigSecretKey = "secret"
+ ConfigBackupConfigKey = "isBackupConfig"
+ ConfigBackupConfigPathKey = "backupConfigPath"
)
const (
@@ -203,39 +201,39 @@
)
const (
- NACOS_KEY = "nacos"
- NACOS_DEFAULT_ROLETYPE = 3
- NACOS_CACHE_DIR_KEY = "cacheDir"
- NACOS_LOG_DIR_KEY = "logDir"
- NACOS_BEAT_INTERVAL_KEY = "beatInterval"
- NACOS_ENDPOINT = "endpoint"
- NACOS_SERVICE_NAME_SEPARATOR = ":"
- NACOS_CATEGORY_KEY = "category"
- NACOS_PROTOCOL_KEY = "protocol"
- NACOS_PATH_KEY = "path"
- NACOS_NAMESPACE_ID = "namespaceId"
- NACOS_PASSWORD = "password"
- NACOS_USERNAME = "username"
- NACOS_NOT_LOAD_LOCAL_CACHE = "nacos.not.load.cache"
- NACOS_APP_NAME_KEY = "appName"
- NACOS_REGION_ID_KEY = "regionId"
- NACOS_ACCESS_KEY = "access"
- NACOS_SECRET_KEY = "secret"
- NACOS_OPEN_KMS_KEY = "kms"
- NACOS_UPDATE_THREAD_NUM_KEY = "updateThreadNum"
- NACOS_LOG_LEVEL_KEY = "logLevel"
+ NacosKey = "nacos"
+ NacosDefaultRoleType = 3
+ NacosCacheDirKey = "cacheDir"
+ NacosLogDirKey = "logDir"
+ NacosBeatIntervalKey = "beatInterval"
+ NacosEndpoint = "endpoint"
+ NacosServiceNameSeparator = ":"
+ NacosCategoryKey = "category"
+ NacosProtocolKey = "protocol"
+ NacosPathKey = "path"
+ NacosNamespaceID = "namespaceId"
+ NacosPassword = "password"
+ NacosUsername = "username"
+ NacosNotLoadLocalCache = "nacos.not.load.cache"
+ NacosAppNameKey = "appName"
+ NacosRegionIDKey = "regionId"
+ NacosAccessKey = "access"
+ NacosSecretKey = "secret"
+ NacosOpenKmsKey = "kms"
+ NacosUpdateThreadNumKey = "updateThreadNum"
+ NacosLogLevelKey = "logLevel"
)
const (
- FILE_KEY = "file"
+ FileKey = "file"
)
const (
- ZOOKEEPER_KEY = "zookeeper"
+ ZookeeperKey = "zookeeper"
)
const (
- ETCDV3_KEY = "etcdv3"
+ EtcdV3Key = "etcdv3"
)
const (
@@ -244,7 +242,7 @@
)
const (
- TRACING_REMOTE_SPAN_CTX = DubboCtxKey("tracing.remote.span.ctx")
+ TracingRemoteSpanCtx = DubboCtxKey("tracing.remote.span.ctx")
)
// Use for router module
@@ -265,63 +263,63 @@
// Auth filter
const (
// name of service filter
- SERVICE_AUTH_KEY = "auth"
+ ServiceAuthKey = "auth"
// key of authenticator
- AUTHENTICATOR_KEY = "authenticator"
+ AuthenticatorKey = "authenticator"
// name of default authenticator
- DEFAULT_AUTHENTICATOR = "accesskeys"
+ DefaultAuthenticator = "accesskeys"
// name of default url storage
- DEFAULT_ACCESS_KEY_STORAGE = "urlstorage"
+ DefaultAccessKeyStorage = "urlstorage"
// key of storage
- ACCESS_KEY_STORAGE_KEY = "accessKey.storage"
+ AccessKeyStorageKey = "accessKey.storage"
// key of request timestamp
- REQUEST_TIMESTAMP_KEY = "timestamp"
+ RequestTimestampKey = "timestamp"
// key of request signature
- REQUEST_SIGNATURE_KEY = "signature"
+ RequestSignatureKey = "signature"
// AK key
- AK_KEY = "ak"
+ AKKey = "ak"
// signature format
- SIGNATURE_STRING_FORMAT = "%s#%s#%s#%s"
+ SignatureStringFormat = "%s#%s#%s#%s"
// key whether enable signature
- PARAMETER_SIGNATURE_ENABLE_KEY = "param.sign"
+ ParameterSignatureEnableKey = "param.sign"
// consumer
- CONSUMER = "consumer"
+ Consumer = "consumer"
// key of access key id
- ACCESS_KEY_ID_KEY = ".accessKeyId"
+ AccessKeyIDKey = ".accessKeyId"
// key of secret access key
- SECRET_ACCESS_KEY_KEY = ".secretAccessKey"
+ SecretAccessKeyKey = ".secretAccessKey"
)
// metadata report
const (
- METACONFIG_REMOTE = "remote"
- METACONFIG_LOCAL = "local"
- KEY_SEPARATOR = ":"
- DEFAULT_PATH_TAG = "metadata"
- KEY_REVISON_PREFIX = "revision"
+ MetaConfigRemote = "remote"
+ MetaConfigLocal = "local"
+ KeySeparator = ":"
+ DefaultPathTag = "metadata"
+ KeyRevisionPrefix = "revision"
// metadata service
- METADATA_SERVICE_NAME = "org.apache.dubbo.metadata.MetadataService"
+ MetadataServiceName = "org.apache.dubbo.metadata.MetadataService"
)
// service discovery
const (
- SUBSCRIBED_SERVICE_NAMES_KEY = "subscribed-services"
- ProvidedBy = "provided-by"
- EXPORTED_SERVICES_REVISION_PROPERTY_NAME = "dubbo.metadata.revision"
- SUBSCRIBED_SERVICES_REVISION_PROPERTY_NAME = "dubbo.subscribed-services.revision"
- SERVICE_INSTANCE_SELECTOR = "service-instance-selector"
- METADATA_STORAGE_TYPE_PROPERTY_NAME = "dubbo.metadata.storage-type"
- DEFAULT_METADATA_STORAGE_TYPE = "local"
- REMOTE_METADATA_STORAGE_TYPE = "remote"
- SERVICE_INSTANCE_ENDPOINTS = "dubbo.endpoints"
- METADATA_SERVICE_PREFIX = "dubbo.metadata-service."
- METADATA_SERVICE_URL_PARAMS_PROPERTY_NAME = METADATA_SERVICE_PREFIX + "url-params"
- METADATA_SERVICE_URLS_PROPERTY_NAME = METADATA_SERVICE_PREFIX + "urls"
+ SubscribedServiceNamesKey = "subscribed-services"
+ ProvidedBy = "provided-by"
+ ExportedServicesRevisionPropertyName = "dubbo.metadata.revision"
+ SubscribedServicesRevisionPropertyName = "dubbo.subscribed-services.revision"
+ ServiceInstanceSelector = "service-instance-selector"
+ MetadataStorageTypePropertyName = "dubbo.metadata.storage-type"
+ DefaultMetadataStorageType = "local"
+ RemoteMetadataStorageType = "remote"
+ ServiceInstanceEndpoints = "dubbo.endpoints"
+ MetadataServicePrefix = "dubbo.metadata-service."
+ MetadataServiceURLParamsPropertyName = MetadataServicePrefix + "url-params"
+ MetadataServiceURLsPropertyName = MetadataServicePrefix + "urls"
- // SERVICE_DISCOVERY_KEY indicate which service discovery instance will be used
- SERVICE_DISCOVERY_KEY = "service_discovery"
+ // ServiceDiscoveryKey indicate which service discovery instance will be used
+ ServiceDiscoveryKey = "service_discovery"
)
// Generic Filter
diff --git a/common/constant/serialization.go b/common/constant/serialization.go
index 60c51df..620037d 100644
--- a/common/constant/serialization.go
+++ b/common/constant/serialization.go
@@ -18,12 +18,12 @@
package constant
const (
- S_Hessian2 byte = 2
- S_Proto byte = 21
+ SHessian2 byte = 2
+ SProto byte = 21
)
const (
- HESSIAN2_SERIALIZATION = "hessian2"
- PROTOBUF_SERIALIZATION = "protobuf"
- MSGPACK_SERIALIZATION = "msgpack"
+ Hessian2Serialization = "hessian2"
+ ProtobufSerialization = "protobuf"
+ MsgpackSerialization = "msgpack"
)
diff --git a/common/extension/metadata_service.go b/common/extension/metadata_service.go
index 780ad37..486f051 100644
--- a/common/extension/metadata_service.go
+++ b/common/extension/metadata_service.go
@@ -44,7 +44,7 @@
// GetMetadataService will create a local MetadataService instance
func GetLocalMetadataService(key string) (service.MetadataService, error) {
if key == "" {
- key = constant.DEFAULT_KEY
+ key = constant.DefaultKey
}
if creator, ok := localMetadataServiceInsMap[key]; ok {
return creator()
diff --git a/common/extension/metadata_service_exporter.go b/common/extension/metadata_service_exporter.go
index 45e71e2..ab8cff8 100644
--- a/common/extension/metadata_service_exporter.go
+++ b/common/extension/metadata_service_exporter.go
@@ -37,7 +37,7 @@
// GetMetadataServiceExporter will create a MetadataServiceExporter instance
func GetMetadataServiceExporter(key string, s service.MetadataService) exporter.MetadataServiceExporter {
if key == "" {
- key = constant.DEFAULT_KEY
+ key = constant.DefaultKey
}
if creator, ok := metadataServiceExporterInsMap[key]; ok {
return creator(s)
diff --git a/common/extension/metadata_service_proxy_factory.go b/common/extension/metadata_service_proxy_factory.go
index 113b4ba..ecb8fb4 100644
--- a/common/extension/metadata_service_proxy_factory.go
+++ b/common/extension/metadata_service_proxy_factory.go
@@ -39,7 +39,7 @@
// it will panic if the factory with name not found
func GetMetadataServiceProxyFactory(name string) service.MetadataServiceProxyFactory {
if name == "" {
- name = constant.DEFAULT_KEY
+ name = constant.DefaultKey
}
if f, ok := metadataServiceProxyFactoryMap[name]; ok {
return f()
diff --git a/common/logger/logger.go b/common/logger/logger.go
index bc19e46..66ecf4a 100644
--- a/common/logger/logger.go
+++ b/common/logger/logger.go
@@ -79,7 +79,7 @@
EncodeCaller: zapcore.ShortCallerEncoder,
}
config.ZapConfig = &zap.Config{
- Level: zap.NewAtomicLevelAt(zap.DebugLevel),
+ Level: zap.NewAtomicLevelAt(zap.InfoLevel),
Development: false,
Encoding: "console",
EncoderConfig: zapLoggerEncoderConfig,
diff --git a/common/metadata_info.go b/common/metadata_info.go
index 123598a..73670cf 100644
--- a/common/metadata_info.go
+++ b/common/metadata_info.go
@@ -40,12 +40,12 @@
constant.SerializationKey,
constant.ClusterKey,
constant.LoadbalanceKey,
- constant.PATH_KEY,
+ constant.PathKey,
constant.TimeoutKey,
- constant.TOKEN_KEY,
+ constant.TokenKey,
constant.VersionKey,
- constant.WARMUP_KEY,
- constant.WEIGHT_KEY,
+ constant.WarmupKey,
+ constant.WeightKey,
constant.ReleaseKey)
// MetadataInfo the metadata information of instance
@@ -97,7 +97,7 @@
} else {
for _, m := range ms {
// methods are part of candidates
- candidates = append(candidates, sk+constant.KEY_SEPARATOR+m)
+ candidates = append(candidates, sk+constant.KeySeparator+m)
}
}
@@ -201,8 +201,8 @@
// nolint
func (si *ServiceInfo) GetMethods() []string {
- if si.Params[constant.METHODS_KEY] != "" {
- s := si.Params[constant.METHODS_KEY]
+ if si.Params[constant.MethodsKey] != "" {
+ s := si.Params[constant.MethodsKey]
return strings.Split(s, ",")
}
methods := make([]string, 8)
diff --git a/common/proxy/proxy_factory/pass_through.go b/common/proxy/proxy_factory/pass_through.go
index cc854cf..6ad28dc 100644
--- a/common/proxy/proxy_factory/pass_through.go
+++ b/common/proxy/proxy_factory/pass_through.go
@@ -102,7 +102,7 @@
in := make([]reflect.Value, 5)
in = append(in, srv.Rcvr())
in = append(in, reflect.ValueOf(invocation.MethodName()))
- in = append(in, reflect.ValueOf(invocation.Attachment(constant.PARAMS_TYPE_Key)))
+ in = append(in, reflect.ValueOf(invocation.Attachment(constant.ParamsTypeKey)))
in = append(in, reflect.ValueOf(args))
in = append(in, reflect.ValueOf(invocation.Attachments()))
diff --git a/common/url.go b/common/url.go
index 1eda3c8..e65c749 100644
--- a/common/url.go
+++ b/common/url.go
@@ -48,8 +48,8 @@
// dubbo role type constant
const (
- // Consumer is consumer role
- Consumer = iota
+ // CONSUMER is consumer role
+ CONSUMER = iota
// CONFIGURATOR is configurator role
CONFIGURATOR
// ROUTER is router role
@@ -213,7 +213,7 @@
u, _ := uuid.NewV4()
value = u.String()
}
- url.SetParam(constant.TOKEN_KEY, value)
+ url.SetParam(constant.TokenKey, value)
}
}
}
@@ -310,9 +310,9 @@
cKey := tmpC.Key()
urlKey := tmpURL.Key()
- if cGroup == constant.ANY_VALUE {
+ if cGroup == constant.AnyValue {
cKey = strings.Replace(cKey, "group=*", "group="+urlGroup, 1)
- } else if urlGroup == constant.ANY_VALUE {
+ } else if urlGroup == constant.AnyValue {
urlKey = strings.Replace(urlKey, "group=*", "group="+cGroup, 1)
}
@@ -322,21 +322,21 @@
}
// 2. if URL contains enabled key, should be true, or *
- if tmpURL.GetParam(constant.ENABLED_KEY, "true") != "true" && tmpURL.GetParam(constant.ENABLED_KEY, "") != constant.ANY_VALUE {
+ if tmpURL.GetParam(constant.EnabledKey, "true") != "true" && tmpURL.GetParam(constant.EnabledKey, "") != constant.AnyValue {
return false
}
// TODO :may need add interface key any value condition
- return isMatchCategory(tmpURL.GetParam(constant.CATEGORY_KEY, constant.DEFAULT_CATEGORY), tmpC.GetParam(constant.CATEGORY_KEY, constant.DEFAULT_CATEGORY))
+ return isMatchCategory(tmpURL.GetParam(constant.CategoryKey, constant.DefaultCategory), tmpC.GetParam(constant.CategoryKey, constant.DefaultCategory))
}
func isMatchCategory(category1 string, category2 string) bool {
if len(category2) == 0 {
- return category1 == constant.DEFAULT_CATEGORY
- } else if strings.Contains(category2, constant.ANY_VALUE) {
+ return category1 == constant.DefaultCategory
+ } else if strings.Contains(category2, constant.AnyValue) {
return true
- } else if strings.Contains(category2, constant.REMOVE_VALUE_PREFIX) {
- return !strings.Contains(category2, constant.REMOVE_VALUE_PREFIX+category1)
+ } else if strings.Contains(category2, constant.RemoveValuePrefix) {
+ return !strings.Contains(category2, constant.RemoveValuePrefix+category1)
} else {
return strings.Contains(category2, category1)
}
@@ -705,7 +705,7 @@
// remote timestamp
if v := serviceURL.GetParam(constant.TimestampKey, ""); len(v) > 0 {
- params[constant.REMOTE_TIMESTAMP_KEY] = []string{v}
+ params[constant.RemoteTimestampKey] = []string{v}
params[constant.TimestampKey] = []string{referenceURL.GetParam(constant.TimestampKey, "")}
}
diff --git a/common/url_test.go b/common/url_test.go
index 38254ba..66f0003 100644
--- a/common/url_test.go
+++ b/common/url_test.go
@@ -314,7 +314,7 @@
serviceUrlParams.Set("test2", "1")
serviceUrlParams.Set(constant.ClusterKey, "roundrobin")
serviceUrlParams.Set(constant.RetriesKey, "2")
- serviceUrlParams.Set(constant.METHOD_KEYS+".testMethod."+constant.RetriesKey, "2")
+ serviceUrlParams.Set(constant.MethodKeys+".testMethod."+constant.RetriesKey, "2")
referenceUrl, _ := NewURL("mock1://127.0.0.1:1111", WithParams(referenceUrlParams), WithMethods([]string{"testMethod"}))
serviceUrl, _ := NewURL("mock2://127.0.0.1:20000", WithParams(serviceUrlParams))
@@ -323,7 +323,7 @@
assert.Equal(t, "1", mergedUrl.GetParam("test2", ""))
assert.Equal(t, "1", mergedUrl.GetParam("test3", ""))
assert.Equal(t, "1", mergedUrl.GetParam(constant.RetriesKey, ""))
- assert.Equal(t, "2", mergedUrl.GetParam(constant.METHOD_KEYS+".testMethod."+constant.RetriesKey, ""))
+ assert.Equal(t, "2", mergedUrl.GetParam(constant.MethodKeys+".testMethod."+constant.RetriesKey, ""))
}
func TestURLSetParams(t *testing.T) {
@@ -383,7 +383,7 @@
"module=dubbogo+user-info+server&org=ikurento.com&owner=ZX&pid=1447&revision=0.0.1&" +
"side=provider&timeout=3000×tamp=155650979798")
assert.False(t, GetCompareURLEqualFunc()(url1, url2))
- assert.True(t, GetCompareURLEqualFunc()(url1, url2, constant.TimestampKey, constant.REMOTE_TIMESTAMP_KEY))
+ assert.True(t, GetCompareURLEqualFunc()(url1, url2, constant.TimestampKey, constant.RemoteTimestampKey))
// test custom
url1, _ = NewURL("dubbo://127.0.0.1:20000/com.ikurento.user.UserProvider?anyhost=true&" +
@@ -396,10 +396,10 @@
"environment=dev&interface=com.ikurento.user.UserProvider&ip=192.168.56.1&methods=GetUser%2C&" +
"module=dubbogo+user-info+server&org=ikurento.com&owner=ZX&pid=1447&revision=0.0.1&" +
"side=provider&timeout=3000×tamp=155650979798")
- assert.True(t, GetCompareURLEqualFunc()(url1, url2, constant.TimestampKey, constant.REMOTE_TIMESTAMP_KEY))
+ assert.True(t, GetCompareURLEqualFunc()(url1, url2, constant.TimestampKey, constant.RemoteTimestampKey))
SetCompareURLEqualFunc(CustomCompareURLEqual)
assert.False(t, GetCompareURLEqualFunc()(url1, url2))
- assert.False(t, GetCompareURLEqualFunc()(url1, url2, constant.TimestampKey, constant.REMOTE_TIMESTAMP_KEY))
+ assert.False(t, GetCompareURLEqualFunc()(url1, url2, constant.TimestampKey, constant.RemoteTimestampKey))
url1, _ = NewURL("dubbo://127.0.0.1:20000/com.ikurento.user.UserProvider?anyhost=true&" +
"application=BDTService&category=providers&default.timeout=10000&dubbo=dubbo-provider-golang-1.0.0&" +
@@ -412,10 +412,10 @@
"module=dubbogo+user-info+server&org=ikurento.com&owner=ZX&pid=1447&revision=0.0.1&" +
"side=provider&timeout=3000")
assert.True(t, GetCompareURLEqualFunc()(url1, url2))
- assert.True(t, GetCompareURLEqualFunc()(url1, url2, constant.TimestampKey, constant.REMOTE_TIMESTAMP_KEY))
+ assert.True(t, GetCompareURLEqualFunc()(url1, url2, constant.TimestampKey, constant.RemoteTimestampKey))
SetCompareURLEqualFunc(CustomCompareURLEqual)
assert.True(t, GetCompareURLEqualFunc()(url1, url2))
- assert.True(t, GetCompareURLEqualFunc()(url1, url2, constant.TimestampKey, constant.REMOTE_TIMESTAMP_KEY))
+ assert.True(t, GetCompareURLEqualFunc()(url1, url2, constant.TimestampKey, constant.RemoteTimestampKey))
}
func CustomCompareURLEqual(l *URL, r *URL, execludeParam ...string) bool {
diff --git a/config/application_config.go b/config/application_config.go
index fb766be..1520e8e 100644
--- a/config/application_config.go
+++ b/config/application_config.go
@@ -32,7 +32,7 @@
Organization string `default:"dubbo-go" yaml:"organization" json:"organization,omitempty" property:"organization"`
Name string `default:"dubbo.io" yaml:"name" json:"name,omitempty" property:"name"`
Module string `default:"sample" yaml:"module" json:"module,omitempty" property:"module"`
- Version string `default:"0.0.1" yaml:"version" json:"version,omitempty" property:"version"`
+ Version string `default:"3.0.0" yaml:"version" json:"version,omitempty" property:"version"`
Owner string `default:"dubbo-go" yaml:"owner" json:"owner,omitempty" property:"owner"`
Environment string `default:"dev" yaml:"environment" json:"environment,omitempty" property:"environment"`
// the metadata type. remote or local
diff --git a/config/config_api_test.go b/config/config_api_test.go
deleted file mode 100644
index ade9032..0000000
--- a/config/config_api_test.go
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package config
-
-//
-//func TestNewDefaultServiceConfig(t *testing.T) {
-// serviceConfig := NewServiceConfigByAPI(
-// WithServiceCluster("test-cluster"),
-// WithServiceInterface("test-interface"),
-// WithServiceLoadBalance("test-loadbalance"),
-// WithServiceMethod("test-method1", "test-retries1", "test-lb1"),
-// WithServiceMethod("test-method2", "test-retries2", "test-lb2"),
-// WithServiceMethod("test-method3", "test-retries3", "test-lb3"),
-// WithServiceProtocol("test-protocol"),
-// WithServiceRegistry("test-registry"),
-// WithServiceWarmUpTime("test-warmup"),
-// )
-// assert.Equal(t, serviceConfig.Cluster, "test-cluster")
-// assert.Equal(t, serviceConfig.InterfaceName, "test-interface")
-// assert.Equal(t, serviceConfig.Loadbalance, "test-loadbalance")
-// for i, v := range serviceConfig.Methods {
-// backFix := strconv.Itoa(i + 1)
-// assert.Equal(t, v.Name, "test-method"+backFix)
-// assert.Equal(t, v.Retries, "test-retries"+backFix)
-// assert.Equal(t, v.LoadBalance, "test-lb"+backFix)
-// }
-// assert.Equal(t, serviceConfig.Protocol, "test-protocol")
-// assert.Equal(t, serviceConfig.Registry, "test-registry")
-// assert.Equal(t, serviceConfig.Warmup, "test-warmup")
-//}
-//
-//func TestNewReferenceConfigByAPI(t *testing.T) {
-// refConfig := NewReferenceConfigByAPI(
-// WithReferenceCluster("test-cluster"),
-// WithReferenceInterface("test-interface"),
-// WithReferenceMethod("test-method1", "test-retries1", "test-lb1"),
-// WithReferenceMethod("test-method2", "test-retries2", "test-lb2"),
-// WithReferenceMethod("test-method3", "test-retries3", "test-lb3"),
-// WithReferenceProtocol("test-protocol"),
-// WithReferenceRegistry("test-registry"),
-// )
-// assert.Equal(t, refConfig.Cluster, "test-cluster")
-// assert.Equal(t, refConfig.InterfaceName, "test-interface")
-// for i, v := range refConfig.Methods {
-// backFix := strconv.Itoa(i + 1)
-// assert.Equal(t, v.Name, "test-method"+backFix)
-// assert.Equal(t, v.Retries, "test-retries"+backFix)
-// assert.Equal(t, v.LoadBalance, "test-lb"+backFix)
-// }
-// assert.Equal(t, refConfig.Protocol, "test-protocol")
-// assert.Equal(t, refConfig.Registry, "test-registry")
-//}
-//
-//func TestNewRegistryConfig(t *testing.T) {
-// regConfig := NewRegistryConfig(
-// WithRegistryTimeOut("test-timeout"),
-// WithRegistryProtocol("test-protocol"),
-// WithRegistryGroup("test-group"),
-// WithRegistryAddress("test-address"),
-// WithRegistrySimplified(true),
-// WithRegistryUserName("test-username"),
-// WithRegistryPassword("test-password"),
-// )
-// assert.Equal(t, regConfig.TimeoutStr, "test-timeout")
-// assert.Equal(t, regConfig.Protocol, "test-protocol")
-// assert.Equal(t, regConfig.Group, "test-group")
-// assert.Equal(t, regConfig.Address, "test-address")
-// assert.Equal(t, regConfig.Simplified, true)
-// assert.Equal(t, regConfig.Username, "test-username")
-// assert.Equal(t, regConfig.Password, "test-password")
-//}
-//
-//func TestNewConsumerConfig(t *testing.T) {
-// referConfig := NewReferenceConfigByAPI(
-// WithReferenceCluster("test-cluster"),
-// WithReferenceInterface("test-interface"),
-// WithReferenceMethod("test-method1", "test-retries1", "test-lb1"),
-// WithReferenceMethod("test-method2", "test-retries2", "test-lb2"),
-// WithReferenceMethod("test-method3", "test-retries3", "test-lb3"),
-// WithReferenceProtocol("test-protocol"),
-// WithReferenceRegistry("test-registry"),
-// )
-// defaultZKRegistry := NewRegistryConfigWithProtocolDefaultPort("zookeeper")
-// assert.Equal(t, defaultZKRegistry.Address, defaultZKAddr)
-// assert.Equal(t, defaultZKRegistry.Protocol, "zookeeper")
-// assert.Equal(t, defaultZKRegistry.TimeoutStr, defaultRegistryTimeout)
-//
-// testConsumerConfig := NewConsumerConfig(
-// WithConsumerConfigCheck(true),
-// WithConsumerConnTimeout(time.Minute),
-// WithConsumerRequestTimeout(time.Hour),
-// WithConsumerReferenceConfig("UserProvider", referConfig),
-// WithConsumerRegistryConfig("demoZK", defaultZKRegistry),
-// )
-//
-// assert.Equal(t, *testConsumerConfig.Check, true)
-// assert.Equal(t, testConsumerConfig.ConnectTimeout, time.Minute)
-// assert.Equal(t, testConsumerConfig.RequestTimeout, time.Hour)
-// assert.Equal(t, testConsumerConfig.Registries["demoZK"], defaultZKRegistry)
-// assert.Equal(t, testConsumerConfig.References["UserProvider"], referConfig)
-//}
-//
-//// TestNewProviderConfig test NewProviderConfig api
-//func TestNewProviderConfig(t *testing.T) {
-// serviceConfig := NewServiceConfigByAPI(
-// WithServiceCluster("test-cluster"),
-// WithServiceInterface("test-interface"),
-// WithServiceLoadBalance("test-loadbalance"),
-// WithServiceMethod("test-method1", "test-retries1", "test-lb1"),
-// WithServiceMethod("test-method2", "test-retries2", "test-lb2"),
-// WithServiceMethod("test-method3", "test-retries3", "test-lb3"),
-// WithServiceProtocol("test-protocol"),
-// WithServiceRegistry("test-registry"),
-// WithServiceWarmUpTime("test-warmup"),
-// )
-//
-// defaultNacosRegistry := NewRegistryConfigWithProtocolDefaultPort("nacos")
-// assert.Equal(t, defaultNacosRegistry.Address, defaultNacosAddr)
-// assert.Equal(t, defaultNacosRegistry.Protocol, "nacos")
-// assert.Equal(t, defaultNacosRegistry.TimeoutStr, defaultRegistryTimeout)
-//
-// testProviderConfig := NewProviderConfig(
-// WithProviderServices("UserProvider", serviceConfig),
-// WithProviderProtocol("dubbo", "dubbo", "20000"),
-// WithProviderRegistry("demoNacos", defaultNacosRegistry),
-// )
-//
-// assert.NotNil(t, testProviderConfig.Services)
-// for k, v := range testProviderConfig.Services {
-// assert.Equal(t, k, "UserProvider")
-// assert.Equal(t, v, serviceConfig)
-// }
-// assert.NotNil(t, testProviderConfig.Registries)
-//
-// if registry, ok := testProviderConfig.Registries["demoNacos"]; ok {
-// assert.Equal(t, registry, defaultNacosRegistry)
-// }
-// assert.NotNil(t, testProviderConfig.Protocols)
-// assert.Equal(t, testProviderConfig.Protocols["dubbo"].Name, "dubbo")
-// assert.Equal(t, testProviderConfig.Protocols["dubbo"].Port, "20000")
-//}
diff --git a/config/config_center_config.go b/config/config_center_config.go
index 956a39d..b97ae3e 100644
--- a/config/config_center_config.go
+++ b/config/config_center_config.go
@@ -18,6 +18,7 @@
package config
import (
+ "fmt"
"net/url"
"strings"
)
@@ -60,8 +61,6 @@
AppID string `default:"dubbo" yaml:"app-id" json:"app-id,omitempty"`
Timeout string `default:"10s" yaml:"timeout" json:"timeout,omitempty"`
Params map[string]string `yaml:"params" json:"parameters,omitempty"`
-
- DynamicConfiguration config_center.DynamicConfiguration
}
// Prefix dubbo.config-center
@@ -90,13 +89,13 @@
// GetUrlMap gets url map from ConfigCenterConfig
func (c *CenterConfig) GetUrlMap() url.Values {
urlMap := url.Values{}
- urlMap.Set(constant.CONFIG_NAMESPACE_KEY, c.Namespace)
- urlMap.Set(constant.CONFIG_GROUP_KEY, c.Group)
- urlMap.Set(constant.CONFIG_CLUSTER_KEY, c.Cluster)
- urlMap.Set(constant.CONFIG_APP_ID_KEY, c.AppID)
- urlMap.Set(constant.CONFIG_USERNAME_KEY, c.Username)
- urlMap.Set(constant.CONFIG_PASSWORD_KEY, c.Password)
- urlMap.Set(constant.CONFIG_TIMEOUT_KEY, c.Timeout)
+ urlMap.Set(constant.ConfigNamespaceKey, c.Namespace)
+ urlMap.Set(constant.ConfigGroupKey, c.Group)
+ urlMap.Set(constant.ConfigClusterKey, c.Cluster)
+ urlMap.Set(constant.ConfigAppIDKey, c.AppID)
+ urlMap.Set(constant.ConfigUsernameKey, c.Username)
+ urlMap.Set(constant.ConfigPasswordKey, c.Password)
+ urlMap.Set(constant.ConfigTimeoutKey, c.Timeout)
for key, val := range c.Params {
urlMap.Set(key, val)
@@ -131,11 +130,17 @@
// it will prepare the environment
func startConfigCenter(rc *RootConfig) error {
cc := rc.ConfigCenter
- strConf, err := cc.prepareEnvironment()
+ dynamicConfig, err := cc.GetDynamicConfiguration()
if err != nil {
- return errors.WithMessagef(err, "start config center error!")
+ logger.Errorf("Start dynamic configuration center error, error message is %v", err)
+ return err
}
+ strConf, err := dynamicConfig.GetProperties(cc.DataId, config_center.WithGroup(cc.Group))
+ if err != nil {
+ logger.Warnf("Dynamic onfig center has started, but config may not be initialized, because %s", err)
+ return nil
+ }
koan := koanf.New(".")
if err = koan.Load(rawbytes.Provider([]byte(strConf)), yaml.Parser()); err != nil {
return err
@@ -155,34 +160,22 @@
}
factory := extension.GetConfigCenterFactory(configCenterUrl.Protocol)
if factory == nil {
- return nil, errors.New("get config center factory failed")
+ return nil, errors.New(fmt.Sprintf("Get config center factory of %s failed", configCenterUrl.Protocol))
}
return factory.GetDynamicConfiguration(configCenterUrl)
}
func (c *CenterConfig) GetDynamicConfiguration() (config_center.DynamicConfiguration, error) {
- if c.DynamicConfiguration != nil {
- return c.DynamicConfiguration, nil
+ envInstance := conf.GetEnvInstance()
+ if envInstance.GetDynamicConfiguration() != nil {
+ return envInstance.GetDynamicConfiguration(), nil
}
dynamicConfig, err := c.CreateDynamicConfiguration()
if err != nil {
- logger.Errorf("Create dynamic configuration error , error message is %v", err)
return nil, errors.WithStack(err)
}
- c.DynamicConfiguration = dynamicConfig
- return dynamicConfig, nil
-}
-
-func (c *CenterConfig) prepareEnvironment() (string, error) {
- dynamicConfig, err := c.GetDynamicConfiguration()
- if err != nil {
- logger.Errorf("Create dynamic configuration error , error message is %v", err)
- return "", errors.WithStack(err)
- }
- envInstance := conf.GetEnvInstance()
envInstance.SetDynamicConfiguration(dynamicConfig)
-
- return dynamicConfig.GetProperties(c.DataId, config_center.WithGroup(c.Group))
+ return dynamicConfig, nil
}
func NewConfigCenterConfigBuilder() *ConfigCenterConfigBuilder {
diff --git a/config/config_center_config_test.go b/config/config_center_config_test.go
index dca8632..e77e593 100644
--- a/config/config_center_config_test.go
+++ b/config/config_center_config_test.go
@@ -20,9 +20,11 @@
import (
"testing"
)
+
import (
"github.com/stretchr/testify/assert"
)
+
import (
_ "dubbo.apache.org/dubbo-go/v3/config_center/apollo"
)
diff --git a/config/config_loader.go b/config/config_loader.go
index a4ca685..8b47ceb 100644
--- a/config/config_loader.go
+++ b/config/config_loader.go
@@ -71,7 +71,7 @@
if err != nil {
panic(err)
}
- p := extension.GetProtocol(constant.REGISTRY_KEY)
+ p := extension.GetProtocol(constant.RegistryKey)
var rp registry.RegistryFactory
var ok bool
if rp, ok = p.(registry.RegistryFactory); !ok {
@@ -90,7 +90,7 @@
}
}
// publish metadata to remote
- if GetApplicationConfig().MetadataType == constant.REMOTE_METADATA_STORAGE_TYPE {
+ if GetApplicationConfig().MetadataType == constant.RemoteMetadataStorageType {
if remoteMetadataService, err := extension.GetRemoteMetadataService(); err == nil {
remoteMetadataService.PublishMetadata(GetApplicationConfig().Name)
}
@@ -113,13 +113,13 @@
// usually we will add more metadata
metadata := make(map[string]string, 8)
- metadata[constant.METADATA_STORAGE_TYPE_PROPERTY_NAME] = appConfig.MetadataType
+ metadata[constant.MetadataStorageTypePropertyName] = appConfig.MetadataType
instance := ®istry.DefaultServiceInstance{
ServiceName: appConfig.Name,
Host: host,
Port: int(port),
- ID: host + constant.KEY_SEPARATOR + url.Port,
+ ID: host + constant.KeySeparator + url.Port,
Enable: true,
Healthy: true,
Metadata: metadata,
diff --git a/config/config_loader_options.go b/config/config_loader_options.go
index f98c8a5..598a478 100644
--- a/config/config_loader_options.go
+++ b/config/config_loader_options.go
@@ -48,7 +48,7 @@
func NewLoaderConf(opts ...LoaderConfOption) *loaderConf {
configFilePath := "../conf/dubbogo.yaml"
- if configFilePathFromEnv := os.Getenv(constant.CONFIG_FILE_ENV_KEY); configFilePathFromEnv != "" {
+ if configFilePathFromEnv := os.Getenv(constant.ConfigFileEnvKey); configFilePathFromEnv != "" {
configFilePath = configFilePathFromEnv
}
genre := strings.Split(configFilePath, ".")
diff --git a/config/config_utils.go b/config/config_utils.go
index 82e2859..2ba76ab 100644
--- a/config/config_utils.go
+++ b/config/config_utils.go
@@ -46,11 +46,11 @@
s1 := strings.Split(str1, ",")
s2 := strings.Split(str2, ",")
str := "," + strings.Join(append(s1, s2...), ",")
- defKey := strings.Contains(str, ","+constant.DEFAULT_KEY)
+ defKey := strings.Contains(str, ","+constant.DefaultKey)
if !defKey {
- str = "," + constant.DEFAULT_KEY + str
+ str = "," + constant.DefaultKey + str
}
- str = strings.TrimPrefix(strings.Replace(str, ","+constant.DEFAULT_KEY, ","+def, -1), ",")
+ str = strings.TrimPrefix(strings.Replace(str, ","+constant.DefaultKey, ","+def, -1), ",")
return removeMinus(strings.Split(str, ","))
}
diff --git a/config/consumer_config.go b/config/consumer_config.go
index cbf2a8d..01c18e0 100644
--- a/config/consumer_config.go
+++ b/config/consumer_config.go
@@ -122,7 +122,7 @@
checkok = false
count++
if count > maxWait {
- errMsg := fmt.Sprintf("Request timed out, please check configuration, Failed to check the status of the service %v. No provider available for the service to the consumer use dubbo version %v", refconfig.InterfaceName, constant.Version)
+ errMsg := fmt.Sprintf("No provider available of the service %v.please check configuration.", refconfig.InterfaceName)
logger.Error(errMsg)
panic(errMsg)
}
diff --git a/config/graceful_shutdown.go b/config/graceful_shutdown.go
index 6c0b755..dfcc79e 100644
--- a/config/graceful_shutdown.go
+++ b/config/graceful_shutdown.go
@@ -53,7 +53,7 @@
*/
const defaultShutDownTime = time.Second * 60
-// nolint
+// GracefulShutdownInit todo GracefulShutdownInit in 3.0 should be discusesed.
func GracefulShutdownInit() {
signals := make(chan os.Signal, 1)
@@ -107,7 +107,7 @@
func destroyAllRegistries() {
logger.Info("Graceful shutdown --- Destroy all registriesConfig. ")
- registryProtocol := extension.GetProtocol(constant.REGISTRY_KEY)
+ registryProtocol := extension.GetProtocol(constant.RegistryKey)
registryProtocol.Destroy()
}
diff --git a/config/logger_config.go b/config/logger_config.go
index 444bc38..d36b6d7 100644
--- a/config/logger_config.go
+++ b/config/logger_config.go
@@ -37,7 +37,7 @@
)
type ZapConfig struct {
- Level string `default:"debug" json:"level,omitempty" yaml:"level" property:"level"`
+ Level string `default:"info" json:"level,omitempty" yaml:"level" property:"level"`
Development bool `default:"false" json:"development,omitempty" yaml:"development" property:"development"`
DisableCaller bool `default:"false" json:"disable-caller,omitempty" yaml:"disable-caller" property:"disable-caller"`
DisableStacktrace bool `default:"false" json:"disable-stacktrace,omitempty" yaml:"disable-stacktrace" property:"disable-stacktrace"`
diff --git a/config/metadata_report_config.go b/config/metadata_report_config.go
index 4d4e03c..86bb034 100644
--- a/config/metadata_report_config.go
+++ b/config/metadata_report_config.go
@@ -31,13 +31,14 @@
// MetadataReportConfig is app level configuration
type MetadataReportConfig struct {
- Protocol string `required:"true" yaml:"protocol" json:"protocol,omitempty"`
- Address string `required:"true" yaml:"address" json:"address"`
- Username string `yaml:"username" json:"username,omitempty"`
- Password string `yaml:"password" json:"password,omitempty"`
- Timeout string `yaml:"timeout" json:"timeout,omitempty"`
- Group string `yaml:"group" json:"group,omitempty"`
- MetadataType string `default:"local" yaml:"metadata-type" json:"metadata-type"`
+ Protocol string `required:"true" yaml:"protocol" json:"protocol,omitempty"`
+ Address string `required:"true" yaml:"address" json:"address"`
+ Username string `yaml:"username" json:"username,omitempty"`
+ Password string `yaml:"password" json:"password,omitempty"`
+ Timeout string `yaml:"timeout" json:"timeout,omitempty"`
+ Group string `yaml:"group" json:"group,omitempty"`
+ // metadataType of this application is defined by application config, local or remote
+ metadataType string
}
// Prefix dubbo.consumer
@@ -49,7 +50,7 @@
if mc == nil {
return nil
}
- mc.MetadataType = rc.Application.MetadataType
+ mc.metadataType = rc.Application.MetadataType
return mc.StartMetadataReport()
}
@@ -59,7 +60,7 @@
common.WithPassword(mc.Password),
common.WithLocation(mc.Address),
common.WithProtocol(mc.Protocol),
- common.WithParamsValue(constant.MetadatatypeKey, mc.MetadataType),
+ common.WithParamsValue(constant.MetadataTypeKey, mc.metadataType),
)
if err != nil || len(res.Protocol) == 0 {
return nil, perrors.New("Invalid MetadataReport Config.")
@@ -86,13 +87,13 @@
}
func publishServiceDefinition(url *common.URL) {
- localService, err := extension.GetLocalMetadataService(constant.DEFAULT_Key)
+ localService, err := extension.GetLocalMetadataService(constant.DefaultKey)
if err != nil {
logger.Warnf("get local metadata service failed, please check if you have imported _ \"dubbo.apache.org/dubbo-go/v3/metadata/service/local\"")
return
}
localService.PublishServiceDefinition(url)
- if url.GetParam(constant.MetadatatypeKey, "") != constant.REMOTE_METADATA_STORAGE_TYPE {
+ if url.GetParam(constant.MetadataTypeKey, "") != constant.RemoteMetadataStorageType {
return
}
if remoteMetadataService, err := extension.GetRemoteMetadataService(); err == nil && remoteMetadataService != nil {
@@ -104,12 +105,12 @@
// selectMetadataServiceExportedURL get already be exported url
func selectMetadataServiceExportedURL() *common.URL {
var selectedUrl *common.URL
- metaDataService, err := extension.GetLocalMetadataService(constant.DEFAULT_Key)
+ metaDataService, err := extension.GetLocalMetadataService(constant.DefaultKey)
if err != nil {
logger.Warnf("get metadata service exporter failed, pls check if you import _ \"dubbo.apache.org/dubbo-go/v3/metadata/service/local\"")
return nil
}
- urlList, err := metaDataService.GetExportedURLs(constant.ANY_VALUE, constant.ANY_VALUE, constant.ANY_VALUE, constant.ANY_VALUE)
+ urlList, err := metaDataService.GetExportedURLs(constant.AnyValue, constant.AnyValue, constant.AnyValue, constant.AnyValue)
if err != nil {
panic(err)
}
@@ -172,12 +173,6 @@
}
// nolint
-func (mrcb *MetadataReportConfigBuilder) SetMetadataType(metadataType string) *MetadataReportConfigBuilder {
- mrcb.metadataReportConfig.MetadataType = metadataType
- return mrcb
-}
-
-// nolint
func (mrcb *MetadataReportConfigBuilder) Build() *MetadataReportConfig {
// TODO Init
return mrcb.metadataReportConfig
diff --git a/config/method_config.go b/config/method_config.go
index 113f928..4e45987 100644
--- a/config/method_config.go
+++ b/config/method_config.go
@@ -45,10 +45,10 @@
// nolint
func (mc *MethodConfig) Prefix() string {
if len(mc.InterfaceId) != 0 {
- return constant.DUBBO + "." + mc.InterfaceName + "." + mc.InterfaceId + "." + mc.Name + "."
+ return constant.Dubbo + "." + mc.InterfaceName + "." + mc.InterfaceId + "." + mc.Name + "."
}
- return constant.DUBBO + "." + mc.InterfaceName + "." + mc.Name + "."
+ return constant.Dubbo + "." + mc.InterfaceName + "." + mc.Name + "."
}
func (mc *MethodConfig) Init() error {
@@ -76,12 +76,3 @@
}
return verify(mc)
}
-
-// UnmarshalYAML unmarshals the MethodConfig by @unmarshal function
-//func (c *MethodConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
-// if err := defaults.Set(c); err != nil {
-// return err
-// }
-// type plain MethodConfig
-// return unmarshal((*plain)(c))
-//}
diff --git a/config/metric_config_test.go b/config/metric_config_test.go
deleted file mode 100644
index 2bcdd6d..0000000
--- a/config/metric_config_test.go
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package config
-
-import (
- "testing"
-)
-
-func TestGetMetricConfig(t *testing.T) {
- //empty := GetMetricConfig()
- //assert.NotNil(t, empty)
-}
diff --git a/config/registry_config.go b/config/registry_config.go
index 203bd35..17b0d2f 100644
--- a/config/registry_config.go
+++ b/config/registry_config.go
@@ -75,14 +75,14 @@
urlMap := url.Values{}
urlMap.Set(constant.GroupKey, c.Group)
urlMap.Set(constant.RoleKey, strconv.Itoa(int(roleType)))
- urlMap.Set(constant.REGISTRY_KEY, c.Protocol)
- urlMap.Set(constant.REGISTRY_TIMEOUT_KEY, c.Timeout)
+ urlMap.Set(constant.RegistryKey, c.Protocol)
+ urlMap.Set(constant.RegistryTimeoutKey, c.Timeout)
// multi registry invoker weight label for load balance
- urlMap.Set(constant.REGISTRY_KEY+"."+constant.REGISTRY_LABEL_KEY, strconv.FormatBool(true))
- urlMap.Set(constant.REGISTRY_KEY+"."+constant.PREFERRED_KEY, strconv.FormatBool(c.Preferred))
- urlMap.Set(constant.REGISTRY_KEY+"."+constant.ZONE_KEY, c.Zone)
- urlMap.Set(constant.REGISTRY_KEY+"."+constant.WEIGHT_KEY, strconv.FormatInt(c.Weight, 10))
- urlMap.Set(constant.REGISTRY_TTL_KEY, c.TTL)
+ urlMap.Set(constant.RegistryKey+"."+constant.RegistryLabelKey, strconv.FormatBool(true))
+ urlMap.Set(constant.RegistryKey+"."+constant.PreferredKey, strconv.FormatBool(c.Preferred))
+ urlMap.Set(constant.RegistryKey+"."+constant.ZoneKey, c.Zone)
+ urlMap.Set(constant.RegistryKey+"."+constant.WeightKey, strconv.FormatInt(c.Weight, 10))
+ urlMap.Set(constant.RegistryTTLKey, c.TTL)
for k, v := range c.Params {
urlMap.Set(k, v)
}
@@ -111,7 +111,7 @@
}
// if the protocol == registry, set protocol the registry value in url.params
if u.Protocol == constant.RegistryProtocol {
- u.Protocol = u.GetParam(constant.REGISTRY_KEY, "")
+ u.Protocol = u.GetParam(constant.RegistryKey, "")
}
return extension.GetRegistry(u.Protocol, u)
}
@@ -127,10 +127,10 @@
}
return common.NewURL(registryURLProtocol+"://"+address,
common.WithParams(c.getUrlMap(roleType)),
- common.WithParamsValue(constant.SIMPLIFIED_KEY, strconv.FormatBool(c.Simplified)),
- common.WithParamsValue(constant.REGISTRY_KEY, c.Protocol),
+ common.WithParamsValue(constant.SimplifiedKey, strconv.FormatBool(c.Simplified)),
+ common.WithParamsValue(constant.RegistryKey, c.Protocol),
common.WithParamsValue(constant.GroupKey, c.Group),
- common.WithParamsValue(constant.NAMESPACE_KEY, c.Namespace),
+ common.WithParamsValue(constant.NamespaceKey, c.Namespace),
common.WithUsername(c.Username),
common.WithPassword(c.Password),
common.WithLocation(c.Address),
diff --git a/config/remote_config.go b/config/remote_config.go
index 444db6e..a570bec 100644
--- a/config/remote_config.go
+++ b/config/remote_config.go
@@ -90,9 +90,9 @@
// getUrlMap get url map
func (rc *RemoteConfig) getUrlMap() url.Values {
urlMap := url.Values{}
- urlMap.Set(constant.CONFIG_USERNAME_KEY, rc.Username)
- urlMap.Set(constant.CONFIG_PASSWORD_KEY, rc.Password)
- urlMap.Set(constant.CONFIG_TIMEOUT_KEY, rc.Timeout)
+ urlMap.Set(constant.ConfigUsernameKey, rc.Username)
+ urlMap.Set(constant.ConfigPasswordKey, rc.Password)
+ urlMap.Set(constant.ConfigTimeoutKey, rc.Timeout)
for key, val := range rc.Params {
urlMap.Set(key, val)
diff --git a/config/root_config.go b/config/root_config.go
index 7db0a34..114d44f 100644
--- a/config/root_config.go
+++ b/config/root_config.go
@@ -86,7 +86,7 @@
// Prefix dubbo
func (RootConfig) Prefix() string {
- return constant.DUBBO
+ return constant.Dubbo
}
func GetRootConfig() *RootConfig {
@@ -137,7 +137,7 @@
return err
}
if err := rc.ConfigCenter.Init(rc); err != nil {
- logger.Infof("config center doesn't start, because %s", err)
+ logger.Infof("Config center doesn't start,because %s", err)
} else {
if err := rc.Logger.Init(); err != nil { // init logger using config from config center again
return err
@@ -153,7 +153,7 @@
if len(protocols) <= 0 {
protocol := &ProtocolConfig{}
protocols = make(map[string]*ProtocolConfig, 1)
- protocols[constant.DUBBO] = protocol
+ protocols[constant.Dubbo] = protocol
rc.Protocols = protocols
}
for _, protocol := range protocols {
@@ -308,7 +308,7 @@
}
func exportMetadataService() {
- ms, err := extension.GetLocalMetadataService(constant.DEFAULT_Key)
+ ms, err := extension.GetLocalMetadataService(constant.DefaultKey)
if err != nil {
logger.Warnf("could not init metadata service", err)
return
@@ -325,7 +325,7 @@
// So using sync.Once will result in dead lock
exporting.Store(true)
- expt := extension.GetMetadataServiceExporter(constant.DEFAULT_Key, ms)
+ expt := extension.GetMetadataServiceExporter(constant.DefaultKey, ms)
if expt == nil {
logger.Warnf("get metadata service exporter failed, pls check if you import _ \"dubbo.apache.org/dubbo-go/v3/metadata/service/exporter/configurable\"")
return
diff --git a/config/service_config.go b/config/service_config.go
index 9d51f16..fac86ca 100644
--- a/config/service_config.go
+++ b/config/service_config.go
@@ -193,10 +193,10 @@
common.WithPort(port),
common.WithParams(urlMap),
common.WithParamsValue(constant.BeanNameKey, svc.id),
- //common.WithParamsValue(constant.SSL_ENABLED_KEY, strconv.FormatBool(config.GetSslEnabled())),
+ //common.WithParamsValue(constant.SslEnabledKey, strconv.FormatBool(config.GetSslEnabled())),
common.WithMethods(strings.Split(methods, ",")),
common.WithToken(svc.Token),
- common.WithParamsValue(constant.MetadatatypeKey, svc.metadataType),
+ common.WithParamsValue(constant.MetadataTypeKey, svc.metadataType),
)
if len(svc.Tag) > 0 {
ivkURL.AddParam(constant.Tagkey, svc.Tag)
@@ -205,7 +205,7 @@
// post process the URL to be exported
svc.postProcessConfig(ivkURL)
// config post processor may set "export" to false
- if !ivkURL.GetParamBool(constant.EXPORT_KEY, true) {
+ if !ivkURL.GetParamBool(constant.ExportKey, true) {
return nil
}
@@ -227,7 +227,7 @@
svc.exporters = append(svc.exporters, exporter)
}
} else {
- if ivkURL.GetParam(constant.InterfaceKey, "") == constant.METADATA_SERVICE_NAME {
+ if ivkURL.GetParam(constant.InterfaceKey, "") == constant.MetadataServiceName {
ms, err := extension.GetLocalMetadataService("")
if err != nil {
logger.Warnf("export org.apache.dubbo.metadata.MetadataService failed beacause of %s ! pls check if you import _ \"dubbo.apache.org/dubbo-go/v3/metadata/service/local\"", err)
@@ -335,14 +335,14 @@
urlMap.Set(constant.TimestampKey, strconv.FormatInt(time.Now().Unix(), 10))
urlMap.Set(constant.ClusterKey, svc.Cluster)
urlMap.Set(constant.LoadbalanceKey, svc.Loadbalance)
- urlMap.Set(constant.WARMUP_KEY, svc.Warmup)
+ urlMap.Set(constant.WarmupKey, svc.Warmup)
urlMap.Set(constant.RetriesKey, svc.Retries)
urlMap.Set(constant.GroupKey, svc.Group)
urlMap.Set(constant.VersionKey, svc.Version)
urlMap.Set(constant.RoleKey, strconv.Itoa(common.PROVIDER))
urlMap.Set(constant.ReleaseKey, "dubbo-golang-"+constant.Version)
urlMap.Set(constant.SideKey, (common.RoleType(common.PROVIDER)).Role())
- urlMap.Set(constant.MESSAGE_SIZE_KEY, strconv.Itoa(svc.GrpcMaxMessageSize))
+ urlMap.Set(constant.MessageSizeKey, strconv.Itoa(svc.GrpcMaxMessageSize))
// todo: move
urlMap.Set(constant.SerializationKey, svc.Serialization)
// application config info
@@ -357,43 +357,43 @@
// filter
if svc.Filter == "" {
- urlMap.Set(constant.SERVICE_FILTER_KEY, constant.DEFAULT_SERVICE_FILTERS)
+ urlMap.Set(constant.ServiceFilterKey, constant.DefaultServiceFilters)
} else {
- urlMap.Set(constant.SERVICE_FILTER_KEY, svc.Filter)
+ urlMap.Set(constant.ServiceFilterKey, svc.Filter)
}
// filter special config
urlMap.Set(constant.AccessLogFilterKey, svc.AccessLog)
// tps limiter
- urlMap.Set(constant.TPS_LIMIT_STRATEGY_KEY, svc.TpsLimitStrategy)
- urlMap.Set(constant.TPS_LIMIT_INTERVAL_KEY, svc.TpsLimitInterval)
- urlMap.Set(constant.TPS_LIMIT_RATE_KEY, svc.TpsLimitRate)
- urlMap.Set(constant.TPS_LIMITER_KEY, svc.TpsLimiter)
- urlMap.Set(constant.TPS_REJECTED_EXECUTION_HANDLER_KEY, svc.TpsLimitRejectedHandler)
+ urlMap.Set(constant.TPSLimitStrategyKey, svc.TpsLimitStrategy)
+ urlMap.Set(constant.TPSLimitIntervalKey, svc.TpsLimitInterval)
+ urlMap.Set(constant.TPSLimitRateKey, svc.TpsLimitRate)
+ urlMap.Set(constant.TPSLimiterKey, svc.TpsLimiter)
+ urlMap.Set(constant.TPSRejectedExecutionHandlerKey, svc.TpsLimitRejectedHandler)
// execute limit filter
- urlMap.Set(constant.EXECUTE_LIMIT_KEY, svc.ExecuteLimit)
- urlMap.Set(constant.EXECUTE_REJECTED_EXECUTION_HANDLER_KEY, svc.ExecuteLimitRejectedHandler)
+ urlMap.Set(constant.ExecuteLimitKey, svc.ExecuteLimit)
+ urlMap.Set(constant.ExecuteRejectedExecutionHandlerKey, svc.ExecuteLimitRejectedHandler)
// auth filter
- urlMap.Set(constant.SERVICE_AUTH_KEY, svc.Auth)
- urlMap.Set(constant.PARAMETER_SIGNATURE_ENABLE_KEY, svc.ParamSign)
+ urlMap.Set(constant.ServiceAuthKey, svc.Auth)
+ urlMap.Set(constant.ParameterSignatureEnableKey, svc.ParamSign)
// whether to export or not
- urlMap.Set(constant.EXPORT_KEY, strconv.FormatBool(svc.export))
+ urlMap.Set(constant.ExportKey, strconv.FormatBool(svc.export))
for _, v := range svc.Methods {
prefix := "methods." + v.Name + "."
urlMap.Set(prefix+constant.LoadbalanceKey, v.LoadBalance)
urlMap.Set(prefix+constant.RetriesKey, v.Retries)
- urlMap.Set(prefix+constant.WEIGHT_KEY, strconv.FormatInt(v.Weight, 10))
+ urlMap.Set(prefix+constant.WeightKey, strconv.FormatInt(v.Weight, 10))
- urlMap.Set(prefix+constant.TPS_LIMIT_STRATEGY_KEY, v.TpsLimitStrategy)
- urlMap.Set(prefix+constant.TPS_LIMIT_INTERVAL_KEY, v.TpsLimitInterval)
- urlMap.Set(prefix+constant.TPS_LIMIT_RATE_KEY, v.TpsLimitRate)
+ urlMap.Set(prefix+constant.TPSLimitStrategyKey, v.TpsLimitStrategy)
+ urlMap.Set(prefix+constant.TPSLimitIntervalKey, v.TpsLimitInterval)
+ urlMap.Set(prefix+constant.TPSLimitRateKey, v.TpsLimitRate)
- urlMap.Set(constant.EXECUTE_LIMIT_KEY, v.ExecuteLimit)
- urlMap.Set(constant.EXECUTE_REJECTED_EXECUTION_HANDLER_KEY, v.ExecuteLimitRejectedHandler)
+ urlMap.Set(constant.ExecuteLimitKey, v.ExecuteLimit)
+ urlMap.Set(constant.ExecuteRejectedExecutionHandlerKey, v.ExecuteLimitRejectedHandler)
}
return urlMap
diff --git a/config_center/apollo/impl.go b/config_center/apollo/impl.go
index 9df8fd7..d6ca2c3 100644
--- a/config_center/apollo/impl.go
+++ b/config_center/apollo/impl.go
@@ -58,13 +58,13 @@
url: url,
}
c.appConf = &config.AppConfig{
- AppID: url.GetParam(constant.CONFIG_APP_ID_KEY, ""),
- Cluster: url.GetParam(constant.CONFIG_CLUSTER_KEY, ""),
- NamespaceName: url.GetParam(constant.CONFIG_NAMESPACE_KEY, cc.DEFAULT_GROUP),
+ AppID: url.GetParam(constant.ConfigAppIDKey, ""),
+ Cluster: url.GetParam(constant.ConfigClusterKey, ""),
+ NamespaceName: url.GetParam(constant.ConfigNamespaceKey, cc.DefaultGroup),
IP: c.getAddressWithProtocolPrefix(url),
- Secret: url.GetParam(constant.CONFIG_SECRET_KEY, ""),
- IsBackupConfig: url.GetParamBool(constant.CONFIG_BACKUP_CONFIG_KEY, true),
- BackupConfigPath: url.GetParam(constant.CONFIG_BACKUP_CONFIG_PATH_KEY, ""),
+ Secret: url.GetParam(constant.ConfigSecretKey, ""),
+ IsBackupConfig: url.GetParamBool(constant.ConfigBackupConfigKey, true),
+ BackupConfigPath: url.GetParam(constant.ConfigBackupConfigPathKey, ""),
}
agollo.InitCustomConfig(func() (*config.AppConfig, error) {
return c.appConf, nil
diff --git a/config_center/apollo/mockDubbogo.yaml.json b/config_center/apollo/mockDubbogo.yaml.json
deleted file mode 100644
index 4131bed..0000000
--- a/config_center/apollo/mockDubbogo.yaml.json
+++ /dev/null
@@ -1 +0,0 @@
-{"appId":"testApplication_yang","cluster":"default","namespaceName":"mockDubbogo.yaml","releaseKey":"20191104105242-0f13805d89f834a4","configurations":{"registries.hangzhouzk.username":"11111"}}
diff --git a/config_center/configurator/override.go b/config_center/configurator/override.go
index 4c4ec37..8c73b66 100644
--- a/config_center/configurator/override.go
+++ b/config_center/configurator/override.go
@@ -50,16 +50,16 @@
func (c *overrideConfigurator) Configure(url *common.URL) {
// remove configuratorUrl some param that can not be configured
- if c.configuratorUrl.GetParam(constant.ENABLED_KEY, "true") == "false" || len(c.configuratorUrl.Location) == 0 {
+ if c.configuratorUrl.GetParam(constant.EnabledKey, "true") == "false" || len(c.configuratorUrl.Location) == 0 {
return
}
// branch for version 2.7.x
- apiVersion := c.configuratorUrl.GetParam(constant.CONFIG_VERSION_KEY, "")
+ apiVersion := c.configuratorUrl.GetParam(constant.ConfigVersionKey, "")
if len(apiVersion) != 0 {
currentSide := url.GetParam(constant.SideKey, "")
configuratorSide := c.configuratorUrl.GetParam(constant.SideKey, "")
- if currentSide == configuratorSide && common.DubboRole[common.Consumer] == currentSide && c.configuratorUrl.Port == "0" {
+ if currentSide == configuratorSide && common.DubboRole[common.CONSUMER] == currentSide && c.configuratorUrl.Port == "0" {
localIP := common.GetLocalIp()
c.configureIfMatch(localIP, url)
} else if currentSide == configuratorSide && common.DubboRole[common.PROVIDER] == currentSide && c.configuratorUrl.Port == url.Port {
@@ -74,23 +74,23 @@
func (c *overrideConfigurator) configureIfMatchInternal(url *common.URL) {
configApp := c.configuratorUrl.GetParam(constant.ApplicationKey, c.configuratorUrl.Username)
currentApp := url.GetParam(constant.ApplicationKey, url.Username)
- if len(configApp) == 0 || constant.ANY_VALUE == configApp || configApp == currentApp {
+ if len(configApp) == 0 || constant.AnyValue == configApp || configApp == currentApp {
conditionKeys := gxset.NewSet()
- conditionKeys.Add(constant.CATEGORY_KEY)
- conditionKeys.Add(constant.CHECK_KEY)
- conditionKeys.Add(constant.ENABLED_KEY)
+ conditionKeys.Add(constant.CategoryKey)
+ conditionKeys.Add(constant.CheckKey)
+ conditionKeys.Add(constant.EnabledKey)
conditionKeys.Add(constant.GroupKey)
conditionKeys.Add(constant.VersionKey)
conditionKeys.Add(constant.ApplicationKey)
conditionKeys.Add(constant.SideKey)
- conditionKeys.Add(constant.CONFIG_VERSION_KEY)
- conditionKeys.Add(constant.COMPATIBLE_CONFIG_KEY)
+ conditionKeys.Add(constant.ConfigVersionKey)
+ conditionKeys.Add(constant.CompatibleConfigKey)
returnUrl := false
c.configuratorUrl.RangeParams(func(k, _ string) bool {
value := c.configuratorUrl.GetParam(k, "")
if strings.HasPrefix(k, "~") || k == constant.ApplicationKey || k == constant.SideKey {
conditionKeys.Add(k)
- if len(value) != 0 && value != constant.ANY_VALUE && value != url.GetParam(strings.TrimPrefix(k, "~"), "") {
+ if len(value) != 0 && value != constant.AnyValue && value != url.GetParam(strings.TrimPrefix(k, "~"), "") {
returnUrl = true
return false
}
@@ -107,9 +107,9 @@
// configureIfMatch translate from java, compatible rules in java
func (c *overrideConfigurator) configureIfMatch(host string, url *common.URL) {
- if constant.ANYHOST_VALUE == c.configuratorUrl.Ip || host == c.configuratorUrl.Ip {
- providers := c.configuratorUrl.GetParam(constant.OVERRIDE_PROVIDERS_KEY, "")
- if len(providers) == 0 || strings.Contains(providers, url.Location) || strings.Contains(providers, constant.ANYHOST_VALUE) {
+ if constant.AnyhostValue == c.configuratorUrl.Ip || host == c.configuratorUrl.Ip {
+ providers := c.configuratorUrl.GetParam(constant.OverrideProvidersKey, "")
+ if len(providers) == 0 || strings.Contains(providers, url.Location) || strings.Contains(providers, constant.AnyhostValue) {
c.configureIfMatchInternal(url)
}
}
@@ -125,11 +125,11 @@
// override url don't have a port, means the ip override url specify is a consumer address or 0.0.0.0
// 1.If it is a consumer ip address, the intention is to control a specific consumer instance, it must takes effect at the consumer side, any provider received this override url should ignore;
// 2.If the ip is 0.0.0.0, this override url can be used on consumer, and also can be used on provider
- if url.GetParam(constant.SideKey, "") == common.DubboRole[common.Consumer] {
+ if url.GetParam(constant.SideKey, "") == common.DubboRole[common.CONSUMER] {
localIP := common.GetLocalIp()
c.configureIfMatch(localIP, url)
} else {
- c.configureIfMatch(constant.ANYHOST_VALUE, url)
+ c.configureIfMatch(constant.AnyhostValue, url)
}
}
}
diff --git a/config_center/dynamic_configuration.go b/config_center/dynamic_configuration.go
index 447342e..12c1851 100644
--- a/config_center/dynamic_configuration.go
+++ b/config_center/dynamic_configuration.go
@@ -34,10 +34,10 @@
// DynamicConfiguration
// ////////////////////////////////////////
const (
- // DEFAULT_GROUP: default group
- DEFAULT_GROUP = "dubbo"
- // DEFAULT_CONFIG_TIMEOUT: default config timeout
- DEFAULT_CONFIG_TIMEOUT = "10s"
+ // DefaultGroup default group
+ DefaultGroup = "dubbo"
+ // DefaultConfigTimeout default config timeout
+ DefaultConfigTimeout = "10s"
)
// DynamicConfiguration for modify listener and get properties file
diff --git a/config_center/file/factory.go b/config_center/file/factory.go
index 2fc48b2..57744be 100644
--- a/config_center/file/factory.go
+++ b/config_center/file/factory.go
@@ -30,7 +30,7 @@
)
func init() {
- extension.SetConfigCenterFactory(constant.FILE_KEY, func() config_center.DynamicConfigurationFactory {
+ extension.SetConfigCenterFactory(constant.FileKey, func() config_center.DynamicConfigurationFactory {
return &fileDynamicConfigurationFactory{}
})
}
diff --git a/config_center/file/impl.go b/config_center/file/impl.go
index a3e2cdc..5fdb20d 100644
--- a/config_center/file/impl.go
+++ b/config_center/file/impl.go
@@ -195,7 +195,7 @@
}
if len(group) == 0 {
- group = config_center.DEFAULT_GROUP
+ group = config_center.DefaultGroup
}
return filepath.Join(fsdc.rootPath, group, adapterKey(key))
diff --git a/config_center/nacos/impl.go b/config_center/nacos/impl.go
index 6d19fbd..fdc8b6e 100644
--- a/config_center/nacos/impl.go
+++ b/config_center/nacos/impl.go
@@ -63,7 +63,7 @@
func newNacosDynamicConfiguration(url *common.URL) (*nacosDynamicConfiguration, error) {
c := &nacosDynamicConfiguration{
- rootPath: "/" + url.GetParam(constant.CONFIG_NAMESPACE_KEY, config_center.DEFAULT_GROUP) + "/config",
+ rootPath: "/" + url.GetParam(constant.ConfigNamespaceKey, config_center.DefaultGroup) + "/config",
url: url,
done: make(chan struct{}),
}
diff --git a/config_center/parser/configuration_parser.go b/config_center/parser/configuration_parser.go
index 5e07f43..1f3f317 100644
--- a/config_center/parser/configuration_parser.go
+++ b/config_center/parser/configuration_parser.go
@@ -116,11 +116,11 @@
func serviceItemToUrls(item ConfigItem, config ConfiguratorConfig) ([]*common.URL, error) {
addresses := item.Addresses
if len(addresses) == 0 {
- addresses = append(addresses, constant.ANYHOST_VALUE)
+ addresses = append(addresses, constant.AnyhostValue)
}
var urls []*common.URL
for _, v := range addresses {
- urlStr := constant.OVERRIDE_PROTOCOL + "://" + v + "/"
+ urlStr := constant.OverrideProtocol + "://" + v + "/"
serviceStr, err := getServiceString(config.Key)
if err != nil {
return nil, perrors.WithStack(err)
@@ -133,7 +133,7 @@
urlStr = urlStr + paramStr
urlStr = urlStr + getEnabledString(item, config)
urlStr = urlStr + "&category="
- urlStr = urlStr + constant.DYNAMIC_CONFIGURATORS_CATEGORY
+ urlStr = urlStr + constant.DynamicConfiguratorsCategory
urlStr = urlStr + "&configVersion="
urlStr = urlStr + config.ConfigVersion
apps := item.Applications
@@ -163,14 +163,14 @@
func appItemToUrls(item ConfigItem, config ConfiguratorConfig) ([]*common.URL, error) {
addresses := item.Addresses
if len(addresses) == 0 {
- addresses = append(addresses, constant.ANYHOST_VALUE)
+ addresses = append(addresses, constant.AnyhostValue)
}
var urls []*common.URL
for _, v := range addresses {
- urlStr := constant.OVERRIDE_PROTOCOL + "://" + v + "/"
+ urlStr := constant.OverrideProtocol + "://" + v + "/"
services := item.Services
if len(services) == 0 {
- services = append(services, constant.ANY_VALUE)
+ services = append(services, constant.AnyValue)
}
for _, vs := range services {
serviceStr, err := getServiceString(vs)
@@ -187,7 +187,7 @@
urlStr = urlStr + config.Key
urlStr = urlStr + getEnabledString(item, config)
urlStr = urlStr + "&category="
- urlStr = urlStr + constant.APP_DYNAMIC_CONFIGURATORS_CATEGORY
+ urlStr = urlStr + constant.AppDynamicConfiguratorsCategory
urlStr = urlStr + "&configVersion="
urlStr = urlStr + config.ConfigVersion
url, err := common.NewURL(urlStr)
@@ -228,7 +228,7 @@
func getParamString(item ConfigItem) (string, error) {
var retStr string
retStr = retStr + "category="
- retStr = retStr + constant.DYNAMIC_CONFIGURATORS_CATEGORY
+ retStr = retStr + constant.DynamicConfiguratorsCategory
if len(item.Side) > 0 {
retStr = retStr + "&side="
retStr = retStr + item.Side
@@ -242,7 +242,7 @@
retStr += "&" + k + "=" + v
}
- retStr += "&" + constant.OVERRIDE_PROVIDERS_KEY + "=" + strings.Join(item.ProviderAddresses, ",")
+ retStr += "&" + constant.OverrideProvidersKey + "=" + strings.Join(item.ProviderAddresses, ",")
return retStr, nil
}
diff --git a/config_center/zookeeper/impl.go b/config_center/zookeeper/impl.go
index c5eb36c..44d752c 100644
--- a/config_center/zookeeper/impl.go
+++ b/config_center/zookeeper/impl.go
@@ -65,7 +65,7 @@
func newZookeeperDynamicConfiguration(url *common.URL) (*zookeeperDynamicConfiguration, error) {
c := &zookeeperDynamicConfiguration{
url: url,
- rootPath: "/" + url.GetParam(constant.CONFIG_NAMESPACE_KEY, config_center.DEFAULT_GROUP) + "/config",
+ rootPath: "/" + url.GetParam(constant.ConfigNamespaceKey, config_center.DefaultGroup) + "/config",
}
if v, ok := config.GetRootConfig().ConfigCenter.Params["base64"]; ok {
base64Enabled, err := strconv.ParseBool(v)
@@ -146,6 +146,8 @@
if c.base64Enabled {
valueBytes = []byte(base64.StdEncoding.EncodeToString(valueBytes))
}
+ // FIXME this method need to be fixed, because it will recursively
+ // create every node in the path with given value which we may not expected.
err := c.client.CreateWithValue(path, valueBytes)
if err != nil {
return perrors.WithStack(err)
@@ -246,7 +248,7 @@
func (c *zookeeperDynamicConfiguration) buildPath(group string) string {
if len(group) == 0 {
- group = config_center.DEFAULT_GROUP
+ group = config_center.DefaultGroup
}
return c.rootPath + pathSeparator + group
}
diff --git a/config_center/zookeeper/listener.go b/config_center/zookeeper/listener.go
index 7b67a70..5dd5457 100644
--- a/config_center/zookeeper/listener.go
+++ b/config_center/zookeeper/listener.go
@@ -25,6 +25,7 @@
import (
"dubbo.apache.org/dubbo-go/v3/common/constant"
"dubbo.apache.org/dubbo-go/v3/common/logger"
+ "dubbo.apache.org/dubbo-go/v3/config"
"dubbo.apache.org/dubbo-go/v3/config_center"
"dubbo.apache.org/dubbo-go/v3/remoting"
)
@@ -65,10 +66,12 @@
// meanings new node
return true
}
- key := l.pathToKey(event.Path)
+ var key string
// TODO use common way
- if strings.HasSuffix(key, constant.MeshRouteSuffix) {
- key = key[:strings.Index(key, constant.MeshRouteSuffix)]
+ if strings.HasSuffix(event.Path, constant.MeshRouteSuffix) {
+ key = config.GetRootConfig().Application.Name
+ } else {
+ key = l.pathToKey(event.Path)
}
if key != "" {
if listeners, ok := l.keyListeners.Load(key); ok {
@@ -85,8 +88,7 @@
key := strings.Replace(strings.Replace(path, l.rootPath+"/", "", -1), "/", ".", -1)
if strings.HasSuffix(key, constant.ConfiguratorSuffix) ||
strings.HasSuffix(key, constant.TagRouterRuleSuffix) ||
- strings.HasSuffix(key, constant.ConditionRouterRuleSuffix) ||
- strings.HasSuffix(key, constant.MeshRouteSuffix) {
+ strings.HasSuffix(key, constant.ConditionRouterRuleSuffix) {
// governance config, so we remove the "dubbo." prefix
key = key[strings.Index(key, ".")+1:]
}
diff --git a/filter/accesslog/filter.go b/filter/accesslog/filter.go
index 102df9e..21d2a80 100644
--- a/filter/accesslog/filter.go
+++ b/filter/accesslog/filter.go
@@ -106,13 +106,13 @@
attachments := invocation.Attachments()
itf := attachments[constant.InterfaceKey]
if itf == nil || len(itf.(string)) == 0 {
- itf = attachments[constant.PATH_KEY]
+ itf = attachments[constant.PathKey]
}
if itf != nil {
dataMap[constant.InterfaceKey] = itf.(string)
}
- if v, ok := attachments[constant.METHOD_KEY]; ok && v != nil {
- dataMap[constant.METHOD_KEY] = v.(string)
+ if v, ok := attachments[constant.MethodKey]; ok && v != nil {
+ dataMap[constant.MethodKey] = v.(string)
}
if v, ok := attachments[constant.VersionKey]; ok && v != nil {
dataMap[constant.VersionKey] = v.(string)
@@ -123,11 +123,11 @@
if v, ok := attachments[constant.TimestampKey]; ok && v != nil {
dataMap[constant.TimestampKey] = v.(string)
}
- if v, ok := attachments[constant.LOCAL_ADDR]; ok && v != nil {
- dataMap[constant.LOCAL_ADDR] = v.(string)
+ if v, ok := attachments[constant.LocalAddr]; ok && v != nil {
+ dataMap[constant.LocalAddr] = v.(string)
}
- if v, ok := attachments[constant.REMOTE_ADDR]; ok && v != nil {
- dataMap[constant.REMOTE_ADDR] = v.(string)
+ if v, ok := attachments[constant.RemoteAddr]; ok && v != nil {
+ dataMap[constant.RemoteAddr] = v.(string)
}
if len(invocation.Arguments()) > 0 {
@@ -242,9 +242,9 @@
builder.WriteString("[")
builder.WriteString(d.data[constant.TimestampKey])
builder.WriteString("] ")
- builder.WriteString(d.data[constant.REMOTE_ADDR])
+ builder.WriteString(d.data[constant.RemoteAddr])
builder.WriteString(" -> ")
- builder.WriteString(d.data[constant.LOCAL_ADDR])
+ builder.WriteString(d.data[constant.LocalAddr])
builder.WriteString(" - ")
if len(d.data[constant.GroupKey]) > 0 {
builder.WriteString(d.data[constant.GroupKey])
@@ -259,7 +259,7 @@
}
builder.WriteString(" ")
- builder.WriteString(d.data[constant.METHOD_KEY])
+ builder.WriteString(d.data[constant.MethodKey])
builder.WriteString("(")
if len(d.data[Types]) > 0 {
builder.WriteString(d.data[Types])
diff --git a/filter/auth/accesskey_storage.go b/filter/auth/accesskey_storage.go
index de6c456..4566cfb 100644
--- a/filter/auth/accesskey_storage.go
+++ b/filter/auth/accesskey_storage.go
@@ -26,7 +26,7 @@
)
func init() {
- extension.SetAccessKeyStorages(constant.DEFAULT_ACCESS_KEY_STORAGE, func() filter.AccessKeyStorage {
+ extension.SetAccessKeyStorages(constant.DefaultAccessKeyStorage, func() filter.AccessKeyStorage {
return &DefaultAccesskeyStorage{}
})
}
@@ -37,7 +37,7 @@
// GetAccessKeyPair retrieves AccessKeyPair from url by the key "accessKeyId" and "secretAccessKey"
func (storage *DefaultAccesskeyStorage) GetAccessKeyPair(invocation protocol.Invocation, url *common.URL) *filter.AccessKeyPair {
return &filter.AccessKeyPair{
- AccessKey: url.GetParam(constant.ACCESS_KEY_ID_KEY, ""),
- SecretKey: url.GetParam(constant.SECRET_ACCESS_KEY_KEY, ""),
+ AccessKey: url.GetParam(constant.AccessKeyIDKey, ""),
+ SecretKey: url.GetParam(constant.SecretAccessKeyKey, ""),
}
}
diff --git a/filter/auth/accesskey_storage_test.go b/filter/auth/accesskey_storage_test.go
index a8b1eb6..8c72e7c 100644
--- a/filter/auth/accesskey_storage_test.go
+++ b/filter/auth/accesskey_storage_test.go
@@ -35,8 +35,8 @@
func TestDefaultAccesskeyStorage_GetAccesskeyPair(t *testing.T) {
url := common.NewURLWithOptions(
common.WithParams(url.Values{}),
- common.WithParamsValue(constant.SECRET_ACCESS_KEY_KEY, "skey"),
- common.WithParamsValue(constant.ACCESS_KEY_ID_KEY, "akey"))
+ common.WithParamsValue(constant.SecretAccessKeyKey, "skey"),
+ common.WithParamsValue(constant.AccessKeyIDKey, "akey"))
invocation := &invocation2.RPCInvocation{}
storage := &DefaultAccesskeyStorage{}
accesskeyPair := storage.GetAccessKeyPair(invocation, url)
diff --git a/filter/auth/consumer_sign_filter_test.go b/filter/auth/consumer_sign_filter_test.go
index ba024bd..187f125 100644
--- a/filter/auth/consumer_sign_filter_test.go
+++ b/filter/auth/consumer_sign_filter_test.go
@@ -38,8 +38,8 @@
func TestConsumerSignFilter_Invoke(t *testing.T) {
url, _ := common.NewURL("dubbo://127.0.0.1:20000/com.ikurento.user.UserProvider?interface=com.ikurento.user.UserProvider&group=gg&version=2.6.0")
- url.SetParam(constant.SECRET_ACCESS_KEY_KEY, "sk")
- url.SetParam(constant.ACCESS_KEY_ID_KEY, "ak")
+ url.SetParam(constant.SecretAccessKeyKey, "sk")
+ url.SetParam(constant.AccessKeyIDKey, "ak")
inv := invocation.NewRPCInvocation("test", []interface{}{"OK"}, nil)
filter := &ConsumerSignFilter{}
ctrl := gomock.NewController(t)
@@ -50,6 +50,6 @@
invoker.EXPECT().GetUrl().Return(url).Times(2)
assert.Equal(t, result, filter.Invoke(context.Background(), invoker, inv))
- url.SetParam(constant.SERVICE_AUTH_KEY, "true")
+ url.SetParam(constant.ServiceAuthKey, "true")
assert.Equal(t, result, filter.Invoke(context.Background(), invoker, inv))
}
diff --git a/filter/auth/default_authenticator.go b/filter/auth/default_authenticator.go
index fd12db0..845bc2e 100644
--- a/filter/auth/default_authenticator.go
+++ b/filter/auth/default_authenticator.go
@@ -34,7 +34,7 @@
)
func init() {
- extension.SetAuthenticator(constant.DEFAULT_AUTHENTICATOR, func() filter.Authenticator {
+ extension.SetAuthenticator(constant.DefaultAuthenticator, func() filter.Authenticator {
return &DefaultAuthenticator{}
})
}
@@ -56,20 +56,20 @@
if err != nil {
return err
}
- inv.SetAttachments(constant.REQUEST_SIGNATURE_KEY, signature)
- inv.SetAttachments(constant.REQUEST_TIMESTAMP_KEY, currentTimeMillis)
- inv.SetAttachments(constant.AK_KEY, accessKeyPair.AccessKey)
- inv.SetAttachments(constant.CONSUMER, consumer)
+ inv.SetAttachments(constant.RequestSignatureKey, signature)
+ inv.SetAttachments(constant.RequestTimestampKey, currentTimeMillis)
+ inv.SetAttachments(constant.AKKey, accessKeyPair.AccessKey)
+ inv.SetAttachments(constant.Consumer, consumer)
return nil
}
// getSignature
// get signature by the metadata and params of the invocation
func getSignature(url *common.URL, invocation protocol.Invocation, secrectKey string, currentTime string) (string, error) {
- requestString := fmt.Sprintf(constant.SIGNATURE_STRING_FORMAT,
+ requestString := fmt.Sprintf(constant.SignatureStringFormat,
url.ColonSeparatedKey(), invocation.MethodName(), secrectKey, currentTime)
var signature string
- if parameterEncrypt := url.GetParamBool(constant.PARAMETER_SIGNATURE_ENABLE_KEY, false); parameterEncrypt {
+ if parameterEncrypt := url.GetParamBool(constant.ParameterSignatureEnableKey, false); parameterEncrypt {
var err error
if signature, err = SignWithParams(invocation.Arguments(), requestString, secrectKey); err != nil {
// TODO
@@ -84,11 +84,11 @@
// Authenticate verifies whether the signature sent by the requester is correct
func (authenticator *DefaultAuthenticator) Authenticate(invocation protocol.Invocation, url *common.URL) error {
- accessKeyId := invocation.AttachmentsByKey(constant.AK_KEY, "")
+ accessKeyId := invocation.AttachmentsByKey(constant.AKKey, "")
- requestTimestamp := invocation.AttachmentsByKey(constant.REQUEST_TIMESTAMP_KEY, "")
- originSignature := invocation.AttachmentsByKey(constant.REQUEST_SIGNATURE_KEY, "")
- consumer := invocation.AttachmentsByKey(constant.CONSUMER, "")
+ requestTimestamp := invocation.AttachmentsByKey(constant.RequestTimestampKey, "")
+ originSignature := invocation.AttachmentsByKey(constant.RequestSignatureKey, "")
+ consumer := invocation.AttachmentsByKey(constant.Consumer, "")
if IsEmpty(accessKeyId, false) || IsEmpty(consumer, false) ||
IsEmpty(requestTimestamp, false) || IsEmpty(originSignature, false) {
return errors.New("failed to authenticate your ak/sk, maybe the consumer has not enabled the auth")
@@ -110,7 +110,7 @@
}
func getAccessKeyPair(invocation protocol.Invocation, url *common.URL) (*filter.AccessKeyPair, error) {
- accesskeyStorage := extension.GetAccessKeyStorages(url.GetParam(constant.ACCESS_KEY_STORAGE_KEY, constant.DEFAULT_ACCESS_KEY_STORAGE))
+ accesskeyStorage := extension.GetAccessKeyStorages(url.GetParam(constant.AccessKeyStorageKey, constant.DefaultAccessKeyStorage))
accessKeyPair := accesskeyStorage.GetAccessKeyPair(invocation, url)
if accessKeyPair == nil || IsEmpty(accessKeyPair.AccessKey, false) || IsEmpty(accessKeyPair.SecretKey, true) {
return nil, errors.New("accessKeyId or secretAccessKey not found")
@@ -120,9 +120,9 @@
}
func doAuthWork(url *common.URL, do func(filter.Authenticator) error) error {
- shouldAuth := url.GetParamBool(constant.SERVICE_AUTH_KEY, false)
+ shouldAuth := url.GetParamBool(constant.ServiceAuthKey, false)
if shouldAuth {
- authenticator := extension.GetAuthenticator(url.GetParam(constant.AUTHENTICATOR_KEY, constant.DEFAULT_AUTHENTICATOR))
+ authenticator := extension.GetAuthenticator(url.GetParam(constant.AuthenticatorKey, constant.DefaultAuthenticator))
return do(authenticator)
}
return nil
diff --git a/filter/auth/default_authenticator_test.go b/filter/auth/default_authenticator_test.go
index eeab4cc..d6ce6ef 100644
--- a/filter/auth/default_authenticator_test.go
+++ b/filter/auth/default_authenticator_test.go
@@ -39,9 +39,9 @@
secret := "dubbo-sk"
access := "dubbo-ak"
testurl, _ := common.NewURL("dubbo://127.0.0.1:20000/com.ikurento.user.UserProvider?interface=com.ikurento.user.UserProvider&group=gg&version=2.6.0")
- testurl.SetParam(constant.PARAMETER_SIGNATURE_ENABLE_KEY, "true")
- testurl.SetParam(constant.ACCESS_KEY_ID_KEY, access)
- testurl.SetParam(constant.SECRET_ACCESS_KEY_KEY, secret)
+ testurl.SetParam(constant.ParameterSignatureEnableKey, "true")
+ testurl.SetParam(constant.AccessKeyIDKey, access)
+ testurl.SetParam(constant.SecretAccessKeyKey, secret)
parmas := []interface{}{"OK", struct {
Name string
ID int64
@@ -53,19 +53,19 @@
authenticator := &DefaultAuthenticator{}
invcation := invocation.NewRPCInvocation("test", parmas, map[string]interface{}{
- constant.REQUEST_SIGNATURE_KEY: signature,
- constant.CONSUMER: "test",
- constant.REQUEST_TIMESTAMP_KEY: requestTime,
- constant.AK_KEY: access,
+ constant.RequestSignatureKey: signature,
+ constant.Consumer: "test",
+ constant.RequestTimestampKey: requestTime,
+ constant.AKKey: access,
})
err := authenticator.Authenticate(invcation, testurl)
assert.Nil(t, err)
// modify the params
invcation = invocation.NewRPCInvocation("test", parmas[:1], map[string]interface{}{
- constant.REQUEST_SIGNATURE_KEY: signature,
- constant.CONSUMER: "test",
- constant.REQUEST_TIMESTAMP_KEY: requestTime,
- constant.AK_KEY: access,
+ constant.RequestSignatureKey: signature,
+ constant.Consumer: "test",
+ constant.RequestTimestampKey: requestTime,
+ constant.AKKey: access,
})
err = authenticator.Authenticate(invcation, testurl)
assert.NotNil(t, err)
@@ -74,22 +74,22 @@
func TestDefaultAuthenticator_Sign(t *testing.T) {
authenticator := &DefaultAuthenticator{}
testurl, _ := common.NewURL("dubbo://127.0.0.1:20000/com.ikurento.user.UserProvider?application=test&interface=com.ikurento.user.UserProvider&group=gg&version=2.6.0")
- testurl.SetParam(constant.ACCESS_KEY_ID_KEY, "akey")
- testurl.SetParam(constant.SECRET_ACCESS_KEY_KEY, "skey")
- testurl.SetParam(constant.PARAMETER_SIGNATURE_ENABLE_KEY, "false")
+ testurl.SetParam(constant.AccessKeyIDKey, "akey")
+ testurl.SetParam(constant.SecretAccessKeyKey, "skey")
+ testurl.SetParam(constant.ParameterSignatureEnableKey, "false")
inv := invocation.NewRPCInvocation("test", []interface{}{"OK"}, nil)
_ = authenticator.Sign(inv, testurl)
- assert.NotEqual(t, inv.AttachmentsByKey(constant.REQUEST_SIGNATURE_KEY, ""), "")
- assert.NotEqual(t, inv.AttachmentsByKey(constant.CONSUMER, ""), "")
- assert.NotEqual(t, inv.AttachmentsByKey(constant.REQUEST_TIMESTAMP_KEY, ""), "")
- assert.Equal(t, inv.AttachmentsByKey(constant.AK_KEY, ""), "akey")
+ assert.NotEqual(t, inv.AttachmentsByKey(constant.RequestSignatureKey, ""), "")
+ assert.NotEqual(t, inv.AttachmentsByKey(constant.Consumer, ""), "")
+ assert.NotEqual(t, inv.AttachmentsByKey(constant.RequestTimestampKey, ""), "")
+ assert.Equal(t, inv.AttachmentsByKey(constant.AKKey, ""), "akey")
}
func Test_getAccessKeyPairSuccess(t *testing.T) {
testurl := common.NewURLWithOptions(
common.WithParams(url.Values{}),
- common.WithParamsValue(constant.SECRET_ACCESS_KEY_KEY, "skey"),
- common.WithParamsValue(constant.ACCESS_KEY_ID_KEY, "akey"))
+ common.WithParamsValue(constant.SecretAccessKeyKey, "skey"),
+ common.WithParamsValue(constant.AccessKeyIDKey, "akey"))
invcation := invocation.NewRPCInvocation("MethodName", []interface{}{"OK"}, nil)
_, e := getAccessKeyPair(invcation, testurl)
assert.Nil(t, e)
@@ -102,28 +102,28 @@
}()
testurl := common.NewURLWithOptions(
common.WithParams(url.Values{}),
- common.WithParamsValue(constant.ACCESS_KEY_ID_KEY, "akey"))
+ common.WithParamsValue(constant.AccessKeyIDKey, "akey"))
invcation := invocation.NewRPCInvocation("MethodName", []interface{}{"OK"}, nil)
_, e := getAccessKeyPair(invcation, testurl)
assert.NotNil(t, e)
testurl = common.NewURLWithOptions(
common.WithParams(url.Values{}),
- common.WithParamsValue(constant.SECRET_ACCESS_KEY_KEY, "skey"),
- common.WithParamsValue(constant.ACCESS_KEY_ID_KEY, "akey"), common.WithParamsValue(constant.ACCESS_KEY_STORAGE_KEY, "dubbo"))
+ common.WithParamsValue(constant.SecretAccessKeyKey, "skey"),
+ common.WithParamsValue(constant.AccessKeyIDKey, "akey"), common.WithParamsValue(constant.AccessKeyStorageKey, "dubbo"))
_, e = getAccessKeyPair(invcation, testurl)
assert.NoError(t, e)
}
func Test_getSignatureWithinParams(t *testing.T) {
testurl, _ := common.NewURL("dubbo://127.0.0.1:20000/com.ikurento.user.UserProvider?interface=com.ikurento.user.UserProvider&group=gg&version=2.6.0")
- testurl.SetParam(constant.PARAMETER_SIGNATURE_ENABLE_KEY, "true")
+ testurl.SetParam(constant.ParameterSignatureEnableKey, "true")
inv := invocation.NewRPCInvocation("test", []interface{}{"OK"}, map[string]interface{}{
"": "",
})
secret := "dubbo"
current := strconv.Itoa(int(time.Now().Unix() * 1000))
signature, _ := getSignature(testurl, inv, secret, current)
- requestString := fmt.Sprintf(constant.SIGNATURE_STRING_FORMAT,
+ requestString := fmt.Sprintf(constant.SignatureStringFormat,
testurl.ColonSeparatedKey(), inv.MethodName(), secret, current)
s, _ := SignWithParams(inv.Arguments(), requestString, secret)
assert.False(t, IsEmpty(signature, false))
@@ -132,12 +132,12 @@
func Test_getSignature(t *testing.T) {
testurl, _ := common.NewURL("dubbo://127.0.0.1:20000/com.ikurento.user.UserProvider?interface=com.ikurento.user.UserProvider&group=gg&version=2.6.0")
- testurl.SetParam(constant.PARAMETER_SIGNATURE_ENABLE_KEY, "false")
+ testurl.SetParam(constant.ParameterSignatureEnableKey, "false")
inv := invocation.NewRPCInvocation("test", []interface{}{"OK"}, nil)
secret := "dubbo"
current := strconv.Itoa(int(time.Now().Unix() * 1000))
signature, _ := getSignature(testurl, inv, secret, current)
- requestString := fmt.Sprintf(constant.SIGNATURE_STRING_FORMAT,
+ requestString := fmt.Sprintf(constant.SignatureStringFormat,
testurl.ColonSeparatedKey(), inv.MethodName(), secret, current)
s := Sign(requestString, secret)
assert.False(t, IsEmpty(signature, false))
diff --git a/filter/auth/provider_auth_filter_test.go b/filter/auth/provider_auth_filter_test.go
index 1f83501..edf1dc6 100644
--- a/filter/auth/provider_auth_filter_test.go
+++ b/filter/auth/provider_auth_filter_test.go
@@ -42,8 +42,8 @@
secret := "dubbo-sk"
access := "dubbo-ak"
url, _ := common.NewURL("dubbo://127.0.0.1:20000/com.ikurento.user.UserProvider?interface=com.ikurento.user.UserProvider&group=gg&version=2.6.0")
- url.SetParam(constant.ACCESS_KEY_ID_KEY, access)
- url.SetParam(constant.SECRET_ACCESS_KEY_KEY, secret)
+ url.SetParam(constant.AccessKeyIDKey, access)
+ url.SetParam(constant.SecretAccessKeyKey, secret)
parmas := []interface{}{
"OK",
struct {
@@ -56,10 +56,10 @@
signature, _ := getSignature(url, inv, secret, requestTime)
inv = invocation.NewRPCInvocation("test", []interface{}{"OK"}, map[string]interface{}{
- constant.REQUEST_SIGNATURE_KEY: signature,
- constant.CONSUMER: "test",
- constant.REQUEST_TIMESTAMP_KEY: requestTime,
- constant.AK_KEY: access,
+ constant.RequestSignatureKey: signature,
+ constant.Consumer: "test",
+ constant.RequestTimestampKey: requestTime,
+ constant.AKKey: access,
})
ctrl := gomock.NewController(t)
filter := &ProviderAuthFilter{}
@@ -69,6 +69,6 @@
invoker.EXPECT().Invoke(inv).Return(result).Times(2)
invoker.EXPECT().GetUrl().Return(url).Times(2)
assert.Equal(t, result, filter.Invoke(context.Background(), invoker, inv))
- url.SetParam(constant.SERVICE_AUTH_KEY, "true")
+ url.SetParam(constant.ServiceAuthKey, "true")
assert.Equal(t, result, filter.Invoke(context.Background(), invoker, inv))
}
diff --git a/filter/echo/filter.go b/filter/echo/filter.go
index c6b367a..f1bc7c3 100644
--- a/filter/echo/filter.go
+++ b/filter/echo/filter.go
@@ -44,7 +44,7 @@
// Invoke response to the callers with its first argument.
func (f *Filter) Invoke(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result {
logger.Debugf("%v,%v", invocation.MethodName(), len(invocation.Arguments()))
- if invocation.MethodName() == constant.ECHO && len(invocation.Arguments()) == 1 {
+ if invocation.MethodName() == constant.Echo && len(invocation.Arguments()) == 1 {
return &protocol.RPCResult{
Rest: invocation.Arguments()[0],
Attrs: invocation.Attachments(),
diff --git a/filter/execlmt/filter.go b/filter/execlmt/filter.go
index 060e3c4..c313c62 100644
--- a/filter/execlmt/filter.go
+++ b/filter/execlmt/filter.go
@@ -82,13 +82,13 @@
limitTarget := ivkURL.ServiceKey()
var limitRateConfig string
- methodLevelConfig := ivkURL.GetParam(methodConfigPrefix+constant.EXECUTE_LIMIT_KEY, "")
+ methodLevelConfig := ivkURL.GetParam(methodConfigPrefix+constant.ExecuteLimitKey, "")
if len(methodLevelConfig) > 0 {
// we have the method-level configuration
limitTarget = limitTarget + "#" + invocation.MethodName()
limitRateConfig = methodLevelConfig
} else {
- limitRateConfig = ivkURL.GetParam(constant.EXECUTE_LIMIT_KEY, constant.DEFAULT_EXECUTE_LIMIT)
+ limitRateConfig = ivkURL.GetParam(constant.ExecuteLimitKey, constant.DefaultExecuteLimit)
}
limitRate, err := strconv.ParseInt(limitRateConfig, 0, 0)
@@ -109,8 +109,8 @@
defer state.(*ExecuteState).decrease()
if concurrentCount > limitRate {
logger.Errorf("The invocation was rejected due to over the execute limitation, url: %s ", ivkURL.String())
- rejectedHandlerConfig := ivkURL.GetParam(methodConfigPrefix+constant.EXECUTE_REJECTED_EXECUTION_HANDLER_KEY,
- ivkURL.GetParam(constant.EXECUTE_REJECTED_EXECUTION_HANDLER_KEY, constant.DEFAULT_KEY))
+ rejectedHandlerConfig := ivkURL.GetParam(methodConfigPrefix+constant.ExecuteRejectedExecutionHandlerKey,
+ ivkURL.GetParam(constant.ExecuteRejectedExecutionHandlerKey, constant.DefaultKey))
return extension.GetRejectedExecutionHandler(rejectedHandlerConfig).RejectedExecution(ivkURL, invocation)
}
diff --git a/filter/execlmt/filter_test.go b/filter/execlmt/filter_test.go
index 43c56c3..c255c5a 100644
--- a/filter/execlmt/filter_test.go
+++ b/filter/execlmt/filter_test.go
@@ -56,7 +56,7 @@
invokeUrl := common.NewURLWithOptions(
common.WithParams(url.Values{}),
common.WithParamsValue(constant.InterfaceKey, methodName),
- common.WithParamsValue(constant.EXECUTE_LIMIT_KEY, "13a"),
+ common.WithParamsValue(constant.ExecuteLimitKey, "13a"),
)
limitFilter := newFilter()
@@ -73,7 +73,7 @@
invokeUrl := common.NewURLWithOptions(
common.WithParams(url.Values{}),
common.WithParamsValue(constant.InterfaceKey, methodName),
- common.WithParamsValue(constant.EXECUTE_LIMIT_KEY, "20"),
+ common.WithParamsValue(constant.ExecuteLimitKey, "20"),
)
limitFilter := newFilter()
diff --git a/filter/filter_impl/import.go b/filter/filter_impl/import.go
index 457e3cd..46bfd45 100644
--- a/filter/filter_impl/import.go
+++ b/filter/filter_impl/import.go
@@ -36,5 +36,3 @@
_ "dubbo.apache.org/dubbo-go/v3/filter/tps"
_ "dubbo.apache.org/dubbo-go/v3/filter/tracing"
)
-
-func init() {}
diff --git a/filter/generic/filter.go b/filter/generic/filter.go
index 4da67d7..38fa76b 100644
--- a/filter/generic/filter.go
+++ b/filter/generic/filter.go
@@ -79,7 +79,7 @@
types,
args,
}
- newivc := invocation2.NewRPCInvocation(constant.GENERIC, newargs, invocation.Attachments())
+ newivc := invocation2.NewRPCInvocation(constant.Generic, newargs, invocation.Attachments())
newivc.SetReply(invocation.Reply())
newivc.Attachments()[constant.GenericKey] = invoker.GetURL().GetParam(constant.GenericKey, "")
diff --git a/filter/generic/filter_test.go b/filter/generic/filter_test.go
index 23bdf64..8ad669d 100644
--- a/filter/generic/filter_test.go
+++ b/filter/generic/filter_test.go
@@ -55,7 +55,7 @@
mockInvoker.EXPECT().GetUrl().Return(invokeUrl).Times(2)
mockInvoker.EXPECT().Invoke(gomock.Not(normalInvocation)).DoAndReturn(
func(invocation protocol.Invocation) protocol.Result {
- assert.Equal(t, constant.GENERIC, invocation.MethodName())
+ assert.Equal(t, constant.Generic, invocation.MethodName())
args := invocation.Arguments()
assert.Equal(t, "Hello", args[0])
assert.Equal(t, "java.lang.String", args[1].([]string)[0])
@@ -78,7 +78,7 @@
ctrl := gomock.NewController(t)
defer ctrl.Finish()
- genericInvocation := invocation.NewRPCInvocation(constant.GENERIC, []interface{}{
+ genericInvocation := invocation.NewRPCInvocation(constant.Generic, []interface{}{
"hello",
[]string{"java.lang.String"},
[]string{"arg1"},
@@ -88,7 +88,7 @@
mockInvoker.EXPECT().GetUrl().Return(invokeUrl).Times(3)
mockInvoker.EXPECT().Invoke(gomock.Any()).DoAndReturn(
func(invocation protocol.Invocation) protocol.Result {
- assert.Equal(t, constant.GENERIC, invocation.MethodName())
+ assert.Equal(t, constant.Generic, invocation.MethodName())
args := invocation.Arguments()
assert.Equal(t, "hello", args[0])
assert.Equal(t, "java.lang.String", args[1].([]string)[0])
diff --git a/filter/generic/service_filter_test.go b/filter/generic/service_filter_test.go
index 5cd5f1b..24bd7be 100644
--- a/filter/generic/service_filter_test.go
+++ b/filter/generic/service_filter_test.go
@@ -82,11 +82,11 @@
mockInvoker.EXPECT().Invoke(gomock.Eq(invocation1))
_ = filter.Invoke(context.Background(), mockInvoker, invocation1)
// arguments are nil
- invocation2 := invocation.NewRPCInvocation(constant.GENERIC, nil, nil)
+ invocation2 := invocation.NewRPCInvocation(constant.Generic, nil, nil)
mockInvoker.EXPECT().Invoke(gomock.Eq(invocation2))
_ = filter.Invoke(context.Background(), mockInvoker, invocation2)
// the number of arguments is not 3
- invocation3 := invocation.NewRPCInvocation(constant.GENERIC, []interface{}{"hello"}, nil)
+ invocation3 := invocation.NewRPCInvocation(constant.Generic, []interface{}{"hello"}, nil)
mockInvoker.EXPECT().Invoke(gomock.Eq(invocation3))
_ = filter.Invoke(context.Background(), mockInvoker, invocation3)
@@ -110,7 +110,7 @@
mockInvoker.EXPECT().GetUrl().Return(ivkUrl).Times(3)
// invoke a method without errors using default generalization
- invocation4 := invocation.NewRPCInvocation(constant.GENERIC,
+ invocation4 := invocation.NewRPCInvocation(constant.Generic,
[]interface{}{
"Hello",
[]string{"java.lang.String"},
@@ -119,7 +119,7 @@
constant.GenericKey: "true",
})
// invoke a non-existed method
- invocation5 := invocation.NewRPCInvocation(constant.GENERIC,
+ invocation5 := invocation.NewRPCInvocation(constant.Generic,
[]interface{}{
"hello11",
[]string{"java.lang.String"},
@@ -128,7 +128,7 @@
constant.GenericKey: "true",
})
// invoke a method with incorrect arguments
- invocation6 := invocation.NewRPCInvocation(constant.GENERIC,
+ invocation6 := invocation.NewRPCInvocation(constant.Generic,
[]interface{}{
"Hello",
[]string{"java.lang.String", "java.lang.String"},
@@ -137,7 +137,7 @@
constant.GenericKey: "true",
})
// invoke a method without errors using protobuf-json generalization
- //invocation7 := invocation.NewRPCInvocation(constant.GENERIC,
+ //invocation7 := invocation.NewRPCInvocation(constant.Generic,
// []interface{}{
// "HelloPB",
// []string{},
@@ -196,7 +196,7 @@
filter := &ServiceFilter{}
// invoke a method without errors
- invocation1 := invocation.NewRPCInvocation(constant.GENERIC,
+ invocation1 := invocation.NewRPCInvocation(constant.Generic,
[]interface{}{
"hello",
[]interface{}{"java.lang.String"},
diff --git a/filter/generic/util.go b/filter/generic/util.go
index b586bb4..9936ec7 100644
--- a/filter/generic/util.go
+++ b/filter/generic/util.go
@@ -31,13 +31,13 @@
// isCallingToGenericService check if it calls to a generic service
func isCallingToGenericService(invoker protocol.Invoker, invocation protocol.Invocation) bool {
return isGeneric(invoker.GetURL().GetParam(constant.GenericKey, "")) &&
- invocation.MethodName() != constant.GENERIC
+ invocation.MethodName() != constant.Generic
}
// isMakingAGenericCall check if it is making a generic call to a generic service
func isMakingAGenericCall(invoker protocol.Invoker, invocation protocol.Invocation) bool {
return isGeneric(invoker.GetURL().GetParam(constant.GenericKey, "")) &&
- invocation.MethodName() == constant.GENERIC &&
+ invocation.MethodName() == constant.Generic &&
invocation.Arguments() != nil &&
len(invocation.Arguments()) == 3
}
@@ -50,7 +50,7 @@
// isGenericInvocation determines if the invocation has generic format
func isGenericInvocation(invocation protocol.Invocation) bool {
- return invocation.MethodName() == constant.GENERIC &&
+ return invocation.MethodName() == constant.Generic &&
invocation.Arguments() != nil &&
len(invocation.Arguments()) == 3
}
diff --git a/filter/gshutdown/filter.go b/filter/gshutdown/filter.go
index 7b4a905..6d2b960 100644
--- a/filter/gshutdown/filter.go
+++ b/filter/gshutdown/filter.go
@@ -87,7 +87,7 @@
}
func (f *Filter) getRejectHandler() filter.RejectedExecutionHandler {
- handler := constant.DEFAULT_KEY
+ handler := constant.DefaultKey
if f.shutdownConfig != nil && len(f.shutdownConfig.RejectRequestHandler) > 0 {
handler = f.shutdownConfig.RejectRequestHandler
}
diff --git a/filter/gshutdown/filter_test.go b/filter/gshutdown/filter_test.go
index b86ed4d..36ddccb 100644
--- a/filter/gshutdown/filter_test.go
+++ b/filter/gshutdown/filter_test.go
@@ -49,7 +49,7 @@
assert.False(t, shutdownFilter.rejectNewRequest())
assert.Nil(t, rootConfig.Shutdown)
- assert.Equal(t, extension.GetRejectedExecutionHandler(constant.DEFAULT_KEY),
+ assert.Equal(t, extension.GetRejectedExecutionHandler(constant.DefaultKey),
shutdownFilter.getRejectHandler())
result := shutdownFilter.Invoke(context.Background(), protocol.NewBaseInvoker(invokeUrl), invoc)
diff --git a/filter/handler/rejected_execution_handler_only_log.go b/filter/handler/rejected_execution_handler_only_log.go
index c370fe6..ac541d3 100644
--- a/filter/handler/rejected_execution_handler_only_log.go
+++ b/filter/handler/rejected_execution_handler_only_log.go
@@ -38,7 +38,7 @@
func init() {
// this implementation is the the default implementation of RejectedExecutionHandler
extension.SetRejectedExecutionHandler(HandlerName, GetOnlyLogRejectedExecutionHandler)
- extension.SetRejectedExecutionHandler(constant.DEFAULT_KEY, GetOnlyLogRejectedExecutionHandler)
+ extension.SetRejectedExecutionHandler(constant.DefaultKey, GetOnlyLogRejectedExecutionHandler)
}
var (
diff --git a/filter/hystrix/filter_test.go b/filter/hystrix/filter_test.go
index 4718fa2..41a6ba6 100644
--- a/filter/hystrix/filter_test.go
+++ b/filter/hystrix/filter_test.go
@@ -152,7 +152,7 @@
func TestHystrixFilterInvokeSuccess(t *testing.T) {
hf := &Filter{}
testUrl, err := common.NewURL(
- fmt.Sprintf("dubbo://%s:%d/com.ikurento.user.UserProvider", constant.LOCAL_HOST_VALUE, constant.DEFAULT_PORT))
+ fmt.Sprintf("dubbo://%s:%d/com.ikurento.user.UserProvider", constant.LocalHostValue, constant.DefaultPort))
assert.NoError(t, err)
testInvoker := testMockSuccessInvoker{*protocol.NewBaseInvoker(testUrl)}
result := hf.Invoke(context.Background(), &testInvoker, &invocation.RPCInvocation{})
@@ -164,7 +164,7 @@
func TestHystrixFilterInvokeFail(t *testing.T) {
hf := &Filter{}
testUrl, err := common.NewURL(
- fmt.Sprintf("dubbo://%s:%d/com.ikurento.user.UserProvider", constant.LOCAL_HOST_VALUE, constant.DEFAULT_PORT))
+ fmt.Sprintf("dubbo://%s:%d/com.ikurento.user.UserProvider", constant.LocalHostValue, constant.DefaultPort))
assert.NoError(t, err)
testInvoker := testMockFailInvoker{*protocol.NewBaseInvoker(testUrl)}
result := hf.Invoke(context.Background(), &testInvoker, &invocation.RPCInvocation{})
@@ -180,7 +180,7 @@
for i := 0; i < 50; i++ {
go func() {
testUrl, err := common.NewURL(
- fmt.Sprintf("dubbo://%s:%d/com.ikurento.user.UserProvider", constant.LOCAL_HOST_VALUE, constant.DEFAULT_PORT))
+ fmt.Sprintf("dubbo://%s:%d/com.ikurento.user.UserProvider", constant.LocalHostValue, constant.DefaultPort))
assert.NoError(t, err)
testInvoker := testMockSuccessInvoker{*protocol.NewBaseInvoker(testUrl)}
result := hf.Invoke(context.Background(), &testInvoker, &invocation.RPCInvocation{})
@@ -208,7 +208,7 @@
for i := 0; i < 50; i++ {
go func() {
testUrl, err := common.NewURL(
- fmt.Sprintf("dubbo://%s:%d/com.ikurento.user.UserProvider", constant.LOCAL_HOST_VALUE, constant.DEFAULT_PORT))
+ fmt.Sprintf("dubbo://%s:%d/com.ikurento.user.UserProvider", constant.LocalHostValue, constant.DefaultPort))
assert.NoError(t, err)
testInvoker := testMockSuccessInvoker{*protocol.NewBaseInvoker(testUrl)}
result := hf.Invoke(context.Background(), &testInvoker, &invocation.RPCInvocation{})
diff --git a/filter/metrics/filter.go b/filter/metrics/filter.go
index 8f31c2b..19a2ead 100644
--- a/filter/metrics/filter.go
+++ b/filter/metrics/filter.go
@@ -38,12 +38,6 @@
}
// Filter will calculate the invocation's duration and the report to the reporters
-// If you want to use this filter to collect the metrics,
-// Adding this into your configuration file, like:
-// filter: "metrics"
-// metrics:
-// reporter:
-// - "your reporter" # here you should specify the reporter, for example 'prometheus'
// more info please take a look at dubbo-samples projects
type Filter struct {
reporters []metrics.Reporter
diff --git a/filter/token/filter.go b/filter/token/filter.go
index 7362c2c..c7eba70 100644
--- a/filter/token/filter.go
+++ b/filter/token/filter.go
@@ -44,10 +44,10 @@
// Invoke verifies the incoming token with the service configured token
func (f *Filter) Invoke(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result {
- invokerTkn := invoker.GetURL().GetParam(constant.TOKEN_KEY, "")
+ invokerTkn := invoker.GetURL().GetParam(constant.TokenKey, "")
if len(invokerTkn) > 0 {
attachs := invocation.Attachments()
- remoteTkn, exist := attachs[constant.TOKEN_KEY]
+ remoteTkn, exist := attachs[constant.TokenKey]
if exist && remoteTkn != nil && strings.EqualFold(invokerTkn, remoteTkn.(string)) {
return invoker.Invoke(ctx, invocation)
}
diff --git a/filter/token/filter_test.go b/filter/token/filter_test.go
index ddc44c2..10edd3f 100644
--- a/filter/token/filter_test.go
+++ b/filter/token/filter_test.go
@@ -39,9 +39,9 @@
url := common.NewURLWithOptions(
common.WithParams(url.Values{}),
- common.WithParamsValue(constant.TOKEN_KEY, "ori_key"))
+ common.WithParamsValue(constant.TokenKey, "ori_key"))
attch := make(map[string]interface{})
- attch[constant.TOKEN_KEY] = "ori_key"
+ attch[constant.TokenKey] = "ori_key"
result := filter.Invoke(context.Background(),
protocol.NewBaseInvoker(url),
invocation.NewRPCInvocation("MethodName",
@@ -55,7 +55,7 @@
testUrl := common.URL{}
attch := make(map[string]interface{})
- attch[constant.TOKEN_KEY] = "ori_key"
+ attch[constant.TokenKey] = "ori_key"
result := filter.Invoke(context.Background(), protocol.NewBaseInvoker(&testUrl), invocation.NewRPCInvocation("MethodName", []interface{}{"OK"}, attch))
assert.Nil(t, result.Error())
assert.Nil(t, result.Result())
@@ -66,7 +66,7 @@
testUrl := common.NewURLWithOptions(
common.WithParams(url.Values{}),
- common.WithParamsValue(constant.TOKEN_KEY, "ori_key"))
+ common.WithParamsValue(constant.TokenKey, "ori_key"))
attch := make(map[string]interface{})
result := filter.Invoke(context.Background(), protocol.NewBaseInvoker(testUrl), invocation.NewRPCInvocation("MethodName", []interface{}{"OK"}, attch))
assert.NotNil(t, result.Error())
@@ -77,9 +77,9 @@
testUrl := common.NewURLWithOptions(
common.WithParams(url.Values{}),
- common.WithParamsValue(constant.TOKEN_KEY, "ori_key"))
+ common.WithParamsValue(constant.TokenKey, "ori_key"))
attch := make(map[string]interface{})
- attch[constant.TOKEN_KEY] = "err_key"
+ attch[constant.TokenKey] = "err_key"
result := filter.Invoke(context.Background(),
protocol.NewBaseInvoker(testUrl), invocation.NewRPCInvocation("MethodName", []interface{}{"OK"}, attch))
assert.NotNil(t, result.Error())
diff --git a/filter/tps/filter.go b/filter/tps/filter.go
index 32a31ae..32f45f5 100644
--- a/filter/tps/filter.go
+++ b/filter/tps/filter.go
@@ -56,8 +56,8 @@
// Invoke gets the configured limter to impose TPS limiting
func (t *Filter) Invoke(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result {
url := invoker.GetURL()
- tpsLimiter := url.GetParam(constant.TPS_LIMITER_KEY, "")
- rejectedExeHandler := url.GetParam(constant.TPS_REJECTED_EXECUTION_HANDLER_KEY, constant.DEFAULT_KEY)
+ tpsLimiter := url.GetParam(constant.TPSLimiterKey, "")
+ rejectedExeHandler := url.GetParam(constant.TPSRejectedExecutionHandlerKey, constant.DefaultKey)
if len(tpsLimiter) > 0 {
allow := extension.GetTpsLimiter(tpsLimiter).IsAllowable(invoker.GetURL(), invocation)
if allow {
diff --git a/filter/tps/filter_test.go b/filter/tps/filter_test.go
index 8e0a529..11f553d 100644
--- a/filter/tps/filter_test.go
+++ b/filter/tps/filter_test.go
@@ -44,7 +44,7 @@
tpsFilter := &Filter{}
invokeUrl := common.NewURLWithOptions(
common.WithParams(url.Values{}),
- common.WithParamsValue(constant.TPS_LIMITER_KEY, ""))
+ common.WithParamsValue(constant.TPSLimiterKey, ""))
attch := make(map[string]interface{})
result := tpsFilter.Invoke(context.Background(),
@@ -60,14 +60,14 @@
defer ctrl.Finish()
mockLimiter := limiter.NewMockTpsLimiter(ctrl)
mockLimiter.EXPECT().IsAllowable(gomock.Any(), gomock.Any()).Return(true).Times(1)
- extension.SetTpsLimiter(constant.DEFAULT_KEY, func() filter.TpsLimiter {
+ extension.SetTpsLimiter(constant.DefaultKey, func() filter.TpsLimiter {
return mockLimiter
})
tpsFilter := &Filter{}
invokeUrl := common.NewURLWithOptions(
common.WithParams(url.Values{}),
- common.WithParamsValue(constant.TPS_LIMITER_KEY, constant.DEFAULT_KEY))
+ common.WithParamsValue(constant.TPSLimiterKey, constant.DefaultKey))
attch := make(map[string]interface{})
result := tpsFilter.Invoke(context.Background(),
@@ -83,7 +83,7 @@
defer ctrl.Finish()
mockLimiter := limiter.NewMockTpsLimiter(ctrl)
mockLimiter.EXPECT().IsAllowable(gomock.Any(), gomock.Any()).Return(false).Times(1)
- extension.SetTpsLimiter(constant.DEFAULT_KEY, func() filter.TpsLimiter {
+ extension.SetTpsLimiter(constant.DefaultKey, func() filter.TpsLimiter {
return mockLimiter
})
@@ -91,14 +91,14 @@
mockRejectedHandler := handler.NewMockRejectedExecutionHandler(ctrl)
mockRejectedHandler.EXPECT().RejectedExecution(gomock.Any(), gomock.Any()).Return(mockResult).Times(1)
- extension.SetRejectedExecutionHandler(constant.DEFAULT_KEY, func() filter.RejectedExecutionHandler {
+ extension.SetRejectedExecutionHandler(constant.DefaultKey, func() filter.RejectedExecutionHandler {
return mockRejectedHandler
})
tpsFilter := &Filter{}
invokeUrl := common.NewURLWithOptions(
common.WithParams(url.Values{}),
- common.WithParamsValue(constant.TPS_LIMITER_KEY, constant.DEFAULT_KEY))
+ common.WithParamsValue(constant.TPSLimiterKey, constant.DefaultKey))
attch := make(map[string]interface{})
result := tpsFilter.Invoke(context.Background(),
diff --git a/filter/tps/limiter/method_service.go b/filter/tps/limiter/method_service.go
index ff3817c..41c16f8 100644
--- a/filter/tps/limiter/method_service.go
+++ b/filter/tps/limiter/method_service.go
@@ -40,7 +40,7 @@
)
func init() {
- extension.SetTpsLimiter(constant.DEFAULT_KEY, GetMethodServiceTpsLimiter)
+ extension.SetTpsLimiter(constant.DefaultKey, GetMethodServiceTpsLimiter)
extension.SetTpsLimiter(name, GetMethodServiceTpsLimiter)
}
@@ -123,8 +123,8 @@
func (limiter MethodServiceTpsLimiter) IsAllowable(url *common.URL, invocation protocol.Invocation) bool {
methodConfigPrefix := "methods." + invocation.MethodName() + "."
- methodLimitRateConfig := url.GetParam(methodConfigPrefix+constant.TPS_LIMIT_RATE_KEY, "")
- methodIntervalConfig := url.GetParam(methodConfigPrefix+constant.TPS_LIMIT_INTERVAL_KEY, "")
+ methodLimitRateConfig := url.GetParam(methodConfigPrefix+constant.TPSLimitRateKey, "")
+ methodIntervalConfig := url.GetParam(methodConfigPrefix+constant.TPSLimitIntervalKey, "")
// service-level tps limit
limitTarget := url.ServiceKey()
@@ -145,8 +145,8 @@
// we could not find the limiter, and try to create one.
limitRate := getLimitConfig(methodLimitRateConfig, url, invocation,
- constant.TPS_LIMIT_RATE_KEY,
- constant.DEFAULT_TPS_LIMIT_RATE)
+ constant.TPSLimitRateKey,
+ constant.DefaultTPSLimitRate)
if limitRate < 0 {
// the limitTarget is not necessary to be limited.
@@ -154,15 +154,15 @@
}
limitInterval := getLimitConfig(methodIntervalConfig, url, invocation,
- constant.TPS_LIMIT_INTERVAL_KEY,
- constant.DEFAULT_TPS_LIMIT_INTERVAL)
+ constant.TPSLimitIntervalKey,
+ constant.DefaultTPSLimitInterval)
if limitInterval <= 0 {
panic(fmt.Sprintf("The interval must be positive, please check your configuration! url: %s", url.String()))
}
// find the strategy config and then create one
- limitStrategyConfig := url.GetParam(methodConfigPrefix+constant.TPS_LIMIT_STRATEGY_KEY,
- url.GetParam(constant.TPS_LIMIT_STRATEGY_KEY, constant.DEFAULT_KEY))
+ limitStrategyConfig := url.GetParam(methodConfigPrefix+constant.TPSLimitStrategyKey,
+ url.GetParam(constant.TPSLimitStrategyKey, constant.DefaultKey))
limitStateCreator := extension.GetTpsLimitStrategyCreator(limitStrategyConfig)
// we using loadOrStore to ensure thread-safe
diff --git a/filter/tps/limiter/method_service_test.go b/filter/tps/limiter/method_service_test.go
index b72954c..21886fe 100644
--- a/filter/tps/limiter/method_service_test.go
+++ b/filter/tps/limiter/method_service_test.go
@@ -47,12 +47,12 @@
invokeUrl := common.NewURLWithOptions(
common.WithParams(url.Values{}),
common.WithParamsValue(constant.InterfaceKey, methodName),
- common.WithParamsValue(constant.TPS_LIMIT_RATE_KEY, "20"))
+ common.WithParamsValue(constant.TPSLimitRateKey, "20"))
mockStrategyImpl := strategy.NewMockTpsLimitStrategy(ctrl)
mockStrategyImpl.EXPECT().IsAllowable().Return(true).Times(1)
- extension.SetTpsLimitStrategy(constant.DEFAULT_KEY, &mockStrategyCreator{
+ extension.SetTpsLimitStrategy(constant.DefaultKey, &mockStrategyCreator{
rate: 20,
interval: 60000,
t: t,
@@ -73,7 +73,7 @@
invokeUrl := common.NewURLWithOptions(
common.WithParams(url.Values{}),
common.WithParamsValue(constant.InterfaceKey, methodName),
- common.WithParamsValue(constant.TPS_LIMIT_RATE_KEY, ""))
+ common.WithParamsValue(constant.TPSLimitRateKey, ""))
limiter := GetMethodServiceTpsLimiter()
result := limiter.IsAllowable(invokeUrl, invoc)
@@ -90,18 +90,18 @@
invokeUrl := common.NewURLWithOptions(
common.WithParams(url.Values{}),
common.WithParamsValue(constant.InterfaceKey, methodName),
- common.WithParamsValue(constant.TPS_LIMIT_RATE_KEY, "20"),
- common.WithParamsValue(constant.TPS_LIMIT_INTERVAL_KEY, "3000"),
- common.WithParamsValue(constant.TPS_LIMIT_STRATEGY_KEY, "invalid"),
- common.WithParamsValue(methodConfigPrefix+constant.TPS_LIMIT_RATE_KEY, "40"),
- common.WithParamsValue(methodConfigPrefix+constant.TPS_LIMIT_INTERVAL_KEY, "7000"),
- common.WithParamsValue(methodConfigPrefix+constant.TPS_LIMIT_STRATEGY_KEY, "default"),
+ common.WithParamsValue(constant.TPSLimitRateKey, "20"),
+ common.WithParamsValue(constant.TPSLimitIntervalKey, "3000"),
+ common.WithParamsValue(constant.TPSLimitStrategyKey, "invalid"),
+ common.WithParamsValue(methodConfigPrefix+constant.TPSLimitRateKey, "40"),
+ common.WithParamsValue(methodConfigPrefix+constant.TPSLimitIntervalKey, "7000"),
+ common.WithParamsValue(methodConfigPrefix+constant.TPSLimitStrategyKey, "default"),
)
mockStrategyImpl := strategy.NewMockTpsLimitStrategy(ctrl)
mockStrategyImpl.EXPECT().IsAllowable().Return(true).Times(1)
- extension.SetTpsLimitStrategy(constant.DEFAULT_KEY, &mockStrategyCreator{
+ extension.SetTpsLimitStrategy(constant.DefaultKey, &mockStrategyCreator{
rate: 40,
interval: 7000,
t: t,
@@ -123,15 +123,15 @@
invokeUrl := common.NewURLWithOptions(
common.WithParams(url.Values{}),
common.WithParamsValue(constant.InterfaceKey, methodName),
- common.WithParamsValue(constant.TPS_LIMIT_RATE_KEY, "20"),
- common.WithParamsValue(constant.TPS_LIMIT_INTERVAL_KEY, "3000"),
- common.WithParamsValue(methodConfigPrefix+constant.TPS_LIMIT_RATE_KEY, "40"),
+ common.WithParamsValue(constant.TPSLimitRateKey, "20"),
+ common.WithParamsValue(constant.TPSLimitIntervalKey, "3000"),
+ common.WithParamsValue(methodConfigPrefix+constant.TPSLimitRateKey, "40"),
)
mockStrategyImpl := strategy.NewMockTpsLimitStrategy(ctrl)
mockStrategyImpl.EXPECT().IsAllowable().Return(true).Times(1)
- extension.SetTpsLimitStrategy(constant.DEFAULT_KEY, &mockStrategyCreator{
+ extension.SetTpsLimitStrategy(constant.DefaultKey, &mockStrategyCreator{
rate: 40,
interval: 3000,
t: t,
diff --git a/filter/tps/strategy/fix_window.go b/filter/tps/strategy/fix_window.go
index 043e5bf..8b34bf9 100644
--- a/filter/tps/strategy/fix_window.go
+++ b/filter/tps/strategy/fix_window.go
@@ -36,7 +36,7 @@
func init() {
creator := &fixedWindowStrategyCreator{}
extension.SetTpsLimitStrategy(FixedWindowKey, creator)
- extension.SetTpsLimitStrategy(constant.DEFAULT_KEY, creator)
+ extension.SetTpsLimitStrategy(constant.DefaultKey, creator)
}
// FixedWindowTpsLimitStrategy implements the TPS limit strategy base on requests count during the interval
diff --git a/filter/tracing/filter.go b/filter/tracing/filter.go
index 0966966..920e659 100644
--- a/filter/tracing/filter.go
+++ b/filter/tracing/filter.go
@@ -55,7 +55,7 @@
)
operationName := invoker.GetURL().ServiceKey() + "#" + invocation.MethodName()
- wiredCtx := ctx.Value(constant.TRACING_REMOTE_SPAN_CTX)
+ wiredCtx := ctx.Value(constant.TracingRemoteSpanCtx)
preSpan := opentracing.SpanFromContext(ctx)
if preSpan != nil {
diff --git a/filter/tracing/filter_test.go b/filter/tracing/filter_test.go
index 9d28393..e56ab7b 100644
--- a/filter/tracing/filter_test.go
+++ b/filter/tracing/filter_test.go
@@ -57,6 +57,6 @@
tf.Invoke(ctx, invoker, inv)
// has remote ctx
- ctx = context.WithValue(context.Background(), constant.DubboCtxKey(constant.TRACING_REMOTE_SPAN_CTX), span.Context())
+ ctx = context.WithValue(context.Background(), constant.DubboCtxKey(constant.TracingRemoteSpanCtx), span.Context())
tf.Invoke(ctx, invoker, inv)
}
diff --git a/go.mod b/go.mod
index 1333f17..e64fef6 100644
--- a/go.mod
+++ b/go.mod
@@ -13,7 +13,7 @@
github.com/creasty/defaults v1.5.2
github.com/dubbogo/go-zookeeper v1.0.3
github.com/dubbogo/gost v1.11.19
- github.com/dubbogo/triple v1.0.8
+ github.com/dubbogo/triple v1.0.9
github.com/emicklei/go-restful/v3 v3.7.1
github.com/fsnotify/fsnotify v1.5.1
github.com/ghodss/yaml v1.0.0
@@ -23,7 +23,7 @@
github.com/golang/mock v1.4.4
github.com/golang/protobuf v1.5.2
github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645
- github.com/hashicorp/vault/sdk v0.2.1
+ github.com/hashicorp/vault/sdk v0.3.0
github.com/jinzhu/copier v0.3.2
github.com/knadh/koanf v1.3.0
github.com/magiconair/properties v1.8.5
@@ -31,6 +31,8 @@
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd
github.com/nacos-group/nacos-sdk-go v1.0.9
github.com/natefinch/lumberjack v2.0.0+incompatible
+ github.com/onsi/ginkgo v1.10.1 // indirect
+ github.com/onsi/gomega v1.7.0 // indirect
github.com/opentracing/opentracing-go v1.2.0
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.11.0
@@ -40,7 +42,7 @@
go.etcd.io/etcd/api/v3 v3.5.1
go.etcd.io/etcd/client/v3 v3.5.0
go.etcd.io/etcd/server/v3 v3.5.0-alpha.0
- go.uber.org/atomic v1.7.0
+ go.uber.org/atomic v1.9.0
go.uber.org/zap v1.19.1
google.golang.org/grpc v1.41.0
google.golang.org/protobuf v1.27.1
diff --git a/go.sum b/go.sum
index e995df9..abd128e 100644
--- a/go.sum
+++ b/go.sum
@@ -1,4 +1,3 @@
-bazil.org/fuse v0.0.0-20160811212531-371fbbdaa898/go.mod h1:Xbm+BRKSBEpa4q4hTSxohYNQpsxXPbPry4JJWOB3LB8=
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU=
@@ -35,7 +34,6 @@
contrib.go.opencensus.io/exporter/prometheus v0.4.0 h1:0QfIkj9z/iVZgK31D9H9ohjjIDApI2GOPScCKwxedbs=
contrib.go.opencensus.io/exporter/prometheus v0.4.0/go.mod h1:o7cosnyfuPVK0tB8q0QmaQNhGnptITnPQB+z1+qeFB0=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
-github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8=
github.com/Azure/go-autorest/autorest v0.9.0/go.mod h1:xyHB1BMZT0cuDHU7I0+g046+BFDTQ8rEZB0s4Yfa6bI=
github.com/Azure/go-autorest/autorest/adal v0.5.0/go.mod h1:8Z9fGy2MpX0PvDjB1pEgQTmVqjGhiHBW7RJJEciWzS0=
github.com/Azure/go-autorest/autorest/date v0.1.0/go.mod h1:plvfp3oPSKwf2DNjlBjWF/7vwR+cUD/ELuzDCXwHUVA=
@@ -49,8 +47,6 @@
github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
github.com/Julusian/godocdown v0.0.0-20170816220326-6d19f8ff2df8/go.mod h1:INZr5t32rG59/5xeltqoCJoNY7e5x/3xoY9WSWVWg74=
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
-github.com/Microsoft/go-winio v0.4.15-0.20190919025122-fc70bd9a86b5/go.mod h1:tTuCMEN+UleMWgg9dVx4Hu52b1bJo+59jBh3ajtinzw=
-github.com/Microsoft/hcsshim v0.8.9/go.mod h1:5692vkUqntj1idxauYlpoINNKeqCiG6Sg38RRsjT5y8=
github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/PuerkitoBio/purell v1.0.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
@@ -85,15 +81,12 @@
github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
-github.com/armon/go-metrics v0.3.0/go.mod h1:zXjbSimjXTd7vOpY8B0/2LpvNvDoXBuplAD+gJD3GYs=
-github.com/armon/go-metrics v0.3.3/go.mod h1:4O98XIr/9W0sxpJ8UaYkvjk10Iff7SnFrb4QAOwNTFc=
+github.com/armon/go-metrics v0.3.9/go.mod h1:4O98XIr/9W0sxpJ8UaYkvjk10Iff7SnFrb4QAOwNTFc=
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a/go.mod h1:DAHtR1m6lCRdSC2Tm3DSWRPvIPr6xNKyeHdqDQSQT+A=
github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU=
-github.com/aws/aws-sdk-go v1.25.37/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
-github.com/aws/aws-sdk-go v1.30.27/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0=
github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g=
github.com/aws/aws-sdk-go-v2 v1.9.2/go.mod h1:cK/D0BBs0b/oWPIcX/Z/obahJK1TT7IPVjy53i/mX/4=
github.com/aws/aws-sdk-go-v2/config v1.8.3/go.mod h1:4AEiLtAb8kLs7vgw2ZV3p2VZ1+hBavOc84hqxVNpCyw=
@@ -144,16 +137,6 @@
github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f h1:o/kfcElHqOiXqcou5a3rIlMc7oJbMQkeLk0VQJ7zgqY=
github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f/go.mod h1:i/u985jwjWRlyHXQbwatDASoW0RMlZ/3i9yJHE2xLkI=
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI=
-github.com/containerd/cgroups v0.0.0-20190919134610-bf292b21730f/go.mod h1:OApqhQ4XNSNC13gXIwDjhOQxjWa/NxkwZXJ1EvqT0ko=
-github.com/containerd/console v0.0.0-20180822173158-c12b1e7919c1/go.mod h1:Tj/on1eG8kiEhd0+fhSDzsPAFESxzBBvdyEgyryXffw=
-github.com/containerd/containerd v1.3.2/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA=
-github.com/containerd/containerd v1.3.4/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA=
-github.com/containerd/continuity v0.0.0-20190426062206-aaeac12a7ffc/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y=
-github.com/containerd/continuity v0.0.0-20200709052629-daa8e1ccc0bc/go.mod h1:cECdGN1O8G9bgKTlLhuPJimka6Xb/Gg7vYzCTNVxhvo=
-github.com/containerd/fifo v0.0.0-20190226154929-a9fb20d87448/go.mod h1:ODA38xgv3Kuk8dQz2ZQXpnv/UZZUHUCL7pnLehbXgQI=
-github.com/containerd/go-runc v0.0.0-20180907222934-5a6d9f37cfa3/go.mod h1:IV7qH3hrUgRmyYrtgEeGWJfWbgcHL9CSRruz2Vqcph0=
-github.com/containerd/ttrpc v0.0.0-20190828154514-0e0f228740de/go.mod h1:PvCDdDGpgqzQIzDW1TphrGLssLDZp2GuS+X5DkEJB8o=
-github.com/containerd/typeurl v0.0.0-20180627222232-a93fcdb778cd/go.mod h1:Cm3kwCdlkCfMSHURc+r6fwoGH6/F1hH3S4sg0rLFWPc=
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
@@ -180,10 +163,6 @@
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
-github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
-github.com/docker/docker v1.4.2-0.20200319182547-c7ad2b866182/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
-github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec=
-github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM=
github.com/dubbogo/go-zookeeper v1.0.3 h1:UkuY+rBsxdT7Bs63QAzp9z7XqQ53W1j8E5rwl83me8g=
github.com/dubbogo/go-zookeeper v1.0.3/go.mod h1:fn6n2CAEer3novYgk9ULLwAjuV8/g4DdC2ENwRb6E+c=
@@ -195,8 +174,8 @@
github.com/dubbogo/jsonparser v1.0.1/go.mod h1:tYAtpctvSP/tWw4MeelsowSPgXQRVHHWbqL6ynps8jU=
github.com/dubbogo/net v0.0.4 h1:Rn9aMPZwOiRE22YhtxmDEE3H0Q3cfVRNhuEjNMelJ/8=
github.com/dubbogo/net v0.0.4/go.mod h1:1CGOnM7X3he+qgGNqjeADuE5vKZQx/eMSeUkpU3ujIc=
-github.com/dubbogo/triple v1.0.8 h1:M3p2t+Bx6z1RbVMm4GjrZKFpe8Ar0g6J0m/6fYU46tQ=
-github.com/dubbogo/triple v1.0.8/go.mod h1:1t9me4j4CTvNDcsMZy6/OGarbRyAUSY0tFXGXHCp7Iw=
+github.com/dubbogo/triple v1.0.9 h1:piScEoTxmowYYFtLqPuYa0SojdSqe/+WNeGbMNkIXn4=
+github.com/dubbogo/triple v1.0.9/go.mod h1:1t9me4j4CTvNDcsMZy6/OGarbRyAUSY0tFXGXHCp7Iw=
github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
@@ -221,6 +200,7 @@
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/evanphx/json-patch v4.2.0+incompatible h1:fUDGZCv/7iAN7u0puUVhvKCcsR6vRfwrJatElLBEf0I=
github.com/evanphx/json-patch v4.2.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
+github.com/evanphx/json-patch/v5 v5.5.0/go.mod h1:G79N1coSVB93tBe7j6PhzjmR3/2VvlbKOFpnXhI9Bw4=
github.com/fastly/go-utils v0.0.0-20180712184237-d95a45783239 h1:Ghm4eQYC0nEPnSJdVkTrXpu9KtoVCSo1hg7mtI7G9KU=
github.com/fastly/go-utils v0.0.0-20180712184237-d95a45783239/go.mod h1:Gdwt2ce0yfBxPvZrHkprdPPTTS3N5rwmLE8T22KBXlw=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
@@ -256,7 +236,6 @@
github.com/go-kit/log v0.1.0 h1:DGJh0Sm43HbOeYDNnVZFl8BvcYVvjD5bqYJvp0REbwQ=
github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY=
github.com/go-ldap/ldap v3.0.2+incompatible/go.mod h1:qfd9rJvER9Q0/D/Sqn1DfHRoBp40uXYvFoEVrNEPqRc=
-github.com/go-ldap/ldap/v3 v3.1.3/go.mod h1:3rbOH3jRS2u6jg2rJnKAMLE/xQyCKIveG2Sa/Cohzb8=
github.com/go-ldap/ldap/v3 v3.1.10/go.mod h1:5Zun81jBTabRaI8lzN7E1JjyEl1g6zI6u9pd8luAK4Q=
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
@@ -280,12 +259,10 @@
github.com/go-resty/resty/v2 v2.3.0 h1:JOOeAvjSlapTT92p8xiS19Zxev1neGikoHsXJeOq8So=
github.com/go-resty/resty/v2 v2.3.0/go.mod h1:UpN9CgLZNsv4e9XG50UU8xdI0F43UQ4HmxLBDwaroHU=
github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
-github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/go-test/deep v1.0.2-0.20181118220953-042da051cf31/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA=
github.com/go-test/deep v1.0.2/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA=
-github.com/godbus/dbus v0.0.0-20190422162347-ade71ed3457e/go.mod h1:bBOAhwG1umN6/6ZUMtDFBMQR8jRg9O75tm9K00oMsK4=
github.com/godbus/dbus/v5 v5.0.3/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s=
@@ -332,8 +309,9 @@
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
-github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4=
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
+github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
+github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/btree v1.0.0 h1:0udJVsspx3VBr5FwtLhQQtuAsVc79tTq0ocGIPAU6qo=
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
@@ -377,7 +355,6 @@
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
-github.com/gorilla/mux v1.7.4/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
@@ -399,28 +376,33 @@
github.com/hashicorp/consul/api v1.3.0/go.mod h1:MmDNSzIMUjNpY/mQ398R4bk2FnqQLoPndWW5VkKPlCE=
github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8=
github.com/hashicorp/consul/sdk v0.3.0/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8=
-github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA=
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
+github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I=
+github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
github.com/hashicorp/go-hclog v0.0.0-20180709165350-ff2cf002a8dd/go.mod h1:9bjs9uLqI8l75knNv3lV1kA55veR+WUPSiKIWcQHudI=
github.com/hashicorp/go-hclog v0.8.0/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ=
-github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ=
-github.com/hashicorp/go-hclog v0.12.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ=
github.com/hashicorp/go-hclog v0.14.1/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ=
+github.com/hashicorp/go-hclog v0.16.2/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ=
github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
-github.com/hashicorp/go-immutable-radix v1.1.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
+github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
github.com/hashicorp/go-kms-wrapping/entropy v0.1.0/go.mod h1:d1g9WGtAunDNpek8jUIEJnBlbgKS1N2Q61QkHiZyR1g=
github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM=
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
-github.com/hashicorp/go-multierror v1.1.0/go.mod h1:spPvp8C1qA32ftKqdAHm4hHTbPw+vmowP0z+KUhOZdA=
+github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
github.com/hashicorp/go-plugin v1.0.1/go.mod h1:++UyYGoz3o5w9ZzAdZxtQKrWWP+iqPBn3cQptSMzBuY=
+github.com/hashicorp/go-plugin v1.4.3/go.mod h1:5fGEH17QVwTTcR0zV7yhDPLLmFX9YSZ38b18Udy6vYQ=
github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs=
github.com/hashicorp/go-retryablehttp v0.5.4/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs=
-github.com/hashicorp/go-retryablehttp v0.6.2/go.mod h1:gEx6HMUGxYYhJScX7W1Il64m6cc2C1mDaW3NQ9sY1FY=
-github.com/hashicorp/go-retryablehttp v0.6.6/go.mod h1:vAew36LZh98gCBJNLH42IQ1ER/9wtLZZ8meHqQvEYWY=
github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU=
github.com/hashicorp/go-rootcerts v1.0.1/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8=
+github.com/hashicorp/go-secure-stdlib/base62 v0.1.1/go.mod h1:EdWO6czbmthiwZ3/PUsDV+UD1D5IRU4ActiaWGwt0Yw=
+github.com/hashicorp/go-secure-stdlib/mlock v0.1.1/go.mod h1:zq93CJChV6L9QTfGKtfBxKqD7BqqXx5O04A/ns2p5+I=
+github.com/hashicorp/go-secure-stdlib/parseutil v0.1.1/go.mod h1:QmrqtbKuxxSWTN3ETMPuB+VtEiBJ/A9XhoYGv8E1uD8=
+github.com/hashicorp/go-secure-stdlib/password v0.1.1/go.mod h1:9hH302QllNwu1o2TGYtSk8I8kTAN0ca1EHpwhm5Mmzo=
+github.com/hashicorp/go-secure-stdlib/strutil v0.1.1/go.mod h1:gKOamz3EwoIoJq7mlMIRBpVTAUn8qPCrEclOKKWhD3U=
+github.com/hashicorp/go-secure-stdlib/tlsutil v0.1.1/go.mod h1:l8slYwnJA26yBz+ErHpp2IRCLr0vuOMGBORIz4rRiAs=
github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU=
github.com/hashicorp/go-sockaddr v1.0.2/go.mod h1:rB4wwRAUzs07qva3c5SdrY/NEtAUjGlgmH/UkBUC97A=
github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4=
@@ -432,8 +414,8 @@
github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90=
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
-github.com/hashicorp/golang-lru v0.5.3 h1:YPkqC67at8FYaadspW/6uE0COsBxS2656RLEr8Bppgk=
-github.com/hashicorp/golang-lru v0.5.3/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
+github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc=
+github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64=
@@ -441,11 +423,9 @@
github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I=
github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc=
github.com/hashicorp/vault/api v1.0.4/go.mod h1:gDcqh3WGcR1cpF5AJz/B1UFheUEneMoIospckxBxk6Q=
-github.com/hashicorp/vault/api v1.0.5-0.20200519221902-385fac77e20f/go.mod h1:euTFbi2YJgwcju3imEt919lhJKF68nN1cQPq3aA+kBE=
github.com/hashicorp/vault/sdk v0.1.13/go.mod h1:B+hVj7TpuQY1Y/GPbCpffmgd+tSEwvhkWnjtSYCaS2M=
-github.com/hashicorp/vault/sdk v0.1.14-0.20200519221530-14615acda45f/go.mod h1:WX57W2PwkrOPQ6rVQk+dy5/htHIaB4aBM70EwKThu10=
-github.com/hashicorp/vault/sdk v0.2.1 h1:S4O6Iv/dyKlE9AUTXGa7VOvZmsCvg36toPKgV4f2P4M=
-github.com/hashicorp/vault/sdk v0.2.1/go.mod h1:WfUiO1vYzfBkz1TmoE4ZGU7HD0T0Cl/rZwaxjBkgN4U=
+github.com/hashicorp/vault/sdk v0.3.0 h1:kR3dpxNkhh/wr6ycaJYqp6AFT/i2xaftbfnwZduTKEY=
+github.com/hashicorp/vault/sdk v0.3.0/go.mod h1:aZ3fNuL5VNydQk8GcLJ2TV8YCRVvyaakYkhZRoVuhj0=
github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM=
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM=
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
@@ -457,10 +437,11 @@
github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo=
github.com/jehiah/go-strftime v0.0.0-20171201141054-1d33003b3869 h1:IPJ3dvxmJ4uczJe5YQdrYB16oTJlGSC/OyZDqUk9xX4=
github.com/jehiah/go-strftime v0.0.0-20171201141054-1d33003b3869/go.mod h1:cJ6Cj7dQo+O6GJNiMx+Pa94qKj+TG8ONdKHgMNIyyag=
+github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
+github.com/jhump/protoreflect v1.6.0/go.mod h1:eaTn3RZAmMBcV0fifFvlm6VHNz3wSkYyXYWUh7ymB74=
github.com/jinzhu/copier v0.3.2 h1:QdBOCbaouLDYaIPFfi1bKv5F5tPpeTwXe4sD0jqtz5w=
github.com/jinzhu/copier v0.3.2/go.mod h1:24xnZezI2Yqac9J61UC6/dG/k76ttpq0DdJI3QmUvro=
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
-github.com/jmespath/go-jmespath v0.3.0/go.mod h1:9QtRXoHjLGCJ5IBSaohpXITPlowMeeYCZ7fLUTSywik=
github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8=
@@ -551,7 +532,6 @@
github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY=
github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
-github.com/mitchellh/mapstructure v1.3.2/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/mitchellh/mapstructure v1.4.2 h1:6h7AQ0yhTcIsmFmnAwQls75jp2Gzs4iB8W7pjMO+rqo=
github.com/mitchellh/mapstructure v1.4.2/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
@@ -566,7 +546,6 @@
github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/montanaflynn/stats v0.6.6/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow=
-github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc=
github.com/mschoch/smat v0.2.0 h1:8imxQsjDm8yFEAVBe7azKmKSgzSkZXDuKkSq9374khM=
github.com/mschoch/smat v0.2.0/go.mod h1:kc9mz7DoBKqDyiRL7VZN8KvXQMWeTaVnttLRXOlotKw=
github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
@@ -602,13 +581,6 @@
github.com/onsi/gomega v1.7.0 h1:XPnZz8VVBHjVsy1vzJmRwIcSwiUO+JFfrv/xGiigmME=
github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk=
-github.com/opencontainers/go-digest v0.0.0-20180430190053-c9281466c8b2/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s=
-github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s=
-github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
-github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0=
-github.com/opencontainers/runc v0.0.0-20190115041553-12f6a991201f/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U=
-github.com/opencontainers/runc v0.1.1/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U=
-github.com/opencontainers/runtime-spec v0.1.2-0.20190507144316-5b71a03e2700/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go.mod h1:Ngi6UdF0k5OKD5t5wlmGhe/EDKPoUM3BXZSSfIuJbis=
github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74=
github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
@@ -635,7 +607,6 @@
github.com/pierrec/lz4 v2.5.2+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
-github.com/pkg/errors v0.8.1-0.20171018195549-f15c970de5b7/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
@@ -645,7 +616,6 @@
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
-github.com/prometheus/client_golang v0.9.2/go.mod h1:OsXs2jCmiKlQ1lTBmv21f2mNfw4xf/QclQDMrYNZzcM=
github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs=
github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso=
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
@@ -664,7 +634,6 @@
github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M=
github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro=
-github.com/prometheus/common v0.0.0-20181126121408-4724e9255275/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro=
github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
@@ -675,9 +644,7 @@
github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc=
github.com/prometheus/common v0.28.0 h1:vGVfV9KrDTvWt5boZO0I19g2E3CsWfpPPKZM9dt3mEw=
github.com/prometheus/common v0.28.0/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls=
-github.com/prometheus/procfs v0.0.0-20180125133057-cb4147076ac7/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
-github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
@@ -711,9 +678,7 @@
github.com/shirou/gopsutil v3.20.11+incompatible h1:LJr4ZQK4mPpIV5gOa4jCOKOGb4ty4DZO54I4FGqIpto=
github.com/shirou/gopsutil v3.20.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
-github.com/sirupsen/logrus v1.0.4-0.20170822132746-89742aefa4b2/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
-github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
github.com/sirupsen/logrus v1.7.0 h1:ShrD1U9pZB12TX0cVy0DtePoCH97K8EtX+mg7ZARUtM=
@@ -733,13 +698,11 @@
github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk=
github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8=
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
-github.com/spf13/cobra v0.0.2-0.20171109065643-2da4a54c5cee/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
github.com/spf13/cobra v1.1.1/go.mod h1:WnodtKOvamDL/PwE2M4iKs8aMDBZ5Q5klgD3qfVJQMI=
github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9Gc1vn7yk=
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
github.com/spf13/pflag v0.0.0-20170130214245-9ff6c6923cff/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
-github.com/spf13/pflag v1.0.1-0.20171106142849-4c012f6dcd95/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
@@ -780,7 +743,6 @@
github.com/ugorji/go v1.2.6/go.mod h1:anCg0y61KIhDlPZmnH+so+RQbysYVyDko0IMgJv0Nn0=
github.com/ugorji/go/codec v1.2.6 h1:7kbGefxLoDBuYXOms4yD7223OpNMMPNPZxXk5TvFcyQ=
github.com/ugorji/go/codec v1.2.6/go.mod h1:V6TCNZ4PHqoHGFZuSG1W8nrCzzdgA2DozYxWFFpvxTw=
-github.com/urfave/cli v0.0.0-20171014202726-7bc6a0acffa5/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 h1:eY9dn8+vbi4tKz5Qo6v2eYzo7kUS51QINcR5jNpbZS8=
@@ -829,8 +791,9 @@
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
-go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw=
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
+go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE=
+go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/goleak v1.1.11-0.20210813005559-691160354723 h1:sHOAIxRGBp443oHZIPB+HsUGaksVCXVQENPxwTfQdH4=
go.uber.org/goleak v1.1.11-0.20210813005559-691160354723/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ=
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
@@ -846,18 +809,15 @@
go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo=
go.uber.org/zap v1.19.1 h1:ue41HOKd1vGURxrmeKIgELGb3jPW9DMUDGtsinblHwI=
go.uber.org/zap v1.19.1/go.mod h1:j3DNczoxDZroyBnOT1L/Q79cfUMGZxlv/9dzN7SM1rI=
-golang.org/x/crypto v0.0.0-20171113213409-9f005a07e0d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190211182817-74369b46fc67/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
-golang.org/x/crypto v0.0.0-20190418165655-df01cb2cc480/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE=
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200220183623-bac4c82f6975/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
-golang.org/x/crypto v0.0.0-20200604202706-70a84ac30bf9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 h1:/UOmuWzQfxxo9UtlXMwuQU8CMgg1eZXqTRwkSQJWKOI=
@@ -898,6 +858,7 @@
golang.org/x/mod v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20170114055629-f2499483f923/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/net v0.0.0-20180530234432-1e491301e022/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
@@ -932,7 +893,6 @@
golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
-golang.org/x/net v0.0.0-20200602114024-627f9648deb9/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
@@ -981,13 +941,11 @@
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20190514135907-3a4b5fb9f71f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -1010,7 +968,6 @@
golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20200602225109-6fdc65e7d980/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -1045,7 +1002,6 @@
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
-golang.org/x/time v0.0.0-20200416051211-89c76fbcd5d1/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20201208040808-7e3f01d25324 h1:Hir2P/De0WpUhtrKGGjvSb2YxUgyZ7EFOSLIcSSpiwE=
golang.org/x/time v0.0.0-20201208040808-7e3f01d25324/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
@@ -1065,7 +1021,6 @@
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
-golang.org/x/tools v0.0.0-20190624222133-a101b041ded4/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
@@ -1136,6 +1091,7 @@
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
google.golang.org/appengine v1.6.6 h1:lMO5rYAqUxkmaj76jAkRUvt5JZgFymx/+Q5Mzfivuhc=
google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
+google.golang.org/genproto v0.0.0-20170818010345-ee236bd376b0/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
google.golang.org/genproto v0.0.0-20190404172233-64821d5d2107/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
@@ -1173,6 +1129,7 @@
google.golang.org/genproto v0.0.0-20210106152847-07624b53cd92/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c h1:wtujag7C+4D6KMoulW9YauvK2lgdvCMS260jsqqBXr0=
google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0=
+google.golang.org/grpc v1.8.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw=
google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw=
google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
@@ -1213,7 +1170,6 @@
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ=
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
-gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d/go.mod h1:cuepJuh7vyXfUyUwEgHQXw849cJrilpS5NeIjOWESAw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
@@ -1227,7 +1183,6 @@
gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o=
-gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2/go.mod h1:Xk6kEKp8OKb+X14hQBKWaSkCsqBpgog8nAV2xsGOxlo=
gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc=
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
gopkg.in/ini.v1 v1.42.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
@@ -1237,7 +1192,6 @@
gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k=
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
gopkg.in/square/go-jose.v2 v2.3.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI=
-gopkg.in/square/go-jose.v2 v2.5.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
@@ -1256,7 +1210,6 @@
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo=
gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
-gotest.tools/v3 v3.0.2/go.mod h1:3SzNCllyD9/Y+b5r9JIKQ474KzkZyqLqEfYqMsX94Bk=
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
diff --git a/metadata/definition/definition.go b/metadata/definition/definition.go
index 1278416..695ca84 100644
--- a/metadata/definition/definition.go
+++ b/metadata/definition/definition.go
@@ -126,11 +126,11 @@
buf := &bytes.Buffer{}
if group != "" {
buf.WriteString(group)
- buf.WriteString(constant.PATH_SEPARATOR)
+ buf.WriteString(constant.PathSeparator)
}
buf.WriteString(serviceName)
if version != "" && version != "0.0.0" {
- buf.WriteString(constant.KEY_SEPARATOR)
+ buf.WriteString(constant.KeySeparator)
buf.WriteString(version)
}
return buf.String()
diff --git a/metadata/identifier/base_metadata_identifier.go b/metadata/identifier/base_metadata_identifier.go
index 9659e45..6bb3c28 100644
--- a/metadata/identifier/base_metadata_identifier.go
+++ b/metadata/identifier/base_metadata_identifier.go
@@ -52,27 +52,27 @@
// getIdentifierKey returns string that format is service:Version:Group:Side:param1:param2...
func (mdi *BaseMetadataIdentifier) getIdentifierKey(params ...string) string {
return mdi.ServiceInterface +
- constant.KEY_SEPARATOR + mdi.Version +
- constant.KEY_SEPARATOR + mdi.Group +
- constant.KEY_SEPARATOR + mdi.Side +
- joinParams(constant.KEY_SEPARATOR, params)
+ constant.KeySeparator + mdi.Version +
+ constant.KeySeparator + mdi.Group +
+ constant.KeySeparator + mdi.Side +
+ joinParams(constant.KeySeparator, params)
}
// getFilePathKey returns string that format is metadata/path/Version/Group/Side/param1/param2...
func (mdi *BaseMetadataIdentifier) getFilePathKey(params ...string) string {
path := serviceToPath(mdi.ServiceInterface)
- return constant.DEFAULT_PATH_TAG +
+ return constant.DefaultPathTag +
withPathSeparator(path) +
withPathSeparator(mdi.Version) +
withPathSeparator(mdi.Group) +
withPathSeparator(mdi.Side) +
- joinParams(constant.PATH_SEPARATOR, params)
+ joinParams(constant.PathSeparator, params)
}
// serviceToPath uss URL encode to decode the @serviceInterface
func serviceToPath(serviceInterface string) string {
- if serviceInterface == constant.ANY_VALUE {
+ if serviceInterface == constant.AnyValue {
return ""
}
return url.PathEscape(serviceInterface)
@@ -81,7 +81,7 @@
// withPathSeparator return "/" + @path
func withPathSeparator(path string) string {
if len(path) != 0 {
- path = constant.PATH_SEPARATOR + path
+ path = constant.PathSeparator + path
}
return path
}
@@ -94,12 +94,12 @@
// getIdentifierKey returns string that format is application/param
func (madi *BaseApplicationMetadataIdentifier) getIdentifierKey(params ...string) string {
- return madi.Application + joinParams(constant.KEY_SEPARATOR, params)
+ return madi.Application + joinParams(constant.KeySeparator, params)
}
// getFilePathKey returns string that format is metadata/application/revision
func (madi *BaseApplicationMetadataIdentifier) getFilePathKey(params ...string) string {
- return constant.DEFAULT_PATH_TAG +
+ return constant.DefaultPathTag +
withPathSeparator(madi.Application) +
- joinParams(constant.PATH_SEPARATOR, params)
+ joinParams(constant.PathSeparator, params)
}
diff --git a/metadata/identifier/service_metadata_identifier.go b/metadata/identifier/service_metadata_identifier.go
index c80bcd7..f555e22 100644
--- a/metadata/identifier/service_metadata_identifier.go
+++ b/metadata/identifier/service_metadata_identifier.go
@@ -46,10 +46,10 @@
// GetIdentifierKey returns string that format is service:Version:Group:Side:Protocol:"revision"+Revision
func (mdi *ServiceMetadataIdentifier) GetIdentifierKey() string {
- return mdi.BaseMetadataIdentifier.getIdentifierKey(mdi.Protocol, constant.KEY_REVISON_PREFIX+mdi.Revision)
+ return mdi.BaseMetadataIdentifier.getIdentifierKey(mdi.Protocol, constant.KeyRevisionPrefix+mdi.Revision)
}
// GetFilePathKey returns string that format is metadata/path/Version/Group/Side/Protocol/"revision"+Revision
func (mdi *ServiceMetadataIdentifier) GetFilePathKey() string {
- return mdi.BaseMetadataIdentifier.getFilePathKey(mdi.Protocol, constant.KEY_REVISON_PREFIX+mdi.Revision)
+ return mdi.BaseMetadataIdentifier.getFilePathKey(mdi.Protocol, constant.KeyRevisionPrefix+mdi.Revision)
}
diff --git a/metadata/identifier/subscribe_metadata_identifier.go b/metadata/identifier/subscribe_metadata_identifier.go
index ee83b5a..1e0c5e3 100644
--- a/metadata/identifier/subscribe_metadata_identifier.go
+++ b/metadata/identifier/subscribe_metadata_identifier.go
@@ -32,7 +32,7 @@
Revision: revision,
BaseApplicationMetadataIdentifier: BaseApplicationMetadataIdentifier{
Application: application,
- Group: constant.DUBBO,
+ Group: constant.Dubbo,
},
}
}
diff --git a/metadata/mapping/metadata/service_name_mapping.go b/metadata/mapping/metadata/service_name_mapping.go
index e392540..550fc4f 100644
--- a/metadata/mapping/metadata/service_name_mapping.go
+++ b/metadata/mapping/metadata/service_name_mapping.go
@@ -55,7 +55,7 @@
func (d *MetadataServiceNameMapping) Map(url *common.URL) error {
serviceInterface := url.GetParam(constant.InterfaceKey, "")
// metadata service is admin service, should not be mapped
- if constant.METADATA_SERVICE_NAME == serviceInterface {
+ if constant.MetadataServiceName == serviceInterface {
logger.Info("try to map the metadata service, will be ignored")
return nil
}
diff --git a/metadata/report/delegate/delegate_report.go b/metadata/report/delegate/delegate_report.go
index 7eec8e7..540ab3f 100644
--- a/metadata/report/delegate/delegate_report.go
+++ b/metadata/report/delegate/delegate_report.go
@@ -117,14 +117,14 @@
}
bmr := &MetadataReport{
reportUrl: url,
- syncReport: url.GetParamBool(constant.SYNC_REPORT_KEY, false),
+ syncReport: url.GetParamBool(constant.SyncReportKey, false),
failedReports: make(map[*identifier.MetadataIdentifier]interface{}, 4),
allMetadataReports: make(map[*identifier.MetadataIdentifier]interface{}, 4),
}
mrr, err := newMetadataReportRetry(
- url.GetParamInt(constant.RETRY_PERIOD_KEY, defaultMetadataReportRetryPeriod),
- url.GetParamInt(constant.RETRY_TIMES_KEY, defaultMetadataReportRetryTimes),
+ url.GetParamInt(constant.RetryPeriodKey, defaultMetadataReportRetryPeriod),
+ url.GetParamInt(constant.RetryTimesKey, defaultMetadataReportRetryTimes),
bmr.retry,
)
if err != nil {
@@ -132,7 +132,7 @@
}
bmr.metadataReportRetry = mrr
- if url.GetParamBool(constant.CYCLE_REPORT_KEY, defaultMetadataReportCycleReport) {
+ if url.GetParamBool(constant.CycleReportKey, defaultMetadataReportCycleReport) {
scheduler := gocron.NewScheduler(time.UTC)
_, err := scheduler.Every(1).Day().Do(
func() {
diff --git a/metadata/report/delegate/delegate_report_test.go b/metadata/report/delegate/delegate_report_test.go
index 5d2b40b..631e6c0 100644
--- a/metadata/report/delegate/delegate_report_test.go
+++ b/metadata/report/delegate/delegate_report_test.go
@@ -75,8 +75,8 @@
cycleReportKey := "true"
url, err := common.NewURL(fmt.Sprintf(
- "test://127.0.0.1:20000/?"+constant.SYNC_REPORT_KEY+"=%v&"+constant.RETRY_PERIOD_KEY+"=%v&"+
- constant.RETRY_TIMES_KEY+"=%v&"+constant.CYCLE_REPORT_KEY+"=%v",
+ "test://127.0.0.1:20000/?"+constant.SyncReportKey+"=%v&"+constant.RetryPeriodKey+"=%v&"+
+ constant.RetryTimesKey+"=%v&"+constant.CycleReportKey+"=%v",
syncReportKey, retryPeriodKey, retryTimesKey, cycleReportKey))
assert.NoError(t, err)
instance.SetMetadataReportUrl(url)
diff --git a/metadata/report/etcd/report.go b/metadata/report/etcd/report.go
index 195ffe1..ee439d6 100644
--- a/metadata/report/etcd/report.go
+++ b/metadata/report/etcd/report.go
@@ -42,7 +42,7 @@
const DEFAULT_ROOT = "dubbo"
func init() {
- extension.SetMetadataReportFactory(constant.ETCDV3_KEY, func() factory.MetadataReportFactory {
+ extension.SetMetadataReportFactory(constant.EtcdV3Key, func() factory.MetadataReportFactory {
return &etcdMetadataReportFactory{}
})
}
@@ -146,7 +146,7 @@
// RegisterServiceAppMapping map the specified Dubbo service interface to current Dubbo app name
func (e *etcdMetadataReport) RegisterServiceAppMapping(key string, group string, value string) error {
- path := e.root + constant.PATH_SEPARATOR + group + constant.PATH_SEPARATOR + key
+ path := e.root + constant.PathSeparator + group + constant.PathSeparator + key
oldVal, err := e.client.Get(path)
if perrors.Cause(err) == gxetcd.ErrKVPairNotFound {
return e.client.Put(path, value)
@@ -156,18 +156,18 @@
if strings.Contains(oldVal, value) {
return nil
}
- value = oldVal + constant.COMMA_SEPARATOR + value
+ value = oldVal + constant.CommaSeparator + value
return e.client.Put(path, value)
}
// GetServiceAppMapping get the app names from the specified Dubbo service interface
func (e *etcdMetadataReport) GetServiceAppMapping(key string, group string) (*gxset.HashSet, error) {
- path := e.root + constant.PATH_SEPARATOR + group + constant.PATH_SEPARATOR + key
+ path := e.root + constant.PathSeparator + group + constant.PathSeparator + key
v, err := e.client.Get(path)
if err != nil {
return nil, err
}
- appNames := strings.Split(v, constant.COMMA_SEPARATOR)
+ appNames := strings.Split(v, constant.CommaSeparator)
set := gxset.NewSet()
for _, app := range appNames {
set.Add(app)
@@ -179,7 +179,7 @@
// CreateMetadataReport get the MetadataReport instance of etcd
func (e *etcdMetadataReportFactory) CreateMetadataReport(url *common.URL) report.MetadataReport {
- timeout := url.GetParamDuration(constant.CONFIG_TIMEOUT_KEY, constant.DEFAULT_REG_TIMEOUT)
+ timeout := url.GetParamDuration(constant.ConfigTimeoutKey, constant.DefaultRegTimeout)
addresses := strings.Split(url.Location, ",")
client, err := gxetcd.NewClient(gxetcd.MetadataETCDV3Client, addresses, timeout, 1)
if err != nil {
@@ -187,16 +187,16 @@
return nil
}
group := url.GetParam(constant.GroupKey, DEFAULT_ROOT)
- group = constant.PATH_SEPARATOR + strings.TrimPrefix(group, constant.PATH_SEPARATOR)
+ group = constant.PathSeparator + strings.TrimPrefix(group, constant.PathSeparator)
return &etcdMetadataReport{client: client, root: group}
}
func (e *etcdMetadataReport) getNodeKey(MetadataIdentifier identifier.IMetadataIdentifier) string {
var rootDir string
- if e.root == constant.PATH_SEPARATOR {
+ if e.root == constant.PathSeparator {
rootDir = e.root
} else {
- rootDir = e.root + constant.PATH_SEPARATOR
+ rootDir = e.root + constant.PathSeparator
}
return rootDir + MetadataIdentifier.GetFilePathKey()
}
diff --git a/metadata/report/nacos/report.go b/metadata/report/nacos/report.go
index 37e17d2..645dc78 100644
--- a/metadata/report/nacos/report.go
+++ b/metadata/report/nacos/report.go
@@ -222,7 +222,7 @@
return nil
}
if oldVal != "" {
- value = oldVal + constant.COMMA_SEPARATOR + value
+ value = oldVal + constant.CommaSeparator + value
}
return n.storeMetadata(vo.ConfigParam{
DataId: key,
@@ -243,7 +243,7 @@
if v == "" {
return nil, perrors.New("There is no service app mapping data.")
}
- appNames := strings.Split(v, constant.COMMA_SEPARATOR)
+ appNames := strings.Split(v, constant.CommaSeparator)
set := gxset.NewSet()
for _, e := range appNames {
set.Add(e)
diff --git a/metadata/report/zookeeper/report.go b/metadata/report/zookeeper/report.go
index 14c9938..2a665f9 100644
--- a/metadata/report/zookeeper/report.go
+++ b/metadata/report/zookeeper/report.go
@@ -145,7 +145,7 @@
// RegisterServiceAppMapping map the specified Dubbo service interface to current Dubbo app name
func (m *zookeeperMetadataReport) RegisterServiceAppMapping(key string, group string, value string) error {
- path := m.rootDir + group + constant.PATH_SEPARATOR + key
+ path := m.rootDir + group + constant.PathSeparator + key
v, state, err := m.client.GetContent(path)
if err == zk.ErrNoNode {
return m.client.CreateWithValue(path, []byte(value))
@@ -156,19 +156,19 @@
if strings.Contains(oldValue, value) {
return nil
}
- value = oldValue + constant.COMMA_SEPARATOR + value
+ value = oldValue + constant.CommaSeparator + value
_, err = m.client.SetContent(path, []byte(value), state.Version)
return err
}
// GetServiceAppMapping get the app names from the specified Dubbo service interface
func (m *zookeeperMetadataReport) GetServiceAppMapping(key string, group string) (*gxset.HashSet, error) {
- path := m.rootDir + group + constant.PATH_SEPARATOR + key
+ path := m.rootDir + group + constant.PathSeparator + key
v, _, err := m.client.GetContent(path)
if err != nil {
return nil, err
}
- appNames := strings.Split(string(v), constant.COMMA_SEPARATOR)
+ appNames := strings.Split(string(v), constant.CommaSeparator)
set := gxset.NewSet()
for _, e := range appNames {
set.Add(e)
@@ -191,11 +191,11 @@
}
rootDir := url.GetParam(constant.GroupKey, "dubbo")
- if !strings.HasPrefix(rootDir, constant.PATH_SEPARATOR) {
- rootDir = constant.PATH_SEPARATOR + rootDir
+ if !strings.HasPrefix(rootDir, constant.PathSeparator) {
+ rootDir = constant.PathSeparator + rootDir
}
- if rootDir != constant.PATH_SEPARATOR {
- rootDir = rootDir + constant.PATH_SEPARATOR
+ if rootDir != constant.PathSeparator {
+ rootDir = rootDir + constant.PathSeparator
}
return &zookeeperMetadataReport{client: client, rootDir: rootDir}
diff --git a/metadata/service/exporter/configurable/exporter.go b/metadata/service/exporter/configurable/exporter.go
index 5675b65..84a9449 100644
--- a/metadata/service/exporter/configurable/exporter.go
+++ b/metadata/service/exporter/configurable/exporter.go
@@ -42,7 +42,7 @@
}
func init() {
- extension.SetMetadataServiceExporter(constant.DEFAULT_Key, NewMetadataServiceExporter)
+ extension.SetMetadataServiceExporter(constant.DefaultKey, NewMetadataServiceExporter)
}
// NewMetadataServiceExporter will return a service_exporter.MetadataServiceExporter with the specified metadata service
@@ -59,17 +59,17 @@
exporter.lock.Lock()
defer exporter.lock.Unlock()
exporter.ServiceConfig = config.NewServiceConfigBuilder().
- SetServiceID(constant.SIMPLE_METADATA_SERVICE_NAME).
- SetProtocolIDs(constant.DEFAULT_PROTOCOL).
- AddRCProtocol(constant.DEFAULT_PROTOCOL, config.NewProtocolConfigBuilder().
- SetName(constant.DEFAULT_PROTOCOL).
+ SetServiceID(constant.SimpleMetadataServiceName).
+ SetProtocolIDs(constant.DefaultProtocol).
+ AddRCProtocol(constant.DefaultProtocol, config.NewProtocolConfigBuilder().
+ SetName(constant.DefaultProtocol).
Build()).
SetRegistryIDs("N/A").
- SetInterface(constant.METADATA_SERVICE_NAME).
+ SetInterface(constant.MetadataServiceName).
SetGroup(config.GetApplicationConfig().Name).
SetVersion(version).
- SetProxyFactoryKey(constant.DEFAULT_Key).
- SetMetadataType(constant.REMOTE_METADATA_STORAGE_TYPE).
+ SetProxyFactoryKey(constant.DefaultKey).
+ SetMetadataType(constant.RemoteMetadataStorageType).
Build()
exporter.ServiceConfig.Implement(exporter.metadataService)
err := exporter.ServiceConfig.Export()
diff --git a/metadata/service/local/metadata_service_proxy_factory.go b/metadata/service/local/metadata_service_proxy_factory.go
index 5c38e14..ee9c292 100644
--- a/metadata/service/local/metadata_service_proxy_factory.go
+++ b/metadata/service/local/metadata_service_proxy_factory.go
@@ -33,7 +33,7 @@
func init() {
factory := service.NewBaseMetadataServiceProxyFactory(createProxy)
- extension.SetMetadataServiceProxyFactory(constant.DEFAULT_KEY, func() service.MetadataServiceProxyFactory {
+ extension.SetMetadataServiceProxyFactory(constant.DefaultKey, func() service.MetadataServiceProxyFactory {
return factory
})
}
@@ -72,7 +72,7 @@
// buildStandardMetadataServiceURL will use standard format to build the metadata service url.
func buildStandardMetadataServiceURL(ins registry.ServiceInstance) []*common.URL {
ps := getMetadataServiceUrlParams(ins)
- if ps[constant.PROTOCOL_KEY] == "" {
+ if ps[constant.ProtocolKey] == "" {
return nil
}
res := make([]*common.URL, 0, len(ps))
@@ -83,12 +83,12 @@
convertedParams[k] = []string{v}
}
u := common.NewURLWithOptions(common.WithIp(host),
- common.WithPath(constant.METADATA_SERVICE_NAME),
- common.WithProtocol(ps[constant.PROTOCOL_KEY]),
- common.WithPort(ps[constant.PORT_KEY]),
+ common.WithPath(constant.MetadataServiceName),
+ common.WithProtocol(ps[constant.ProtocolKey]),
+ common.WithPort(ps[constant.PortKey]),
common.WithParams(convertedParams),
common.WithParamsValue(constant.GroupKey, sn),
- common.WithParamsValue(constant.InterfaceKey, constant.METADATA_SERVICE_NAME))
+ common.WithParamsValue(constant.InterfaceKey, constant.MetadataServiceName))
res = append(res, u)
return res
@@ -100,7 +100,7 @@
func getMetadataServiceUrlParams(ins registry.ServiceInstance) map[string]string {
ps := ins.GetMetadata()
res := make(map[string]string, 2)
- if str, ok := ps[constant.METADATA_SERVICE_URL_PARAMS_PROPERTY_NAME]; ok && len(str) > 0 {
+ if str, ok := ps[constant.MetadataServiceURLParamsPropertyName]; ok && len(str) > 0 {
err := json.Unmarshal([]byte(str), &res)
if err != nil {
diff --git a/metadata/service/local/metadata_service_proxy_factory_test.go b/metadata/service/local/metadata_service_proxy_factory_test.go
index b20ca93..95665ba 100644
--- a/metadata/service/local/metadata_service_proxy_factory_test.go
+++ b/metadata/service/local/metadata_service_proxy_factory_test.go
@@ -57,7 +57,7 @@
pxy := createProxy(ins)
assert.Nil(t, pxy)
- ins.Metadata = map[string]string{constant.METADATA_SERVICE_URL_PARAMS_PROPERTY_NAME: `{"protocol":"mock","timeout":"10000","version":"1.0.0","dubbo":"2.0.2","release":"2.7.6","port":"20880"}`}
+ ins.Metadata = map[string]string{constant.MetadataServiceURLParamsPropertyName: `{"protocol":"mock","timeout":"10000","version":"1.0.0","dubbo":"2.0.2","release":"2.7.6","port":"20880"}`}
pxy = createProxy(ins)
assert.NotNil(t, pxy)
}
diff --git a/metadata/service/local/service.go b/metadata/service/local/service.go
index 5abeb0f..3a0f94d 100644
--- a/metadata/service/local/service.go
+++ b/metadata/service/local/service.go
@@ -36,7 +36,7 @@
)
func init() {
- extension.SetLocalMetadataService(constant.DEFAULT_KEY, GetLocalMetadataService)
+ extension.SetLocalMetadataService(constant.DefaultKey, GetLocalMetadataService)
}
// version will be used by Version func
@@ -128,7 +128,7 @@
urls := value.(*skip.SkipList)
for i := uint64(0); i < urls.Len(); i++ {
url := urls.ByPosition(i).(*common.URL)
- if url.Service() != constant.METADATA_SERVICE_NAME {
+ if url.Service() != constant.MetadataServiceName {
res = append(res, url)
}
}
@@ -146,7 +146,7 @@
urls := serviceList.(*skip.SkipList)
for i := uint64(0); i < urls.Len(); i++ {
url := urls.ByPosition(i).(*common.URL)
- if len(protocol) == 0 || protocol == constant.ANY_VALUE || url.Protocol == protocol || url.GetParam(constant.PROTOCOL_KEY, "") == protocol {
+ if len(protocol) == 0 || protocol == constant.AnyValue || url.Protocol == protocol || url.GetParam(constant.ProtocolKey, "") == protocol {
res = append(res, url)
}
}
@@ -157,7 +157,7 @@
// ExportURL can store the in memory
func (mts *MetadataService) ExportURL(url *common.URL) (bool, error) {
- if constant.METADATA_SERVICE_NAME == url.GetParam(constant.InterfaceKey, "") {
+ if constant.MetadataServiceName == url.GetParam(constant.InterfaceKey, "") {
mts.metadataServiceURL = url
return true, nil
}
@@ -170,7 +170,7 @@
// UnexportURL can remove the url store in memory
func (mts *MetadataService) UnexportURL(url *common.URL) error {
- if constant.METADATA_SERVICE_NAME == url.GetParam(constant.InterfaceKey, "") {
+ if constant.MetadataServiceName == url.GetParam(constant.InterfaceKey, "") {
mts.metadataServiceURL = nil
return nil
}
@@ -194,7 +194,7 @@
// PublishServiceDefinition: publish url's service metadata info, and write into memory
func (mts *MetadataService) PublishServiceDefinition(url *common.URL) error {
- if common.RoleType(common.Consumer).Role() == url.GetParam(constant.SideKey, "") {
+ if common.RoleType(common.CONSUMER).Role() == url.GetParam(constant.SideKey, "") {
return nil
}
interfaceName := url.GetParam(constant.InterfaceKey, "")
@@ -216,7 +216,7 @@
// GetExportedURLs get all exported urls
func (mts *MetadataService) GetExportedURLs(serviceInterface string, group string, version string, protocol string) ([]*common.URL, error) {
- if serviceInterface == constant.ANY_VALUE {
+ if serviceInterface == constant.AnyValue {
return mts.getAllService(mts.exportedServiceURLs), nil
} else {
serviceKey := definition.ServiceDescriperBuild(serviceInterface, group, version)
diff --git a/metadata/service/local/service_proxy.go b/metadata/service/local/service_proxy.go
index 8418bea..4d6555f 100644
--- a/metadata/service/local/service_proxy.go
+++ b/metadata/service/local/service_proxy.go
@@ -101,7 +101,7 @@
// nolint
func (m *MetadataServiceProxy) Reference() string {
logger.Error("you should never invoke this implementation")
- return constant.METADATA_SERVICE_NAME
+ return constant.MetadataServiceName
}
// nolint
diff --git a/metadata/service/local/service_proxy_test.go b/metadata/service/local/service_proxy_test.go
index df2f5c1..6c89076 100644
--- a/metadata/service/local/service_proxy_test.go
+++ b/metadata/service/local/service_proxy_test.go
@@ -37,7 +37,7 @@
func TestMetadataServiceProxy_GetExportedURLs(t *testing.T) {
pxy := createPxy()
assert.NotNil(t, pxy)
- res, err := pxy.GetExportedURLs(constant.ANY_VALUE, constant.ANY_VALUE, constant.ANY_VALUE, constant.ANY_VALUE)
+ res, err := pxy.GetExportedURLs(constant.AnyValue, constant.AnyValue, constant.AnyValue, constant.AnyValue)
assert.Nil(t, err)
assert.Len(t, res, 1)
}
@@ -50,7 +50,7 @@
assert.Nil(t, err)
err = pxy.PublishServiceDefinition(&common.URL{})
assert.Nil(t, err)
- _, err = pxy.GetServiceDefinition(constant.ANY_VALUE, constant.ANY_VALUE, constant.ANY_VALUE)
+ _, err = pxy.GetServiceDefinition(constant.AnyValue, constant.AnyValue, constant.AnyValue)
assert.Nil(t, err)
_, err = pxy.Version()
assert.Nil(t, err)
@@ -70,7 +70,7 @@
assert.True(t, len(m) == 0)
err = pxy.UnexportURL(&common.URL{})
assert.NoError(t, err)
- ok, err = pxy.RefreshMetadata(constant.ANY_VALUE, constant.ANY_VALUE)
+ ok, err = pxy.RefreshMetadata(constant.AnyValue, constant.AnyValue)
assert.False(t, ok)
assert.NoError(t, err)
}
@@ -87,7 +87,7 @@
Port: 8080,
Enable: true,
Healthy: true,
- Metadata: map[string]string{constant.METADATA_SERVICE_URL_PARAMS_PROPERTY_NAME: `{"timeout":"10000", "protocol":"mock","version":"1.0.0","dubbo":"2.0.2","release":"2.7.6","port":"20880"}`},
+ Metadata: map[string]string{constant.MetadataServiceURLParamsPropertyName: `{"timeout":"10000", "protocol":"mock","version":"1.0.0","dubbo":"2.0.2","release":"2.7.6","port":"20880"}`},
}
return extension.GetMetadataServiceProxyFactory("").GetProxy(ins)
diff --git a/metadata/service/local_service.go b/metadata/service/local_service.go
index 1230e3a..9f80761 100644
--- a/metadata/service/local_service.go
+++ b/metadata/service/local_service.go
@@ -96,7 +96,7 @@
// Reference will return the reference id of metadata service
func (mts *BaseMetadataService) Reference() string {
- return constant.SIMPLE_METADATA_SERVICE_NAME
+ return constant.SimpleMetadataServiceName
}
type MetadataServiceProxyFactory interface {
@@ -127,7 +127,7 @@
func getExportedServicesRevision(serviceInstance registry.ServiceInstance) string {
metaData := serviceInstance.GetMetadata()
- return metaData[constant.EXPORTED_SERVICES_REVISION_PROPERTY_NAME]
+ return metaData[constant.ExportedServicesRevisionPropertyName]
}
func ConvertURLArrToIntfArr(urls []*common.URL) []interface{} {
diff --git a/metadata/service/remote/service.go b/metadata/service/remote/service.go
index 14bd9d9..0c8ee8f 100644
--- a/metadata/service/remote/service.go
+++ b/metadata/service/remote/service.go
@@ -96,7 +96,7 @@
// GetMetadata get the medata info of service from report
func (s *MetadataService) GetMetadata(instance registry.ServiceInstance) (*common.MetadataInfo, error) {
- revision := instance.GetMetadata()[constant.EXPORTED_SERVICES_REVISION_PROPERTY_NAME]
+ revision := instance.GetMetadata()[constant.ExportedServicesRevisionPropertyName]
id := identifier.NewSubscriberMetadataIdentifier(instance.GetServiceName(), revision)
return s.delegateReport.GetAppMetadata(id)
}
@@ -113,8 +113,8 @@
BaseMetadataIdentifier: identifier.BaseMetadataIdentifier{
ServiceInterface: interfaceName,
Version: url.GetParam(constant.VersionKey, ""),
- Group: url.GetParam(constant.GroupKey, constant.DUBBO),
- Side: url.GetParam(constant.SideKey, constant.PROVIDER_PROTOCOL),
+ Group: url.GetParam(constant.GroupKey, constant.Dubbo),
+ Side: url.GetParam(constant.SideKey, constant.ProviderProtocol),
},
}
s.delegateReport.StoreProviderMetadata(id, sd)
@@ -131,7 +131,7 @@
BaseMetadataIdentifier: identifier.BaseMetadataIdentifier{
ServiceInterface: interfaceName,
Version: url.GetParam(constant.VersionKey, ""),
- Group: url.GetParam(constant.GroupKey, constant.DUBBO),
+ Group: url.GetParam(constant.GroupKey, constant.Dubbo),
Side: url.GetParam(constant.SideKey, "consumer"),
},
}
diff --git a/metrics/prometheus/reporter.go b/metrics/prometheus/reporter.go
index 6f11c91..9abc65f 100644
--- a/metrics/prometheus/reporter.go
+++ b/metrics/prometheus/reporter.go
@@ -44,10 +44,10 @@
const (
reporterName = "prometheus"
- serviceKey = constant.SERVICE_KEY
+ serviceKey = constant.ServiceKey
groupKey = constant.GroupKey
versionKey = constant.VersionKey
- methodKey = constant.METHOD_KEY
+ methodKey = constant.MethodKey
timeoutKey = constant.TimeoutKey
// to identify side
@@ -55,9 +55,9 @@
consumerPrefix = "consumer_"
// to identify the metric's type
- histogramSuffix = "_histogram"
+ rtSuffix = "_rt"
// to identify the metric's type
- summarySuffix = "_summary"
+ tpsSuffix = "_tps"
)
var (
@@ -77,14 +77,15 @@
// if you want to use this feature, you need to initialize your prometheus.
// https://prometheus.io/docs/guides/go-application/
type PrometheusReporter struct {
- // report the consumer-side's summary data
- consumerSummaryVec *prometheus.SummaryVec
- // report the provider-side's summary data
- providerSummaryVec *prometheus.SummaryVec
- // report the provider-side's histogram data
- providerHistogramVec *prometheus.HistogramVec
- // report the consumer-side's histogram data
- consumerHistogramVec *prometheus.HistogramVec
+ // report the consumer-side's rt gauge data
+ consumerRTGaugeVec *prometheus.GaugeVec
+ // report the provider-side's rt gauge data
+ providerRTGaugeVec *prometheus.GaugeVec
+ // todo tps support
+ // report the consumer-side's tps gauge data
+ consumerTPSGaugeVec *prometheus.GaugeVec
+ // report the provider-side's tps gauge data
+ providerTPSGaugeVec *prometheus.GaugeVec
userGauge sync.Map
userSummary sync.Map
@@ -101,14 +102,11 @@
// 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()
- var sumVec *prometheus.SummaryVec
- var hisVec *prometheus.HistogramVec
+ var rtVec *prometheus.GaugeVec
if isProvider(url) {
- sumVec = reporter.providerSummaryVec
- hisVec = reporter.providerHistogramVec
+ rtVec = reporter.providerRTGaugeVec
} else if isConsumer(url) {
- sumVec = reporter.consumerSummaryVec
- hisVec = reporter.consumerHistogramVec
+ rtVec = reporter.consumerRTGaugeVec
} else {
logger.Warnf("The url belongs neither the consumer nor the provider, "+
"so the invocation will be ignored. url: %s", url.String())
@@ -118,13 +116,12 @@
labels := prometheus.Labels{
serviceKey: url.Service(),
groupKey: url.GetParam(groupKey, ""),
- versionKey: url.GetParam(versionKey, ""),
+ versionKey: url.GetParam(constant.AppVersionKey, ""),
methodKey: invocation.MethodName(),
timeoutKey: url.GetParam(timeoutKey, ""),
}
- costMs := float64(cost.Nanoseconds() / constant.MsToNanoRate)
- sumVec.With(labels).Observe(costMs)
- hisVec.With(labels).Observe(costMs)
+ costMs := cost.Nanoseconds()
+ rtVec.With(labels).Set(float64(costMs))
}
func newHistogramVec(name, namespace string, labels []string) *prometheus.HistogramVec {
@@ -206,7 +203,7 @@
// isConsumer shows whether this url represents the application sent then request as client
func isConsumer(url *common.URL) bool {
role := url.GetParam(constant.RoleKey, "")
- return strings.EqualFold(role, strconv.Itoa(common.Consumer))
+ return strings.EqualFold(role, strconv.Itoa(common.CONSUMER))
}
// newPrometheusReporter create new prometheusReporter
@@ -215,16 +212,12 @@
if reporterInstance == nil {
reporterInitOnce.Do(func() {
reporterInstance = &PrometheusReporter{
- consumerSummaryVec: newSummaryVec(consumerPrefix+serviceKey+summarySuffix, reporterConfig.Namespace, labelNames),
- providerSummaryVec: newSummaryVec(providerPrefix+serviceKey+summarySuffix, reporterConfig.Namespace, labelNames),
- namespace: reporterConfig.Namespace,
- consumerHistogramVec: newHistogramVec(consumerPrefix+serviceKey+histogramSuffix, reporterConfig.Namespace, labelNames),
- providerHistogramVec: newHistogramVec(providerPrefix+serviceKey+histogramSuffix, reporterConfig.Namespace, labelNames),
+ namespace: reporterConfig.Namespace,
+ consumerRTGaugeVec: newGaugeVec(consumerPrefix+serviceKey+rtSuffix, reporterConfig.Namespace, labelNames),
+ providerRTGaugeVec: newGaugeVec(providerPrefix+serviceKey+rtSuffix, reporterConfig.Namespace, labelNames),
}
- prom.DefaultRegisterer.MustRegister(reporterInstance.consumerSummaryVec, reporterInstance.providerSummaryVec,
- reporterInstance.consumerHistogramVec, reporterInstance.providerHistogramVec)
-
+ prom.DefaultRegisterer.MustRegister(reporterInstance.consumerRTGaugeVec, reporterInstance.providerRTGaugeVec)
metricsExporter, err := ocprom.NewExporter(ocprom.Options{
Registry: prom.DefaultRegisterer.(*prom.Registry),
})
@@ -232,13 +225,19 @@
logger.Errorf("new prometheus reporter with error = %s", err)
return
}
- go func() {
- mux := http.NewServeMux()
- mux.Handle(reporterConfig.Path, metricsExporter)
- if err := http.ListenAndServe(":"+reporterConfig.Port, mux); err != nil {
- logger.Errorf("new prometheus reporter with error = %s", err)
+
+ if reporterConfig.Enable {
+ if reporterConfig.Mode == metrics.ReportModePull {
+ go func() {
+ mux := http.NewServeMux()
+ mux.Handle(reporterConfig.Path, metricsExporter)
+ if err := http.ListenAndServe(":"+reporterConfig.Port, mux); err != nil {
+ logger.Warnf("new prometheus reporter with error = %s", err)
+ }
+ }()
}
- }()
+ // todo pushgateway support
+ }
})
}
return reporterInstance
diff --git a/protocol/dubbo/dubbo_codec.go b/protocol/dubbo/dubbo_codec.go
index e568ba0..32dc5f5 100644
--- a/protocol/dubbo/dubbo_codec.go
+++ b/protocol/dubbo/dubbo_codec.go
@@ -64,12 +64,12 @@
invocation := *invoc
svc := impl.Service{}
- svc.Path = invocation.AttachmentsByKey(constant.PATH_KEY, "")
+ svc.Path = invocation.AttachmentsByKey(constant.PathKey, "")
svc.Interface = invocation.AttachmentsByKey(constant.InterfaceKey, "")
svc.Version = invocation.AttachmentsByKey(constant.VersionKey, "")
svc.Group = invocation.AttachmentsByKey(constant.GroupKey, "")
svc.Method = invocation.MethodName()
- timeout, err := strconv.Atoi(invocation.AttachmentsByKey(constant.TimeoutKey, strconv.Itoa(constant.DEFAULT_REMOTING_TIMEOUT)))
+ timeout, err := strconv.Atoi(invocation.AttachmentsByKey(constant.TimeoutKey, strconv.Itoa(constant.DefaultRemotingTimeout)))
if err != nil {
// it will be wrapped in readwrite.Write .
return nil, perrors.WithStack(err)
@@ -77,11 +77,11 @@
svc.Timeout = time.Duration(timeout)
header := impl.DubboHeader{}
- serialization := invocation.AttachmentsByKey(constant.SerializationKey, constant.HESSIAN2_SERIALIZATION)
- if serialization == constant.PROTOBUF_SERIALIZATION {
- header.SerialID = constant.S_Proto
+ serialization := invocation.AttachmentsByKey(constant.SerializationKey, constant.Hessian2Serialization)
+ if serialization == constant.ProtobufSerialization {
+ header.SerialID = constant.SProto
} else {
- header.SerialID = constant.S_Hessian2
+ header.SerialID = constant.SHessian2
}
header.ID = request.ID
if request.TwoWay {
@@ -109,7 +109,7 @@
func (c *DubboCodec) encodeHeartbeartReqeust(request *remoting.Request) (*bytes.Buffer, error) {
header := impl.DubboHeader{
Type: impl.PackageHeartbeat,
- SerialID: constant.S_Hessian2,
+ SerialID: constant.SHessian2,
ID: request.ID,
}
@@ -216,7 +216,7 @@
request.Version = req[impl.DubboVersionKey].(string)
}
// path
- attachments[constant.PATH_KEY] = pkg.Service.Path
+ attachments[constant.PathKey] = pkg.Service.Path
// version
attachments[constant.VersionKey] = pkg.Service.Version
// method
diff --git a/protocol/dubbo/dubbo_invoker.go b/protocol/dubbo/dubbo_invoker.go
index bea1216..0f23070 100644
--- a/protocol/dubbo/dubbo_invoker.go
+++ b/protocol/dubbo/dubbo_invoker.go
@@ -40,7 +40,7 @@
)
var attachmentKey = []string{
- constant.InterfaceKey, constant.GroupKey, constant.TOKEN_KEY, constant.TimeoutKey,
+ constant.InterfaceKey, constant.GroupKey, constant.TokenKey, constant.TimeoutKey,
constant.VersionKey,
}
@@ -117,7 +117,7 @@
inv := invocation.(*invocation_impl.RPCInvocation)
// init param
- inv.SetAttachments(constant.PATH_KEY, di.GetURL().GetParam(constant.InterfaceKey, ""))
+ inv.SetAttachments(constant.PathKey, di.GetURL().GetParam(constant.InterfaceKey, ""))
for _, k := range attachmentKey {
if v := di.GetURL().GetParam(k, ""); len(v) > 0 {
inv.SetAttachments(k, v)
@@ -130,7 +130,7 @@
url := di.GetURL()
// default hessian2 serialization, compatible
if url.GetParam(constant.SerializationKey, "") == "" {
- url.SetParam(constant.SerializationKey, constant.HESSIAN2_SERIALIZATION)
+ url.SetParam(constant.SerializationKey, constant.Hessian2Serialization)
}
// async
async, err := strconv.ParseBool(inv.AttachmentsByKey(constant.AsyncKey, "false"))
@@ -169,7 +169,7 @@
if di.GetURL().GetParamBool(constant.GenericKey, false) {
methodName = invocation.Arguments()[0].(string)
}
- timeout := di.GetURL().GetParam(strings.Join([]string{constant.METHOD_KEYS, methodName, constant.TimeoutKey}, "."), "")
+ timeout := di.GetURL().GetParam(strings.Join([]string{constant.MethodKeys, methodName, constant.TimeoutKey}, "."), "")
if len(timeout) != 0 {
if t, err := time.ParseDuration(timeout); err == nil {
// config timeout into attachment
diff --git a/protocol/dubbo/dubbo_protocol.go b/protocol/dubbo/dubbo_protocol.go
index fe35e35..f2de5b7 100644
--- a/protocol/dubbo/dubbo_protocol.go
+++ b/protocol/dubbo/dubbo_protocol.go
@@ -234,7 +234,7 @@
spanCtx, err := opentracing.GlobalTracer().Extract(opentracing.TextMap,
opentracing.TextMapCarrier(filterContext(inv.Attachments())))
if err == nil {
- ctx = context.WithValue(ctx, constant.DubboCtxKey(constant.TRACING_REMOTE_SPAN_CTX), spanCtx)
+ ctx = context.WithValue(ctx, constant.DubboCtxKey(constant.TracingRemoteSpanCtx), spanCtx)
}
return ctx
}
diff --git a/protocol/dubbo/impl/codec.go b/protocol/dubbo/impl/codec.go
index cc842dc..cc7abad 100644
--- a/protocol/dubbo/impl/codec.go
+++ b/protocol/dubbo/impl/codec.go
@@ -276,7 +276,7 @@
}
func NewDubboCodec(reader *bufio.Reader) *ProtocolCodec {
- s, _ := GetSerializerById(constant.S_Hessian2)
+ s, _ := GetSerializerById(constant.SHessian2)
return &ProtocolCodec{
reader: reader,
pkgType: 0,
diff --git a/protocol/dubbo/impl/codec_test.go b/protocol/dubbo/impl/codec_test.go
index 2ea2e2f..9a64ac5 100644
--- a/protocol/dubbo/impl/codec_test.go
+++ b/protocol/dubbo/impl/codec_test.go
@@ -34,7 +34,7 @@
pkg := NewDubboPackage(nil)
pkg.Body = []interface{}{"a"}
pkg.Header.Type = PackageHeartbeat
- pkg.Header.SerialID = constant.S_Hessian2
+ pkg.Header.SerialID = constant.SHessian2
pkg.Header.ID = 10086
pkg.SetSerializer(HessianSerializer{})
@@ -49,7 +49,7 @@
err = pkgres.Unmarshal()
assert.NoError(t, err)
assert.Equal(t, PackageHeartbeat|PackageRequest|PackageRequest_TwoWay, pkgres.Header.Type)
- assert.Equal(t, constant.S_Hessian2, pkgres.Header.SerialID)
+ assert.Equal(t, constant.SHessian2, pkgres.Header.SerialID)
assert.Equal(t, int64(10086), pkgres.Header.ID)
assert.Equal(t, 0, len(pkgres.Body.([]interface{})))
@@ -70,7 +70,7 @@
reassembleBody := pkgres.GetBody().(map[string]interface{})
assert.NoError(t, err)
assert.Equal(t, PackageRequest, pkgres.Header.Type)
- assert.Equal(t, constant.S_Hessian2, pkgres.Header.SerialID)
+ assert.Equal(t, constant.SHessian2, pkgres.Header.SerialID)
assert.Equal(t, int64(10086), pkgres.Header.ID)
assert.Equal(t, "2.0.2", reassembleBody["dubboVersion"].(string))
assert.Equal(t, "path", pkgres.Service.Path)
diff --git a/protocol/dubbo/impl/hessian.go b/protocol/dubbo/impl/hessian.go
index 2d96675..26858dc 100644
--- a/protocol/dubbo/impl/hessian.go
+++ b/protocol/dubbo/impl/hessian.go
@@ -370,8 +370,8 @@
if req[6] != nil {
attachments = req[6].(map[string]interface{})
}
- if svc.Path == "" && attachments[constant.PATH_KEY] != nil && len(attachments[constant.PATH_KEY].(string)) > 0 {
- svc.Path = attachments[constant.PATH_KEY].(string)
+ if svc.Path == "" && attachments[constant.PathKey] != nil && len(attachments[constant.PathKey].(string)) > 0 {
+ svc.Path = attachments[constant.PathKey].(string)
}
if _, ok := attachments[constant.InterfaceKey]; ok {
svc.Interface = attachments[constant.InterfaceKey].(string)
diff --git a/protocol/dubbo/impl/serialization.go b/protocol/dubbo/impl/serialization.go
index 8137a2f..a98d408 100644
--- a/protocol/dubbo/impl/serialization.go
+++ b/protocol/dubbo/impl/serialization.go
@@ -32,8 +32,8 @@
func init() {
nameMaps = map[byte]string{
- constant.S_Hessian2: constant.HESSIAN2_SERIALIZATION,
- constant.S_Proto: constant.PROTOBUF_SERIALIZATION,
+ constant.SHessian2: constant.Hessian2Serialization,
+ constant.SProto: constant.ProtobufSerialization,
}
}
diff --git a/protocol/dubbo/impl/serialize.go b/protocol/dubbo/impl/serialize.go
index 771d91e..23e9fbc 100644
--- a/protocol/dubbo/impl/serialize.go
+++ b/protocol/dubbo/impl/serialize.go
@@ -29,7 +29,7 @@
// NOTE: default serialID is S_Hessian
serialID := p.Header.SerialID
if serialID == 0 {
- serialID = constant.S_Hessian2
+ serialID = constant.SHessian2
}
serializer, err := GetSerializerById(serialID)
if err != nil {
diff --git a/protocol/dubbo3/common_test.go b/protocol/dubbo3/common_test.go
index f137e84..5daac36 100644
--- a/protocol/dubbo3/common_test.go
+++ b/protocol/dubbo3/common_test.go
@@ -28,7 +28,6 @@
import (
"dubbo.apache.org/dubbo-go/v3/config"
- "dubbo.apache.org/dubbo-go/v3/protocol"
"dubbo.apache.org/dubbo-go/v3/protocol/dubbo3/internal"
"dubbo.apache.org/dubbo-go/v3/protocol/invocation"
)
@@ -39,13 +38,11 @@
}
type greeterProvider struct {
- *greeterProviderBase
+ internal.UnimplementedGreeterServer
}
func newGreeterProvider() *greeterProvider {
- return &greeterProvider{
- greeterProviderBase: &greeterProviderBase{},
- }
+ return &greeterProvider{}
}
func (g *greeterProvider) SayHello(ctx context.Context, req *internal.HelloRequest) (reply *internal.HelloReply, err error) {
@@ -53,38 +50,6 @@
return &internal.HelloReply{Message: "this is message from reply"}, nil
}
-func (g *greeterProvider) Reference() string {
- return "DubboGreeterImpl"
-}
-
-// code generated by greeter.go
-type greeterProviderBase struct {
- proxyImpl protocol.Invoker
-}
-
-func (g *greeterProviderBase) SetProxyImpl(impl protocol.Invoker) {
- g.proxyImpl = impl
-}
-
-func (g *greeterProviderBase) GetProxyImpl() protocol.Invoker {
- return g.proxyImpl
-}
-
-func (g *greeterProviderBase) ServiceDesc() *native_grpc.ServiceDesc {
- return &native_grpc.ServiceDesc{
- ServiceName: "helloworld.Greeter",
- HandlerType: (*internal.GreeterServer)(nil),
- Methods: []native_grpc.MethodDesc{
- {
- MethodName: "SayHello",
- Handler: dubboGreeterSayHelloHandler,
- },
- },
- Streams: []native_grpc.StreamDesc{},
- Metadata: "helloworld.proto",
- }
-}
-
func dubboGreeterSayHelloHandler(srv interface{}, ctx context.Context,
dec func(interface{}) error, interceptor native_grpc.UnaryServerInterceptor) (interface{}, error) {
@@ -99,7 +64,7 @@
invo := invocation.NewRPCInvocation("SayHello", args, nil)
if interceptor == nil {
- result := base.GetProxyImpl().Invoke(context.Background(), invo)
+ result := base.XXX_GetProxyImpl().Invoke(context.Background(), invo)
return result.Result(), result.Error()
}
info := &native_grpc.UnaryServerInfo{
@@ -107,7 +72,7 @@
FullMethod: "/helloworld.Greeter/SayHello",
}
handler := func(context.Context, interface{}) (interface{}, error) {
- result := base.GetProxyImpl().Invoke(context.Background(), invo)
+ result := base.XXX_GetProxyImpl().Invoke(context.Background(), invo)
return result.Result(), result.Error()
}
return interceptor(ctx, in, info, handler)
diff --git a/protocol/dubbo3/dubbo3_invoker.go b/protocol/dubbo3/dubbo3_invoker.go
index 0539790..c978f85 100644
--- a/protocol/dubbo3/dubbo3_invoker.go
+++ b/protocol/dubbo3/dubbo3_invoker.go
@@ -64,7 +64,7 @@
interfaceKey := url.GetParam(constant.InterfaceKey, "")
consumerService := config.GetConsumerServiceByInterfaceName(interfaceKey)
- dubboSerializaerType := url.GetParam(constant.SerializationKey, constant.PROTOBUF_SERIALIZATION)
+ dubboSerializaerType := url.GetParam(constant.SerializationKey, constant.ProtobufSerialization)
triCodecType := tripleConstant.CodecType(dubboSerializaerType)
// new triple client
triOption := triConfig.NewTripleOption(
@@ -155,7 +155,7 @@
// 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.TimeoutKey}, "."), "")
+ timeout := di.GetURL().GetParam(strings.Join([]string{constant.MethodKeys, invocation.MethodName(), constant.TimeoutKey}, "."), "")
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 a836e0d..c84cbc1 100644
--- a/protocol/dubbo3/dubbo3_protocol.go
+++ b/protocol/dubbo3/dubbo3_protocol.go
@@ -83,13 +83,13 @@
var service interface{}
service = config.GetProviderService(key)
- serializationType := url.GetParam(constant.SerializationKey, constant.PROTOBUF_SERIALIZATION)
+ serializationType := url.GetParam(constant.SerializationKey, constant.ProtobufSerialization)
var triSerializationType tripleConstant.CodecType
- if serializationType == constant.PROTOBUF_SERIALIZATION {
- m, ok := reflect.TypeOf(service).MethodByName("SetProxyImpl")
+ if serializationType == constant.ProtobufSerialization {
+ m, ok := reflect.TypeOf(service).MethodByName("XXX_SetProxyImpl")
if !ok {
- panic("method SetProxyImpl is necessary for triple service")
+ panic("method XXX_SetProxyImpl is necessary for triple service")
}
if invoker == nil {
panic(fmt.Sprintf("no invoker found for servicekey: %v", url.ServiceKey()))
@@ -160,11 +160,11 @@
// Dubbo3GrpcService is gRPC service
type Dubbo3GrpcService interface {
// SetProxyImpl sets proxy.
- SetProxyImpl(impl protocol.Invoker)
+ XXX_SetProxyImpl(impl protocol.Invoker)
// GetProxyImpl gets proxy.
- GetProxyImpl() protocol.Invoker
+ XXX_GetProxyImpl() protocol.Invoker
// ServiceDesc gets an RPC service's specification.
- ServiceDesc() *grpc.ServiceDesc
+ XXX_ServiceDesc() *grpc.ServiceDesc
}
type UnaryService struct {
diff --git a/protocol/dubbo3/dubbo3_protocol_test.go b/protocol/dubbo3/dubbo3_protocol_test.go
index 95e485d..b0baa35 100644
--- a/protocol/dubbo3/dubbo3_protocol_test.go
+++ b/protocol/dubbo3/dubbo3_protocol_test.go
@@ -36,7 +36,7 @@
)
const (
- mockDubbo3CommonUrl = "tri://127.0.0.1:20002/DubboGreeterImpl?accesslog=&anyhost=true&app.version=0.0.1&application=BDTService&async=false&bean.name=greeterImpl" +
+ mockDubbo3CommonUrl = "tri://127.0.0.1:20002/DubboGreeterImpl?accesslog=&anyhost=true&app.version=0.0.1&application=BDTService&async=false&bean.name=greeterProvider" +
"&category=providers&cluster=failover&dubbo=dubbo-provider-golang-2.6.0&environment=dev&execute.limit=&execute.limit.rejected.handler=&generic=false&group=&interface=org.apache.dubbo.DubboGreeterImpl" +
"&ip=192.168.1.106&loadbalance=random&methods.SayHello.loadbalance=random&methods.SayHello.retries=1&methods.SayHello.tps.limit.interval=&methods.SayHello.tps.limit.rate=&methods.SayHello.tps.limit.strategy=" +
"&methods.SayHello.weight=0&module=dubbogo+say-hello+client&name=BDTService&organization=ikurento.com&owner=ZX&pid=49427&reference.filter=cshutdown®istry.role=3&remote.timestamp=1576923717&retries=" +
diff --git a/protocol/dubbo3/internal/helloworld.pb.go b/protocol/dubbo3/internal/helloworld.pb.go
index e265b30..f846788 100644
--- a/protocol/dubbo3/internal/helloworld.pb.go
+++ b/protocol/dubbo3/internal/helloworld.pb.go
@@ -16,257 +16,228 @@
*/
// Code generated by protoc-gen-go. DO NOT EDIT.
+// versions:
+// protoc-gen-go v1.25.0
+// protoc v3.14.0
// source: helloworld.proto
package internal
import (
- context "context"
- fmt "fmt"
- math "math"
+ reflect "reflect"
+ sync "sync"
)
import (
- "github.com/dubbogo/triple/pkg/common"
- tripleConstant "github.com/dubbogo/triple/pkg/common/constant"
- dubbo3 "github.com/dubbogo/triple/pkg/triple"
-
proto "github.com/golang/protobuf/proto"
- grpc "google.golang.org/grpc"
+ protoreflect "google.golang.org/protobuf/reflect/protoreflect"
+
+ protoimpl "google.golang.org/protobuf/runtime/protoimpl"
)
-import (
- "dubbo.apache.org/dubbo-go/v3/protocol"
- dgrpc "dubbo.apache.org/dubbo-go/v3/protocol/grpc"
- "dubbo.apache.org/dubbo-go/v3/protocol/invocation"
+const (
+ // Verify that this generated code is sufficiently up-to-date.
+ _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
+ // Verify that runtime/protoimpl is sufficiently up-to-date.
+ _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the proto package it is being compiled against.
-// A compilation error at this line likely means your copy of the
-// proto package needs to be updated.
-const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
+// This is a compile-time assertion that a sufficiently up-to-date version
+// of the legacy proto package is being used.
+const _ = proto.ProtoPackageIsVersion4
// The request message containing the user's name.
type HelloRequest struct {
- Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
- XXX_NoUnkeyedLiteral struct{} `json:"-"`
- XXX_unrecognized []byte `json:"-"`
- XXX_sizecache int32 `json:"-"`
+ state protoimpl.MessageState
+ sizeCache protoimpl.SizeCache
+ unknownFields protoimpl.UnknownFields
+
+ Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
}
-func (m *HelloRequest) Reset() { *m = HelloRequest{} }
-func (m *HelloRequest) String() string { return proto.CompactTextString(m) }
-func (*HelloRequest) ProtoMessage() {}
+func (x *HelloRequest) Reset() {
+ *x = HelloRequest{}
+ if protoimpl.UnsafeEnabled {
+ mi := &file_helloworld_proto_msgTypes[0]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+ }
+}
+
+func (x *HelloRequest) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*HelloRequest) ProtoMessage() {}
+
+func (x *HelloRequest) ProtoReflect() protoreflect.Message {
+ mi := &file_helloworld_proto_msgTypes[0]
+ if protoimpl.UnsafeEnabled && x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use HelloRequest.ProtoReflect.Descriptor instead.
func (*HelloRequest) Descriptor() ([]byte, []int) {
- return fileDescriptor_17b8c58d586b62f2, []int{0}
+ return file_helloworld_proto_rawDescGZIP(), []int{0}
}
-func (m *HelloRequest) XXX_Unmarshal(b []byte) error {
- return xxx_messageInfo_HelloRequest.Unmarshal(m, b)
-}
-func (m *HelloRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- return xxx_messageInfo_HelloRequest.Marshal(b, m, deterministic)
-}
-func (m *HelloRequest) XXX_Merge(src proto.Message) {
- xxx_messageInfo_HelloRequest.Merge(m, src)
-}
-func (m *HelloRequest) XXX_Size() int {
- return xxx_messageInfo_HelloRequest.Size(m)
-}
-func (m *HelloRequest) XXX_DiscardUnknown() {
- xxx_messageInfo_HelloRequest.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_HelloRequest proto.InternalMessageInfo
-
-func (m *HelloRequest) GetName() string {
- if m != nil {
- return m.Name
+func (x *HelloRequest) GetName() string {
+ if x != nil {
+ return x.Name
}
return ""
}
// The response message containing the greetings
type HelloReply struct {
- Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"`
- XXX_NoUnkeyedLiteral struct{} `json:"-"`
- XXX_unrecognized []byte `json:"-"`
- XXX_sizecache int32 `json:"-"`
+ state protoimpl.MessageState
+ sizeCache protoimpl.SizeCache
+ unknownFields protoimpl.UnknownFields
+
+ Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"`
}
-func (m *HelloReply) Reset() { *m = HelloReply{} }
-func (m *HelloReply) String() string { return proto.CompactTextString(m) }
-func (*HelloReply) ProtoMessage() {}
+func (x *HelloReply) Reset() {
+ *x = HelloReply{}
+ if protoimpl.UnsafeEnabled {
+ mi := &file_helloworld_proto_msgTypes[1]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+ }
+}
+
+func (x *HelloReply) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*HelloReply) ProtoMessage() {}
+
+func (x *HelloReply) ProtoReflect() protoreflect.Message {
+ mi := &file_helloworld_proto_msgTypes[1]
+ if protoimpl.UnsafeEnabled && x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use HelloReply.ProtoReflect.Descriptor instead.
func (*HelloReply) Descriptor() ([]byte, []int) {
- return fileDescriptor_17b8c58d586b62f2, []int{1}
+ return file_helloworld_proto_rawDescGZIP(), []int{1}
}
-func (m *HelloReply) XXX_Unmarshal(b []byte) error {
- return xxx_messageInfo_HelloReply.Unmarshal(m, b)
-}
-func (m *HelloReply) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- return xxx_messageInfo_HelloReply.Marshal(b, m, deterministic)
-}
-func (m *HelloReply) XXX_Merge(src proto.Message) {
- xxx_messageInfo_HelloReply.Merge(m, src)
-}
-func (m *HelloReply) XXX_Size() int {
- return xxx_messageInfo_HelloReply.Size(m)
-}
-func (m *HelloReply) XXX_DiscardUnknown() {
- xxx_messageInfo_HelloReply.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_HelloReply proto.InternalMessageInfo
-
-func (m *HelloReply) GetMessage() string {
- if m != nil {
- return m.Message
+func (x *HelloReply) GetMessage() string {
+ if x != nil {
+ return x.Message
}
return ""
}
-func init() {
- proto.RegisterType((*HelloRequest)(nil), "internal.HelloRequest")
- proto.RegisterType((*HelloReply)(nil), "internal.HelloReply")
+var File_helloworld_proto protoreflect.FileDescriptor
+
+var file_helloworld_proto_rawDesc = []byte{
+ 0x0a, 0x10, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2e, 0x70, 0x72, 0x6f,
+ 0x74, 0x6f, 0x12, 0x08, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x22, 0x22, 0x0a, 0x0c,
+ 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04,
+ 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65,
+ 0x22, 0x26, 0x0a, 0x0a, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x18,
+ 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
+ 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x32, 0x45, 0x0a, 0x07, 0x47, 0x72, 0x65, 0x65,
+ 0x74, 0x65, 0x72, 0x12, 0x3a, 0x0a, 0x08, 0x53, 0x61, 0x79, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x12,
+ 0x16, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f,
+ 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e,
+ 0x61, 0x6c, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x42,
+ 0x43, 0x0a, 0x1b, 0x69, 0x6f, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70,
+ 0x6c, 0x65, 0x73, 0x2e, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x42, 0x0f,
+ 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50,
+ 0x01, 0x5a, 0x0b, 0x2e, 0x2f, 0x3b, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0xa2, 0x02,
+ 0x03, 0x48, 0x4c, 0x57, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
-func init() { proto.RegisterFile("helloworld.proto", fileDescriptor_17b8c58d586b62f2) }
+var (
+ file_helloworld_proto_rawDescOnce sync.Once
+ file_helloworld_proto_rawDescData = file_helloworld_proto_rawDesc
+)
-var fileDescriptor_17b8c58d586b62f2 = []byte{
- // 189 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0xc8, 0x48, 0xcd, 0xc9,
- 0xc9, 0x2f, 0xcf, 0x2f, 0xca, 0x49, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0xc8, 0xcc,
- 0x2b, 0x49, 0x2d, 0xca, 0x4b, 0xcc, 0x51, 0x52, 0xe2, 0xe2, 0xf1, 0x00, 0xc9, 0x06, 0xa5, 0x16,
- 0x96, 0xa6, 0x16, 0x97, 0x08, 0x09, 0x71, 0xb1, 0xe4, 0x25, 0xe6, 0xa6, 0x4a, 0x30, 0x2a, 0x30,
- 0x6a, 0x70, 0x06, 0x81, 0xd9, 0x4a, 0x6a, 0x5c, 0x5c, 0x50, 0x35, 0x05, 0x39, 0x95, 0x42, 0x12,
- 0x5c, 0xec, 0xb9, 0xa9, 0xc5, 0xc5, 0x89, 0xe9, 0x30, 0x45, 0x30, 0xae, 0x91, 0x2b, 0x17, 0xbb,
- 0x7b, 0x51, 0x6a, 0x6a, 0x49, 0x6a, 0x91, 0x90, 0x15, 0x17, 0x47, 0x70, 0x62, 0x25, 0x58, 0x97,
- 0x90, 0x98, 0x1e, 0xcc, 0x36, 0x3d, 0x64, 0xab, 0xa4, 0x44, 0x30, 0xc4, 0x0b, 0x72, 0x2a, 0x95,
- 0x18, 0x9c, 0xcc, 0xb8, 0xa4, 0x33, 0xf3, 0xf5, 0xd2, 0x8b, 0x0a, 0x92, 0xf5, 0x52, 0x2b, 0x12,
- 0x73, 0x0b, 0x72, 0x52, 0x8b, 0xf5, 0x10, 0x3e, 0x70, 0xe2, 0x07, 0x2b, 0x0e, 0x07, 0xb1, 0x03,
- 0x40, 0x9e, 0x09, 0x60, 0x5c, 0xc4, 0xc4, 0xec, 0xe1, 0x13, 0x9e, 0xc4, 0x06, 0xf6, 0x9b, 0x31,
- 0x20, 0x00, 0x00, 0xff, 0xff, 0xc4, 0x20, 0xe8, 0xd3, 0xef, 0x00, 0x00, 0x00,
+func file_helloworld_proto_rawDescGZIP() []byte {
+ file_helloworld_proto_rawDescOnce.Do(func() {
+ file_helloworld_proto_rawDescData = protoimpl.X.CompressGZIP(file_helloworld_proto_rawDescData)
+ })
+ return file_helloworld_proto_rawDescData
}
-type greeterDubbo3Client struct {
- cc *dubbo3.TripleConn
+var file_helloworld_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
+var file_helloworld_proto_goTypes = []interface{}{
+ (*HelloRequest)(nil), // 0: internal.HelloRequest
+ (*HelloReply)(nil), // 1: internal.HelloReply
+}
+var file_helloworld_proto_depIdxs = []int32{
+ 0, // 0: internal.Greeter.SayHello:input_type -> internal.HelloRequest
+ 1, // 1: internal.Greeter.SayHello:output_type -> internal.HelloReply
+ 1, // [1:2] is the sub-list for method output_type
+ 0, // [0:1] is the sub-list for method input_type
+ 0, // [0:0] is the sub-list for extension type_name
+ 0, // [0:0] is the sub-list for extension extendee
+ 0, // [0:0] is the sub-list for field type_name
}
-func NewGreeterDubbo3Client(cc *dubbo3.TripleConn) GreeterClient {
- return &greeterDubbo3Client{cc}
-}
-func (c *greeterDubbo3Client) SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, common.ErrorWithAttachment) {
- out := new(HelloReply)
- interfaceKey := ctx.Value(tripleConstant.InterfaceKey).(string)
- return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/SayHello", in, out)
-}
-
-// GreeterClientImpl is the client API for Greeter service.
-//
-// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
-type GreeterClient interface {
- // Sends a greeting
- SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, common.ErrorWithAttachment)
-}
-
-type GreeterClientImpl struct {
- // Sends a greeting
- SayHello func(ctx context.Context, in *HelloRequest) (*HelloReply, error)
-}
-
-type Greeter_SayHelloClient interface {
- CloseAndRecv() (*HelloReply, error)
- grpc.ClientStream
-}
-
-type greeterSayHelloClient struct {
- grpc.ClientStream
-}
-
-func (x *greeterSayHelloClient) CloseAndRecv() (*HelloReply, error) {
- if err := x.ClientStream.CloseSend(); err != nil {
- return nil, err
+func init() { file_helloworld_proto_init() }
+func file_helloworld_proto_init() {
+ if File_helloworld_proto != nil {
+ return
}
- m := new(HelloReply)
- if err := x.ClientStream.RecvMsg(m); err != nil {
- return nil, err
+ if !protoimpl.UnsafeEnabled {
+ file_helloworld_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
+ switch v := v.(*HelloRequest); i {
+ case 0:
+ return &v.state
+ case 1:
+ return &v.sizeCache
+ case 2:
+ return &v.unknownFields
+ default:
+ return nil
+ }
+ }
+ file_helloworld_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
+ switch v := v.(*HelloReply); i {
+ case 0:
+ return &v.state
+ case 1:
+ return &v.sizeCache
+ case 2:
+ return &v.unknownFields
+ default:
+ return nil
+ }
+ }
}
- return m, nil
-}
-
-func (c *GreeterClientImpl) Reference() string {
- return "greeterImpl"
-}
-
-func (c *GreeterClientImpl) GetDubboStub(cc *dubbo3.TripleConn) GreeterClient {
- return NewGreeterDubbo3Client(cc)
-}
-
-// GreeterServer is the server API for Greeter service.
-type GreeterServer interface {
- // Sends a greeting
- SayHello(context.Context, *HelloRequest) (*HelloReply, error)
-}
-
-type GreeterProviderBase struct {
- proxyImpl protocol.Invoker
-}
-
-func (s *GreeterProviderBase) SetProxyImpl(impl protocol.Invoker) {
- s.proxyImpl = impl
-}
-
-func (s *GreeterProviderBase) GetProxyImpl() protocol.Invoker {
- return s.proxyImpl
-}
-
-func (c *GreeterProviderBase) Reference() string {
- return "greeterImpl"
-}
-
-func _Triple_Greeter_SayHello_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(HelloRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- base := srv.(dgrpc.DubboGrpcService)
- args := []interface{}{}
- args = append(args, in)
- invo := invocation.NewRPCInvocation("SayHello", args, nil)
- if interceptor == nil {
- result := base.GetProxyImpl().Invoke(ctx, invo)
- return result, result.Error()
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/internal.Greeter/SayHello",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- result := base.GetProxyImpl().Invoke(context.Background(), invo)
- return result.Result(), result.Error()
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func (s *GreeterProviderBase) ServiceDesc() *grpc.ServiceDesc {
- return &grpc.ServiceDesc{
- ServiceName: "internal.Greeter",
- HandlerType: (*GreeterServer)(nil),
- Methods: []grpc.MethodDesc{
- {
- MethodName: "SayHello",
- Handler: _Triple_Greeter_SayHello_Handler,
- },
+ type x struct{}
+ out := protoimpl.TypeBuilder{
+ File: protoimpl.DescBuilder{
+ GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
+ RawDescriptor: file_helloworld_proto_rawDesc,
+ NumEnums: 0,
+ NumMessages: 2,
+ NumExtensions: 0,
+ NumServices: 1,
},
- Streams: []grpc.StreamDesc{},
- Metadata: "helloworld.proto",
- }
+ GoTypes: file_helloworld_proto_goTypes,
+ DependencyIndexes: file_helloworld_proto_depIdxs,
+ MessageInfos: file_helloworld_proto_msgTypes,
+ }.Build()
+ File_helloworld_proto = out.File
+ file_helloworld_proto_rawDesc = nil
+ file_helloworld_proto_goTypes = nil
+ file_helloworld_proto_depIdxs = nil
}
diff --git a/protocol/dubbo3/internal/helloworld.proto b/protocol/dubbo3/internal/helloworld.proto
index 7b62e20..ceb877a 100644
--- a/protocol/dubbo3/internal/helloworld.proto
+++ b/protocol/dubbo3/internal/helloworld.proto
@@ -21,6 +21,7 @@
option java_package = "io.grpc.examples.helloworld";
option java_outer_classname = "HelloWorldProto";
option objc_class_prefix = "HLW";
+option go_package = "./;internal";
package internal;
diff --git a/protocol/dubbo3/internal/helloworld_triple.pb.go b/protocol/dubbo3/internal/helloworld_triple.pb.go
new file mode 100644
index 0000000..b9c2f7f
--- /dev/null
+++ b/protocol/dubbo3/internal/helloworld_triple.pb.go
@@ -0,0 +1,168 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// Code generated by protoc-gen-go-triple. DO NOT EDIT.
+// versions:
+// - protoc-gen-go-triple v1.0.0
+// - protoc v3.14.0
+// source: helloworld.proto
+
+package internal
+
+import (
+ context "context"
+)
+
+import (
+ common "github.com/dubbogo/triple/pkg/common"
+ constant "github.com/dubbogo/triple/pkg/common/constant"
+ triple "github.com/dubbogo/triple/pkg/triple"
+
+ grpc "google.golang.org/grpc"
+ codes "google.golang.org/grpc/codes"
+ status "google.golang.org/grpc/status"
+)
+
+import (
+ protocol "dubbo.apache.org/dubbo-go/v3/protocol"
+ invocation "dubbo.apache.org/dubbo-go/v3/protocol/invocation"
+)
+
+// This is a compile-time assertion to ensure that this generated file
+// is compatible with the grpc package it is being compiled against.
+const _ = grpc.SupportPackageIsVersion7
+
+// GreeterClient is the client API for Greeter service.
+//
+// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
+type GreeterClient interface {
+ // Sends a greeting
+ SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, common.ErrorWithAttachment)
+}
+
+type greeterClient struct {
+ cc *triple.TripleConn
+}
+
+type GreeterClientImpl struct {
+ SayHello func(ctx context.Context, in *HelloRequest) (*HelloReply, error)
+}
+
+func (c *GreeterClientImpl) GetDubboStub(cc *triple.TripleConn) GreeterClient {
+ return NewGreeterClient(cc)
+}
+
+func NewGreeterClient(cc *triple.TripleConn) GreeterClient {
+ return &greeterClient{cc}
+}
+
+func (c *greeterClient) SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, common.ErrorWithAttachment) {
+ out := new(HelloReply)
+ interfaceKey := ctx.Value(constant.InterfaceKey).(string)
+ return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/SayHello", in, out)
+}
+
+// GreeterServer is the server API for Greeter service.
+// All implementations must embed UnimplementedGreeterServer
+// for forward compatibility
+type GreeterServer interface {
+ // Sends a greeting
+ SayHello(context.Context, *HelloRequest) (*HelloReply, error)
+ mustEmbedUnimplementedGreeterServer()
+}
+
+// UnimplementedGreeterServer must be embedded to have forward compatible implementations.
+type UnimplementedGreeterServer struct {
+ proxyImpl protocol.Invoker
+}
+
+func (UnimplementedGreeterServer) SayHello(context.Context, *HelloRequest) (*HelloReply, error) {
+ return nil, status.Errorf(codes.Unimplemented, "method SayHello not implemented")
+}
+func (s *UnimplementedGreeterServer) XXX_SetProxyImpl(impl protocol.Invoker) {
+ s.proxyImpl = impl
+}
+
+func (s *UnimplementedGreeterServer) XXX_GetProxyImpl() protocol.Invoker {
+ return s.proxyImpl
+}
+
+func (UnimplementedGreeterServer) mustEmbedUnimplementedGreeterServer() {}
+
+// UnsafeGreeterServer may be embedded to opt out of forward compatibility for this service.
+// Use of this interface is not recommended, as added methods to GreeterServer will
+// result in compilation errors.
+type UnsafeGreeterServer interface {
+ mustEmbedUnimplementedGreeterServer()
+}
+
+func RegisterGreeterServer(s grpc.ServiceRegistrar, srv GreeterServer) {
+ s.RegisterService(&Greeter_ServiceDesc, srv)
+}
+
+// Dubbo3GrpcService is gRPC service
+type Dubbo3GrpcService interface {
+ // SetProxyImpl sets proxy.
+ XXX_SetProxyImpl(impl protocol.Invoker)
+ // GetProxyImpl gets proxy.
+ XXX_GetProxyImpl() protocol.Invoker
+ // ServiceDesc gets an RPC service's specification.
+ XXX_ServiceDesc() *grpc.ServiceDesc
+}
+
+func _Greeter_SayHello_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(HelloRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ base := srv.(Dubbo3GrpcService)
+ args := []interface{}{}
+ args = append(args, in)
+ invo := invocation.NewRPCInvocation("SayHello", args, nil)
+ if interceptor == nil {
+ result := base.XXX_GetProxyImpl().Invoke(ctx, invo)
+ return result, result.Error()
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: "/internal.Greeter/SayHello",
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(GreeterServer).SayHello(ctx, req.(*HelloRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+// Greeter_ServiceDesc is the grpc.ServiceDesc for Greeter service.
+// It's only intended for direct use with grpc.RegisterService,
+// and not to be introspected or modified (even as a copy)
+var Greeter_ServiceDesc = grpc.ServiceDesc{
+ ServiceName: "internal.Greeter",
+ HandlerType: (*GreeterServer)(nil),
+ Methods: []grpc.MethodDesc{
+ {
+ MethodName: "SayHello",
+ Handler: _Greeter_SayHello_Handler,
+ },
+ },
+ Streams: []grpc.StreamDesc{},
+ Metadata: "helloworld.proto",
+}
+
+func (s *UnimplementedGreeterServer) XXX_ServiceDesc() *grpc.ServiceDesc {
+ return &Greeter_ServiceDesc
+}
diff --git a/protocol/dubbo3/internal/server.go b/protocol/dubbo3/internal/server.go
index 97245df..51021c8 100644
--- a/protocol/dubbo3/internal/server.go
+++ b/protocol/dubbo3/internal/server.go
@@ -32,7 +32,7 @@
// server is used to implement helloworld.GreeterServer.
type Server struct {
- GreeterProviderBase
+ UnimplementedGreeterServer
}
// SayHello implements helloworld.GreeterServer
diff --git a/protocol/grpc/client.go b/protocol/grpc/client.go
index 8a05abc..b6f2b03 100644
--- a/protocol/grpc/client.go
+++ b/protocol/grpc/client.go
@@ -58,7 +58,7 @@
// If not, will return NoopTracer.
tracer := opentracing.GlobalTracer()
dialOpts := make([]grpc.DialOption, 0, 4)
- maxMessageSize, _ := strconv.Atoi(url.GetParam(constant.MESSAGE_SIZE_KEY, "4"))
+ maxMessageSize, _ := strconv.Atoi(url.GetParam(constant.MessageSizeKey, "4"))
// consumer config client connectTimeout
//connectTimeout := config.GetConsumerConfig().ConnectTimeout
diff --git a/protocol/grpc/grpc_protocol.go b/protocol/grpc/grpc_protocol.go
index 83ae1c3..cafd5a7 100644
--- a/protocol/grpc/grpc_protocol.go
+++ b/protocol/grpc/grpc_protocol.go
@@ -79,7 +79,7 @@
panic("[GrpcProtocol]" + url.Key() + "is not existing")
}
- grpcMessageSize, _ := strconv.Atoi(url.GetParam(constant.MESSAGE_SIZE_KEY, "4"))
+ grpcMessageSize, _ := strconv.Atoi(url.GetParam(constant.MessageSizeKey, "4"))
srv := NewServer()
srv.SetBufferSize(grpcMessageSize)
gp.serverMap[url.Location] = srv
diff --git a/protocol/invocation/rpcinvocation.go b/protocol/invocation/rpcinvocation.go
index c729c09..bac9060 100644
--- a/protocol/invocation/rpcinvocation.go
+++ b/protocol/invocation/rpcinvocation.go
@@ -194,7 +194,7 @@
}
func (r *RPCInvocation) ServiceKey() string {
- return common.ServiceKey(strings.TrimPrefix(r.AttachmentsByKey(constant.PATH_KEY, r.AttachmentsByKey(constant.InterfaceKey, "")), "/"),
+ return common.ServiceKey(strings.TrimPrefix(r.AttachmentsByKey(constant.PathKey, r.AttachmentsByKey(constant.InterfaceKey, "")), "/"),
r.AttachmentsByKey(constant.GroupKey, ""), r.AttachmentsByKey(constant.VersionKey, ""))
}
diff --git a/protocol/invocation/rpcinvocation_test.go b/protocol/invocation/rpcinvocation_test.go
index b29f23c..2a36506 100644
--- a/protocol/invocation/rpcinvocation_test.go
+++ b/protocol/invocation/rpcinvocation_test.go
@@ -55,7 +55,7 @@
assert.NoError(t, err)
invocation := NewRPCInvocationWithOptions(WithAttachments(map[string]interface{}{
constant.InterfaceKey: sameInfPathConsumerUrl.GetParam(constant.InterfaceKey, ""),
- constant.PATH_KEY: sameInfPathConsumerUrl.Path,
+ constant.PathKey: sameInfPathConsumerUrl.Path,
constant.GroupKey: sameInfPathConsumerUrl.GetParam(constant.GroupKey, ""),
constant.VersionKey: sameInfPathConsumerUrl.GetParam(constant.VersionKey, ""),
}))
@@ -66,7 +66,7 @@
assert.NoError(t, err)
invocation = NewRPCInvocationWithOptions(WithAttachments(map[string]interface{}{
constant.InterfaceKey: diffInfPathConsumerUrl.GetParam(constant.InterfaceKey, ""),
- constant.PATH_KEY: diffInfPathConsumerUrl.Path,
+ constant.PathKey: diffInfPathConsumerUrl.Path,
constant.GroupKey: diffInfPathConsumerUrl.GetParam(constant.GroupKey, ""),
constant.VersionKey: diffInfPathConsumerUrl.GetParam(constant.VersionKey, ""),
}))
diff --git a/protocol/jsonrpc/http.go b/protocol/jsonrpc/http.go
index 95d4ddb..ad1b226 100644
--- a/protocol/jsonrpc/http.go
+++ b/protocol/jsonrpc/http.go
@@ -122,7 +122,7 @@
reqTimeout = 100 * time.Millisecond
}
httpHeader.Set("Timeout", reqTimeout.String())
- if md, ok := ctx.Value(constant.DUBBOGO_CTX_KEY).(map[string]string); ok {
+ if md, ok := ctx.Value(constant.DubboGoCtxKey).(map[string]string); ok {
for k := range md {
httpHeader.Set(k, md[k])
}
diff --git a/protocol/jsonrpc/jsonrpc_invoker.go b/protocol/jsonrpc/jsonrpc_invoker.go
index d2a0d1e..03b3280 100644
--- a/protocol/jsonrpc/jsonrpc_invoker.go
+++ b/protocol/jsonrpc/jsonrpc_invoker.go
@@ -50,7 +50,7 @@
inv := invocation.(*invocation_impl.RPCInvocation)
url := ji.GetURL()
req := ji.client.NewRequest(url, inv.MethodName(), inv.Arguments())
- ctxNew := context.WithValue(ctx, constant.DUBBOGO_CTX_KEY, map[string]string{
+ ctxNew := context.WithValue(ctx, constant.DubboGoCtxKey, map[string]string{
"X-Proxy-ID": "dubbogo",
"X-Services": url.Path,
"X-Method": inv.MethodName(),
diff --git a/protocol/jsonrpc/server.go b/protocol/jsonrpc/server.go
index 400b690..340849c 100644
--- a/protocol/jsonrpc/server.go
+++ b/protocol/jsonrpc/server.go
@@ -160,7 +160,7 @@
spanCtx, err := opentracing.GlobalTracer().Extract(opentracing.HTTPHeaders,
opentracing.HTTPHeadersCarrier(r.Header))
if err == nil {
- ctx = context.WithValue(ctx, constant.TRACING_REMOTE_SPAN_CTX, spanCtx)
+ ctx = context.WithValue(ctx, constant.TracingRemoteSpanCtx, spanCtx)
}
if len(reqHeader["Timeout"]) > 0 {
@@ -347,7 +347,7 @@
invoker := exporter.(*JsonrpcExporter).GetInvoker()
if invoker != nil {
result := invoker.Invoke(ctx, invocation.NewRPCInvocation(methodName, args, map[string]interface{}{
- constant.PATH_KEY: path,
+ constant.PathKey: path,
constant.VersionKey: codec.req.Version,
}))
if err := result.Error(); err != nil {
diff --git a/protocol/protocolwrapper/protocol_filter_wrapper.go b/protocol/protocolwrapper/protocol_filter_wrapper.go
index f04e15a..2c24178 100644
--- a/protocol/protocolwrapper/protocol_filter_wrapper.go
+++ b/protocol/protocolwrapper/protocol_filter_wrapper.go
@@ -50,7 +50,7 @@
if pfw.protocol == nil {
pfw.protocol = extension.GetProtocol(invoker.GetURL().Protocol)
}
- invoker = BuildInvokerChain(invoker, constant.SERVICE_FILTER_KEY)
+ invoker = BuildInvokerChain(invoker, constant.ServiceFilterKey)
return pfw.protocol.Export(invoker)
}
diff --git a/protocol/protocolwrapper/protocol_filter_wrapper_test.go b/protocol/protocolwrapper/protocol_filter_wrapper_test.go
index 42bd0a0..7862e4e 100644
--- a/protocol/protocolwrapper/protocol_filter_wrapper_test.go
+++ b/protocol/protocolwrapper/protocol_filter_wrapper_test.go
@@ -44,7 +44,7 @@
u := common.NewURLWithOptions(
common.WithParams(url.Values{}),
- common.WithParamsValue(constant.SERVICE_FILTER_KEY, mockFilterKey))
+ common.WithParamsValue(constant.ServiceFilterKey, mockFilterKey))
exporter := filtProto.Export(protocol.NewBaseInvoker(u))
_, ok := exporter.GetInvoker().(*FilterInvoker)
assert.True(t, ok)
@@ -72,7 +72,7 @@
func (ef *mockEchoFilter) Invoke(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result {
logger.Infof("invoking echo filter.")
logger.Debugf("%v,%v", invocation.MethodName(), len(invocation.Arguments()))
- if invocation.MethodName() == constant.ECHO && len(invocation.Arguments()) == 1 {
+ if invocation.MethodName() == constant.Echo && len(invocation.Arguments()) == 1 {
return &protocol.RPCResult{
Rest: invocation.Arguments()[0],
}
diff --git a/protocol/rest/client/client_impl/resty_client.go b/protocol/rest/client/client_impl/resty_client.go
index c7c16e8..7044a53 100644
--- a/protocol/rest/client/client_impl/resty_client.go
+++ b/protocol/rest/client/client_impl/resty_client.go
@@ -38,7 +38,7 @@
)
func init() {
- extension.SetRestClient(constant.DEFAULT_REST_CLIENT, NewRestyClient)
+ extension.SetRestClient(constant.DefaultRestClient, NewRestyClient)
}
// RestyClient a rest client implement by Resty
diff --git a/protocol/rest/config/reader/rest_config_reader.go b/protocol/rest/config/reader/rest_config_reader.go
index 18f06b2..6bfe5c2 100644
--- a/protocol/rest/config/reader/rest_config_reader.go
+++ b/protocol/rest/config/reader/rest_config_reader.go
@@ -60,7 +60,7 @@
restConsumerServiceConfigMap := make(map[string]*config.RestServiceConfig, len(restConsumerConfig.RestServiceConfigsMap))
for key, rc := range restConsumerConfig.RestServiceConfigsMap {
- rc.Client = getNotEmptyStr(rc.Client, restConsumerConfig.Client, constant.DEFAULT_REST_CLIENT)
+ rc.Client = getNotEmptyStr(rc.Client, restConsumerConfig.Client, constant.DefaultRestClient)
rc.RestMethodConfigsMap = initMethodConfigMap(rc, restConsumerConfig.Consumes, restConsumerConfig.Produces)
restConsumerServiceConfigMap[key] = rc
}
@@ -77,7 +77,7 @@
}
restProviderServiceConfigMap := make(map[string]*config.RestServiceConfig, len(restProviderConfig.RestServiceConfigsMap))
for key, rc := range restProviderConfig.RestServiceConfigsMap {
- rc.Server = getNotEmptyStr(rc.Server, restProviderConfig.Server, constant.DEFAULT_REST_SERVER)
+ rc.Server = getNotEmptyStr(rc.Server, restProviderConfig.Server, constant.DefaultRestServer)
rc.RestMethodConfigsMap = initMethodConfigMap(rc, restProviderConfig.Consumes, restProviderConfig.Produces)
restProviderServiceConfigMap[key] = rc
}
diff --git a/protocol/rest/server/server_impl/go_restful_server.go b/protocol/rest/server/server_impl/go_restful_server.go
index af7eb5a..464f5c8 100644
--- a/protocol/rest/server/server_impl/go_restful_server.go
+++ b/protocol/rest/server/server_impl/go_restful_server.go
@@ -42,7 +42,7 @@
)
func init() {
- extension.SetRestServer(constant.DEFAULT_REST_SERVER, NewGoRestfulServer)
+ extension.SetRestServer(constant.DefaultRestServer, NewGoRestfulServer)
}
var filterSlice []restful.FilterFunction
diff --git a/protocol/rpc_status.go b/protocol/rpc_status.go
index e0147e0..f35b2ae 100644
--- a/protocol/rpc_status.go
+++ b/protocol/rpc_status.go
@@ -256,7 +256,7 @@
atomic.CompareAndSwapInt32(&blackListRefreshing, 1, 0)
}()
- ivks := GetBlackListInvokers(constant.DEFAULT_BLACK_LIST_RECOVER_BLOCK)
+ ivks := GetBlackListInvokers(constant.DefaultBlackListRecoverBlock)
logger.Debug("blackList len = ", len(ivks))
for i := 0; i < 3; i++ {
diff --git a/registry/base_configuration_listener.go b/registry/base_configuration_listener.go
index 39ab265..f82e834 100644
--- a/registry/base_configuration_listener.go
+++ b/registry/base_configuration_listener.go
@@ -55,7 +55,7 @@
bcl.defaultConfiguratorFunc = f
bcl.dynamicConfiguration.AddListener(key, listener)
if rawConfig, err := bcl.dynamicConfiguration.GetInternalProperty(key,
- config_center.WithGroup(constant.DUBBO)); err != nil {
+ config_center.WithGroup(constant.Dubbo)); err != nil {
//set configurators to empty
bcl.configurators = []config_center.Configurator{}
return
@@ -102,13 +102,13 @@
}
var configurators []config_center.Configurator
for _, url := range urls {
- if url.Protocol == constant.EMPTY_PROTOCOL {
+ if url.Protocol == constant.EmptyProtocol {
configurators = []config_center.Configurator{}
break
}
override := url.GetParams()
- delete(override, constant.ANYHOST_KEY)
+ delete(override, constant.AnyhostKey)
if len(override) == 0 {
continue
}
diff --git a/registry/base_registry.go b/registry/base_registry.go
index 6acbfbd..e46d3f1 100644
--- a/registry/base_registry.go
+++ b/registry/base_registry.go
@@ -320,13 +320,13 @@
logger.Errorf("facadeBasedRegistry.CreatePath(path{%s}) = error{%#v}", dubboPath, perrors.WithStack(err))
return "", "", perrors.WithMessagef(err, "facadeBasedRegistry.CreatePath(path:%s)", dubboPath)
}
- params.Add(constant.ANYHOST_KEY, "true")
+ params.Add(constant.AnyhostKey, "true")
// Dubbo java consumer to start looking for the provider url,because the category does not match,
// the provider will not find, causing the consumer can not start, so we use consumers.
if len(c.Methods) != 0 {
- params.Add(constant.METHODS_KEY, strings.Join(c.Methods, ","))
+ params.Add(constant.MethodsKey, strings.Join(c.Methods, ","))
}
logger.Debugf("provider url params:%#v", params)
var host string
diff --git a/registry/directory/directory.go b/registry/directory/directory.go
index eb67b77..0a340af 100644
--- a/registry/directory/directory.go
+++ b/registry/directory/directory.go
@@ -191,7 +191,7 @@
if event != nil && event.Service != nil {
logger.Infof("selector add service url{%s}", event.Service.String())
}
- if event != nil && event.Service != nil && constant.ROUTER_PROTOCOL == event.Service.Protocol {
+ if event != nil && event.Service != nil && constant.RouterProtocol == event.Service.Protocol {
dir.configRouters()
}
if oldInvoker, _ := dir.doCacheInvoker(event.Service, event); oldInvoker != nil {
@@ -246,7 +246,7 @@
case remoting.EventTypeAdd, remoting.EventTypeUpdate:
u := dir.convertUrl(event)
logger.Infof("selector add service url{%s}", event.Service)
- if u != nil && constant.ROUTER_PROTOCOL == u.Protocol {
+ if u != nil && constant.RouterProtocol == u.Protocol {
dir.configRouters()
}
return dir.cacheInvoker(u, event), nil
@@ -267,12 +267,12 @@
// convertUrl processes override:// and router://
func (dir *RegistryDirectory) convertUrl(res *registry.ServiceEvent) *common.URL {
ret := res.Service
- if ret.Protocol == constant.OVERRIDE_PROTOCOL || // 1.for override url in 2.6.x
- ret.GetParam(constant.CATEGORY_KEY, constant.DEFAULT_CATEGORY) == constant.CONFIGURATORS_CATEGORY {
+ if ret.Protocol == constant.OverrideProtocol || // 1.for override url in 2.6.x
+ ret.GetParam(constant.CategoryKey, constant.DefaultCategory) == constant.ConfiguratorsCategory {
dir.configurators = append(dir.configurators, extension.GetDefaultConfigurator(ret))
ret = nil
- } else if ret.Protocol == constant.ROUTER_PROTOCOL || // 2.for router
- ret.GetParam(constant.CATEGORY_KEY, constant.DEFAULT_CATEGORY) == constant.ROUTER_CATEGORY {
+ } else if ret.Protocol == constant.RouterProtocol || // 2.for router
+ ret.GetParam(constant.CategoryKey, constant.DefaultCategory) == constant.RouterCategory {
ret = nil
}
return ret
@@ -304,7 +304,7 @@
} else {
for _, invokers := range groupInvokersMap {
staticDir := static.NewDirectory(invokers)
- cst := extension.GetCluster(dir.GetURL().SubURL.GetParam(constant.ClusterKey, constant.DEFAULT_CLUSTER))
+ cst := extension.GetCluster(dir.GetURL().SubURL.GetParam(constant.ClusterKey, constant.DefaultCluster))
err = staticDir.BuildRouterChain(invokers)
if err != nil {
logger.Error(err)
diff --git a/registry/etcdv3/registry.go b/registry/etcdv3/registry.go
index c777154..2576021 100644
--- a/registry/etcdv3/registry.go
+++ b/registry/etcdv3/registry.go
@@ -74,7 +74,7 @@
}
func newETCDV3Registry(url *common.URL) (registry.Registry, error) {
- timeout := url.GetParamDuration(constant.CONFIG_TIMEOUT_KEY, constant.DEFAULT_REG_TIMEOUT)
+ timeout := url.GetParamDuration(constant.ConfigTimeoutKey, constant.DefaultRegTimeout)
logger.Infof("etcd address is: %v, timeout is: %s", url.Location, timeout.String())
@@ -160,7 +160,7 @@
// register the svc to dataListener
r.dataListener.AddInterestedURL(svc)
- go r.listener.ListenServiceEvent(fmt.Sprintf("/dubbo/%s/"+constant.DEFAULT_CATEGORY, svc.Service()), r.dataListener)
+ go r.listener.ListenServiceEvent(fmt.Sprintf("/dubbo/%s/"+constant.DefaultCategory, svc.Service()), r.dataListener)
return configListener, nil
}
diff --git a/registry/etcdv3/service_discovery.go b/registry/etcdv3/service_discovery.go
index a99ea94..02d3c7e 100644
--- a/registry/etcdv3/service_discovery.go
+++ b/registry/etcdv3/service_discovery.go
@@ -49,7 +49,7 @@
var initLock sync.Mutex
func init() {
- extension.SetServiceDiscovery(constant.ETCDV3_KEY, newEtcdV3ServiceDiscovery)
+ extension.SetServiceDiscovery(constant.EtcdV3Key, newEtcdV3ServiceDiscovery)
}
// new etcd service discovery struct
@@ -235,12 +235,12 @@
return ""
}
// like: /services/servicename1/host(127.0.0.1)/8080
- return fmt.Sprintf("%s%d", ROOT+constant.PATH_SEPARATOR+instance.GetServiceName()+constant.PATH_SEPARATOR+instance.GetHost()+constant.KEY_SEPARATOR, instance.GetPort())
+ return fmt.Sprintf("%s%d", ROOT+constant.PathSeparator+instance.GetServiceName()+constant.PathSeparator+instance.GetHost()+constant.KeySeparator, instance.GetPort())
}
// to dubbo service path
func toParentPath(serviceName string) string {
- return ROOT + constant.PATH_SEPARATOR + serviceName
+ return ROOT + constant.PathSeparator + serviceName
}
// register service instance listener, instance listener and watcher are matched through serviceName
diff --git a/registry/event/base_configuration_listener.go b/registry/event/base_configuration_listener.go
index 0985c78..a9e2106 100644
--- a/registry/event/base_configuration_listener.go
+++ b/registry/event/base_configuration_listener.go
@@ -55,7 +55,7 @@
bcl.defaultConfiguratorFunc = f
bcl.dynamicConfiguration.AddListener(key, listener)
if rawConfig, err := bcl.dynamicConfiguration.GetInternalProperty(key,
- config_center.WithGroup(constant.DUBBO)); err != nil {
+ config_center.WithGroup(constant.Dubbo)); err != nil {
// set configurators to empty
bcl.configurators = []config_center.Configurator{}
return
@@ -102,13 +102,13 @@
}
var configurators []config_center.Configurator
for _, url := range urls {
- if url.Protocol == constant.EMPTY_PROTOCOL {
+ if url.Protocol == constant.EmptyProtocol {
configurators = []config_center.Configurator{}
break
}
override := url.GetParams()
- delete(override, constant.ANYHOST_KEY)
+ delete(override, constant.AnyhostKey)
if len(override) == 0 {
continue
}
diff --git a/registry/event/metadata_service_url_params_customizer.go b/registry/event/metadata_service_url_params_customizer.go
index 085480d..205e3ce 100644
--- a/registry/event/metadata_service_url_params_customizer.go
+++ b/registry/event/metadata_service_url_params_customizer.go
@@ -71,7 +71,7 @@
logger.Errorf("could not transfer the map to json", err)
return
}
- instance.GetMetadata()[constant.METADATA_SERVICE_URL_PARAMS_PROPERTY_NAME] = string(str)
+ instance.GetMetadata()[constant.MetadataServiceURLParamsPropertyName] = string(str)
}
func (m *metadataServiceURLParamsMetadataCustomizer) convertToParams(url *common.URL) map[string]string {
@@ -84,7 +84,7 @@
}
p[k] = v[0]
}
- p[constant.PORT_KEY] = url.Port
- p[constant.PROTOCOL_KEY] = url.Protocol
+ p[constant.PortKey] = url.Port
+ p[constant.ProtocolKey] = url.Protocol
return p
}
diff --git a/registry/event/protocol_ports_metadata_customizer.go b/registry/event/protocol_ports_metadata_customizer.go
index 058c0b9..8478aff 100644
--- a/registry/event/protocol_ports_metadata_customizer.go
+++ b/registry/event/protocol_ports_metadata_customizer.go
@@ -73,7 +73,7 @@
protocolMap[u.Protocol] = port
}
- instance.GetMetadata()[constant.SERVICE_INSTANCE_ENDPOINTS] = endpointsStr(protocolMap)
+ instance.GetMetadata()[constant.ServiceInstanceEndpoints] = endpointsStr(protocolMap)
}
// endpointsStr convert the map to json like [{"protocol": "dubbo", "port": 123}]
diff --git a/registry/event/service_instances_changed_listener_impl.go b/registry/event/service_instances_changed_listener_impl.go
index 6d6ab00..4992175 100644
--- a/registry/event/service_instances_changed_listener_impl.go
+++ b/registry/event/service_instances_changed_listener_impl.go
@@ -74,7 +74,7 @@
logger.Warnf("Instance metadata is nil: %s", instance.GetHost())
continue
}
- revision := instance.GetMetadata()[constant.EXPORTED_SERVICES_REVISION_PROPERTY_NAME]
+ revision := instance.GetMetadata()[constant.ExportedServicesRevisionPropertyName]
if "0" == revision {
logger.Infof("Find instance without valid service metadata: %s", instance.GetHost())
continue
@@ -141,16 +141,16 @@
return nil
}
-// getMetadataInfo get metadata info when METADATA_STORAGE_TYPE_PROPERTY_NAME is null
+// getMetadataInfo get metadata info when MetadataStorageTypePropertyName is null
func (lstn *ServiceInstancesChangedListenerImpl) getMetadataInfo(instance registry.ServiceInstance, revision string) (*common.MetadataInfo, error) {
var metadataStorageType string
var metadataInfo *common.MetadataInfo
if instance.GetMetadata() == nil {
- metadataStorageType = constant.DEFAULT_METADATA_STORAGE_TYPE
+ metadataStorageType = constant.DefaultMetadataStorageType
} else {
- metadataStorageType = instance.GetMetadata()[constant.METADATA_STORAGE_TYPE_PROPERTY_NAME]
+ metadataStorageType = instance.GetMetadata()[constant.MetadataStorageTypePropertyName]
}
- if metadataStorageType == constant.REMOTE_METADATA_STORAGE_TYPE {
+ if metadataStorageType == constant.RemoteMetadataStorageType {
remoteMetadataServiceImpl, err := extension.GetRemoteMetadataService()
if err != nil {
return nil, err
@@ -161,7 +161,7 @@
}
} else {
var err error
- proxyFactory := extension.GetMetadataServiceProxyFactory(constant.DEFAULT_KEY)
+ proxyFactory := extension.GetMetadataServiceProxyFactory(constant.DefaultKey)
metadataService := proxyFactory.GetProxy(instance)
metadataInfo, err = metadataService.GetMetadataInfo(revision)
if err != nil {
diff --git a/registry/event/service_revision_customizer.go b/registry/event/service_revision_customizer.go
index ccf8485..c648eed 100644
--- a/registry/event/service_revision_customizer.go
+++ b/registry/event/service_revision_customizer.go
@@ -54,7 +54,7 @@
return
}
- urls, err := ms.GetExportedURLs(constant.ANY_VALUE, constant.ANY_VALUE, constant.ANY_VALUE, constant.ANY_VALUE)
+ urls, err := ms.GetExportedURLs(constant.AnyValue, constant.AnyValue, constant.AnyValue, constant.AnyValue)
if err != nil {
logger.Errorf("could not find the exported url", err)
}
@@ -63,7 +63,7 @@
if len(revision) == 0 {
revision = defaultRevision
}
- instance.GetMetadata()[constant.EXPORTED_SERVICES_REVISION_PROPERTY_NAME] = revision
+ instance.GetMetadata()[constant.ExportedServicesRevisionPropertyName] = revision
}
type subscribedServicesRevisionMetadataCustomizer struct{}
@@ -90,7 +90,7 @@
if len(revision) == 0 {
revision = defaultRevision
}
- instance.GetMetadata()[constant.SUBSCRIBED_SERVICES_REVISION_PROPERTY_NAME] = revision
+ instance.GetMetadata()[constant.SubscribedServicesRevisionPropertyName] = revision
}
// resolveRevision is different from Dubbo because golang doesn't support overload
@@ -111,7 +111,7 @@
} else {
for _, m := range u.Methods {
// methods are part of candidates
- candidates = append(candidates, sk+constant.KEY_SEPARATOR+m)
+ candidates = append(candidates, sk+constant.KeySeparator+m)
}
}
diff --git a/registry/file/service_discovery.go b/registry/file/service_discovery.go
index 4fabafb..6c8960e 100644
--- a/registry/file/service_discovery.go
+++ b/registry/file/service_discovery.go
@@ -46,7 +46,7 @@
// init will put the service discovery into extension
func init() {
- extension.SetServiceDiscovery(constant.FILE_KEY, newFileSystemServiceDiscovery)
+ extension.SetServiceDiscovery(constant.FileKey, newFileSystemServiceDiscovery)
}
// fileServiceDiscovery is the implementation of service discovery based on file.
@@ -57,7 +57,7 @@
}
func newFileSystemServiceDiscovery() (registry.ServiceDiscovery, error) {
- if config.GetMetadataReportConfg().Protocol != constant.FILE_KEY {
+ if config.GetMetadataReportConfg().Protocol != constant.FileKey {
return nil, perrors.New("could not init the instance because the config is invalid")
}
@@ -66,8 +66,8 @@
return nil, perrors.WithStack(err)
}
- fdcf := extension.GetConfigCenterFactory(constant.FILE_KEY)
- p := path.Join(rp, ".dubbo", constant.REGISTRY_KEY)
+ fdcf := extension.GetConfigCenterFactory(constant.FileKey)
+ p := path.Join(rp, ".dubbo", constant.RegistryKey)
url, _ := common.NewURL("")
url.AddParamAvoidNil(file.ConfigCenterDirParamName, p)
c, err := fdcf.GetDynamicConfiguration(url)
diff --git a/registry/kubernetes/registry.go b/registry/kubernetes/registry.go
index b6e1107..63af25f 100644
--- a/registry/kubernetes/registry.go
+++ b/registry/kubernetes/registry.go
@@ -137,7 +137,7 @@
// register the svc to dataListener
r.dataListener.AddInterestedURL(svc)
- go r.listener.ListenServiceEvent(fmt.Sprintf("/dubbo/%s/"+constant.DEFAULT_CATEGORY, svc.Service()), r.dataListener)
+ go r.listener.ListenServiceEvent(fmt.Sprintf("/dubbo/%s/"+constant.DefaultCategory, svc.Service()), r.dataListener)
return configListener, nil
}
diff --git a/registry/nacos/listener.go b/registry/nacos/listener.go
index a186182..3ed949c 100644
--- a/registry/nacos/listener.go
+++ b/registry/nacos/listener.go
@@ -190,7 +190,7 @@
return perrors.New("nacos naming namingClient stopped")
}
serviceName := getSubscribeName(nl.listenUrl)
- groupName := nl.listenUrl.GetParam(constant.REGISTRY_GROUP_KEY, defaultGroup)
+ groupName := nl.listenUrl.GetParam(constant.RegistryGroupKey, defaultGroup)
nl.subscribeParam = &vo.SubscribeParam{
ServiceName: serviceName,
SubscribeCallback: nl.Callback,
diff --git a/registry/nacos/registry.go b/registry/nacos/registry.go
index 531ea6c..af61e8c 100644
--- a/registry/nacos/registry.go
+++ b/registry/nacos/registry.go
@@ -50,7 +50,7 @@
func init() {
localIP = common.GetLocalIp()
- extension.SetRegistry(constant.NACOS_KEY, newNacosRegistry)
+ extension.SetRegistry(constant.NacosKey, newNacosRegistry)
}
type nacosRegistry struct {
@@ -60,7 +60,7 @@
}
func getCategory(url *common.URL) string {
- role, _ := strconv.Atoi(url.GetParam(constant.RoleKey, strconv.Itoa(constant.NACOS_DEFAULT_ROLETYPE)))
+ role, _ := strconv.Atoi(url.GetParam(constant.RoleKey, strconv.Itoa(constant.NacosDefaultRoleType)))
category := common.DubboNodes[role]
return category
}
@@ -77,7 +77,7 @@
func appendParam(target *bytes.Buffer, url *common.URL, key string) {
value := url.GetParam(key, "")
- target.Write([]byte(constant.NACOS_SERVICE_NAME_SEPARATOR))
+ target.Write([]byte(constant.NacosServiceNameSeparator))
if strings.TrimSpace(value) != "" {
target.Write([]byte(value))
}
@@ -92,9 +92,9 @@
return true
})
- params[constant.NACOS_CATEGORY_KEY] = category
- params[constant.NACOS_PROTOCOL_KEY] = url.Protocol
- params[constant.NACOS_PATH_KEY] = url.Path
+ params[constant.NacosCategoryKey] = category
+ params[constant.NacosProtocolKey] = url.Protocol
+ params[constant.NacosPathKey] = url.Path
if len(url.Ip) == 0 {
url.Ip = localIP
}
@@ -177,7 +177,7 @@
// TODO
// role, _ := strconv.Atoi(nr.URL.GetParam(constant.RoleKey, ""))
role, _ := strconv.Atoi(url.GetParam(constant.RoleKey, ""))
- if role != common.Consumer {
+ if role != common.CONSUMER {
return nil
}
@@ -188,7 +188,7 @@
}
groupName := nr.GetParam(constant.GroupKey, defaultGroup)
- url.SetParam(constant.REGISTRY_GROUP_KEY, groupName) // update to registry.group
+ url.SetParam(constant.RegistryGroupKey, groupName) // update to registry.group
listener, err := nr.subscribe(url)
if err != nil {
diff --git a/registry/nacos/registry_test.go b/registry/nacos/registry_test.go
index f4c49ca..36f46d7 100644
--- a/registry/nacos/registry_test.go
+++ b/registry/nacos/registry_test.go
@@ -44,7 +44,7 @@
}
regurlMap := url.Values{}
regurlMap.Set(constant.RoleKey, strconv.Itoa(common.PROVIDER))
- regurlMap.Set(constant.NACOS_NOT_LOAD_LOCAL_CACHE, "true")
+ regurlMap.Set(constant.NacosNotLoadLocalCache, "true")
regurl, _ := common.NewURL("registry://console.nacos.io:80", common.WithParams(regurlMap))
urlMap := url.Values{}
@@ -81,7 +81,7 @@
}
regurlMap := url.Values{}
regurlMap.Set(constant.RoleKey, strconv.Itoa(common.PROVIDER))
- regurlMap.Set(constant.NACOS_NOT_LOAD_LOCAL_CACHE, "true")
+ regurlMap.Set(constant.NacosNotLoadLocalCache, "true")
regurl, _ := common.NewURL("registry://console.nacos.io:80", common.WithParams(regurlMap))
urlMap := url.Values{}
@@ -90,7 +90,7 @@
urlMap.Set(constant.InterfaceKey, "com.dubbo.user.UserProvider")
urlMap.Set(constant.VersionKey, "1.0.0")
urlMap.Set(constant.ClusterKey, "mock")
- urlMap.Set(constant.NACOS_PATH_KEY, "")
+ urlMap.Set(constant.NacosPathKey, "")
testUrl, _ := common.NewURL("dubbo://127.0.0.1:20000/com.dubbo.user.UserProvider", common.WithParams(urlMap), common.WithMethods([]string{"GetUser", "AddUser"}))
reg, _ := newNacosRegistry(regurl)
@@ -101,7 +101,7 @@
return
}
- regurl.SetParam(constant.RoleKey, strconv.Itoa(common.Consumer))
+ regurl.SetParam(constant.RoleKey, strconv.Itoa(common.CONSUMER))
reg2, _ := newNacosRegistry(regurl)
listener, err := reg2.(*nacosRegistry).subscribe(testUrl)
assert.Nil(t, err)
@@ -125,7 +125,7 @@
}
regurlMap := url.Values{}
regurlMap.Set(constant.RoleKey, strconv.Itoa(common.PROVIDER))
- regurlMap.Set(constant.NACOS_NOT_LOAD_LOCAL_CACHE, "true")
+ regurlMap.Set(constant.NacosNotLoadLocalCache, "true")
regurl, _ := common.NewURL("registry://console.nacos.io:80", common.WithParams(regurlMap))
urlMap := url.Values{}
@@ -134,7 +134,7 @@
urlMap.Set(constant.InterfaceKey, "com.ikurento.user.UserProvider")
urlMap.Set(constant.VersionKey, "2.0.0")
urlMap.Set(constant.ClusterKey, "mock")
- urlMap.Set(constant.NACOS_PATH_KEY, "")
+ urlMap.Set(constant.NacosPathKey, "")
url1, _ := common.NewURL("dubbo://127.0.0.1:20000/com.ikurento.user.UserProvider", common.WithParams(urlMap), common.WithMethods([]string{"GetUser", "AddUser"}))
url2, _ := common.NewURL("dubbo://127.0.0.2:20000/com.ikurento.user.UserProvider", common.WithParams(urlMap), common.WithMethods([]string{"GetUser", "AddUser"}))
@@ -152,7 +152,7 @@
return
}
- regurl.SetParam(constant.RoleKey, strconv.Itoa(common.Consumer))
+ regurl.SetParam(constant.RoleKey, strconv.Itoa(common.CONSUMER))
reg2, _ := newNacosRegistry(regurl)
listener, err := reg2.(*nacosRegistry).subscribe(url1)
assert.Nil(t, err)
@@ -199,7 +199,7 @@
func TestNacosListener_Close(t *testing.T) {
regurlMap := url.Values{}
regurlMap.Set(constant.RoleKey, strconv.Itoa(common.PROVIDER))
- regurlMap.Set(constant.NACOS_NOT_LOAD_LOCAL_CACHE, "true")
+ regurlMap.Set(constant.NacosNotLoadLocalCache, "true")
regurl, _ := common.NewURL("registry://console.nacos.io:80", common.WithParams(regurlMap))
urlMap := url.Values{}
@@ -208,7 +208,7 @@
urlMap.Set(constant.InterfaceKey, "com.ikurento.user.UserProvider2")
urlMap.Set(constant.VersionKey, "1.0.0")
urlMap.Set(constant.ClusterKey, "mock")
- urlMap.Set(constant.NACOS_PATH_KEY, "")
+ urlMap.Set(constant.NacosPathKey, "")
url1, _ := common.NewURL("dubbo://127.0.0.1:20000/com.ikurento.user.UserProvider2", common.WithParams(urlMap), common.WithMethods([]string{"GetUser", "AddUser"}))
reg, _ := newNacosRegistry(regurl)
listener, err := reg.(*nacosRegistry).subscribe(url1)
diff --git a/registry/nacos/service_discovery.go b/registry/nacos/service_discovery.go
index 58717a5..b69053f 100644
--- a/registry/nacos/service_discovery.go
+++ b/registry/nacos/service_discovery.go
@@ -45,13 +45,13 @@
)
const (
- defaultGroup = constant.SERVICE_DISCOVERY_DEFAULT_GROUP
+ defaultGroup = constant.ServiceDiscoveryDefaultGroup
idKey = "id"
)
// init will put the service discovery into extension
func init() {
- extension.SetServiceDiscovery(constant.NACOS_KEY, newNacosServiceDiscovery)
+ extension.SetServiceDiscovery(constant.NacosKey, newNacosServiceDiscovery)
}
// nacosServiceDiscovery is the implementation of service discovery based on nacos.
@@ -336,7 +336,7 @@
common.WithParams(make(url.Values)),
common.WithPassword(metadataReportConfig.Password),
common.WithUsername(metadataReportConfig.Username),
- common.WithParamsValue(constant.REGISTRY_TIMEOUT_KEY, metadataReportConfig.Timeout))
+ common.WithParamsValue(constant.RegistryTimeoutKey, metadataReportConfig.Timeout))
url.Location = metadataReportConfig.Address
client, err := nacos.NewNacosClientByUrl(url)
if err != nil {
diff --git a/registry/protocol/protocol.go b/registry/protocol/protocol.go
index 566a93f..ce19d38 100644
--- a/registry/protocol/protocol.go
+++ b/registry/protocol/protocol.go
@@ -137,7 +137,7 @@
registryUrl := url
serviceUrl := registryUrl.SubURL
if registryUrl.Protocol == constant.RegistryProtocol {
- registryUrl.Protocol = registryUrl.GetParam(constant.REGISTRY_KEY, "")
+ registryUrl.Protocol = registryUrl.GetParam(constant.RegistryKey, "")
}
var reg registry.Registry
@@ -163,7 +163,7 @@
}
// new cluster invoker
- cluster := extension.GetCluster(serviceUrl.GetParam(constant.ClusterKey, constant.DEFAULT_CLUSTER))
+ cluster := extension.GetCluster(serviceUrl.GetParam(constant.ClusterKey, constant.DefaultCluster))
invoker := cluster.Join(directory)
proto.invokers = append(proto.invokers, invoker)
return invoker
@@ -329,51 +329,51 @@
func isMatched(providerUrl *common.URL, consumerUrl *common.URL) bool {
// Compatible with the 2.6.x
- if len(providerUrl.GetParam(constant.CATEGORY_KEY, "")) == 0 &&
- providerUrl.Protocol == constant.OVERRIDE_PROTOCOL {
- providerUrl.AddParam(constant.CATEGORY_KEY, constant.CONFIGURATORS_CATEGORY)
+ if len(providerUrl.GetParam(constant.CategoryKey, "")) == 0 &&
+ providerUrl.Protocol == constant.OverrideProtocol {
+ providerUrl.AddParam(constant.CategoryKey, constant.ConfiguratorsCategory)
}
consumerInterface := consumerUrl.GetParam(constant.InterfaceKey, consumerUrl.Path)
providerInterface := providerUrl.GetParam(constant.InterfaceKey, providerUrl.Path)
- if !(constant.ANY_VALUE == consumerInterface ||
- constant.ANY_VALUE == providerInterface ||
+ if !(constant.AnyValue == consumerInterface ||
+ constant.AnyValue == providerInterface ||
providerInterface == consumerInterface) {
return false
}
- if !isMatchCategory(providerUrl.GetParam(constant.CATEGORY_KEY, constant.DEFAULT_CATEGORY),
- consumerUrl.GetParam(constant.CATEGORY_KEY, constant.DEFAULT_CATEGORY)) {
+ if !isMatchCategory(providerUrl.GetParam(constant.CategoryKey, constant.DefaultCategory),
+ consumerUrl.GetParam(constant.CategoryKey, constant.DefaultCategory)) {
return false
}
- if !providerUrl.GetParamBool(constant.ENABLED_KEY, true) &&
- consumerUrl.GetParam(constant.ENABLED_KEY, "") != constant.ANY_VALUE {
+ if !providerUrl.GetParamBool(constant.EnabledKey, true) &&
+ consumerUrl.GetParam(constant.EnabledKey, "") != constant.AnyValue {
return false
}
consumerGroup := consumerUrl.GetParam(constant.GroupKey, "")
consumerVersion := consumerUrl.GetParam(constant.VersionKey, "")
- consumerClassifier := consumerUrl.GetParam(constant.CLASSIFIER_KEY, "")
+ consumerClassifier := consumerUrl.GetParam(constant.ClassifierKey, "")
providerGroup := providerUrl.GetParam(constant.GroupKey, "")
providerVersion := providerUrl.GetParam(constant.VersionKey, "")
- providerClassifier := providerUrl.GetParam(constant.CLASSIFIER_KEY, "")
+ providerClassifier := providerUrl.GetParam(constant.ClassifierKey, "")
// todo: public static boolean isContains(String values, String value) {
- // return isNotEmpty(values) && isContains(COMMA_SPLIT_PATTERN.split(values), value);
+ // return isNotEmpty(values) && isContains(CommaSplitPattern.split(values), value);
// }
- return (consumerGroup == constant.ANY_VALUE || consumerGroup == providerGroup ||
- strings.Contains(consumerGroup, providerGroup)) && (consumerVersion == constant.ANY_VALUE ||
+ return (consumerGroup == constant.AnyValue || consumerGroup == providerGroup ||
+ strings.Contains(consumerGroup, providerGroup)) && (consumerVersion == constant.AnyValue ||
consumerVersion == providerVersion) && (len(consumerClassifier) == 0 ||
- consumerClassifier == constant.ANY_VALUE || consumerClassifier == providerClassifier)
+ consumerClassifier == constant.AnyValue || consumerClassifier == providerClassifier)
}
func isMatchCategory(category string, categories string) bool {
if len(categories) == 0 {
- return category == constant.DEFAULT_CATEGORY
- } else if strings.Contains(categories, constant.ANY_VALUE) {
+ return category == constant.DefaultCategory
+ } else if strings.Contains(categories, constant.AnyValue) {
return true
- } else if strings.Contains(categories, constant.REMOVE_VALUE_PREFIX) {
- return !strings.Contains(categories, constant.REMOVE_VALUE_PREFIX+category)
+ } else if strings.Contains(categories, constant.RemoveValuePrefix) {
+ return !strings.Contains(categories, constant.RemoveValuePrefix+category)
} else {
return strings.Contains(categories, category)
}
@@ -381,9 +381,9 @@
func getSubscribedOverrideUrl(providerUrl *common.URL) *common.URL {
newUrl := providerUrl.Clone()
- newUrl.Protocol = constant.PROVIDER_PROTOCOL
- newUrl.SetParam(constant.CATEGORY_KEY, constant.CONFIGURATORS_CATEGORY)
- newUrl.SetParam(constant.CHECK_KEY, "false")
+ newUrl.Protocol = constant.ProviderProtocol
+ newUrl.SetParam(constant.CategoryKey, constant.ConfiguratorsCategory)
+ newUrl.SetParam(constant.CheckKey, "false")
return newUrl
}
@@ -412,7 +412,7 @@
url := invoker.GetURL()
// if the protocol == registry, set protocol the registry value in url.params
if url.Protocol == constant.RegistryProtocol {
- url.Protocol = url.GetParam(constant.REGISTRY_KEY, "")
+ url.Protocol = url.GetParam(constant.RegistryKey, "")
}
return url
}
diff --git a/registry/service_instance.go b/registry/service_instance.go
index 12cc350..b329da5 100644
--- a/registry/service_instance.go
+++ b/registry/service_instance.go
@@ -155,7 +155,7 @@
// GetEndPoints get end points from metadata
func (d *DefaultServiceInstance) GetEndPoints() []*Endpoint {
- rawEndpoints := d.Metadata[constant.SERVICE_INSTANCE_ENDPOINTS]
+ rawEndpoints := d.Metadata[constant.ServiceInstanceEndpoints]
if len(rawEndpoints) == 0 {
return nil
}
diff --git a/registry/servicediscovery/service_discovery_registry.go b/registry/servicediscovery/service_discovery_registry.go
index 19d28bb..fcd2d2b 100644
--- a/registry/servicediscovery/service_discovery_registry.go
+++ b/registry/servicediscovery/service_discovery_registry.go
@@ -71,7 +71,7 @@
if err != nil {
return nil, err
}
- subscribedServices := parseServices(url.GetParam(constant.SUBSCRIBED_SERVICE_NAMES_KEY, ""))
+ subscribedServices := parseServices(url.GetParam(constant.SubscribedServiceNamesKey, ""))
subscribedURLsSynthesizers := synthesizer.GetAllSynthesizer()
serviceNameMapping := extension.GetGlobalServiceNameMapping()
metaDataService, err := local.GetLocalMetadataService()
@@ -118,7 +118,7 @@
}
func creatServiceDiscovery(url *common.URL) (registry.ServiceDiscovery, error) {
- sdcName := url.GetParam(constant.REGISTRY_KEY, "")
+ sdcName := url.GetParam(constant.RegistryKey, "")
originServiceDiscovery, err := extension.GetServiceDiscovery(sdcName)
if err != nil {
return nil, perrors.WithMessage(err, "Create service discovery fialed")
@@ -181,7 +181,7 @@
func shouldRegister(url *common.URL) bool {
side := url.GetParam(constant.SideKey, "")
- if side == constant.PROVIDER_PROTOCOL {
+ if side == constant.ProviderProtocol {
return true
}
logger.Debugf("The URL should not be register.", url.String())
@@ -247,7 +247,7 @@
bf.WriteString("?")
appendParam(bf, constant.VersionKey, url)
appendParam(bf, constant.GroupKey, url)
- appendParam(bf, constant.NACOS_PROTOCOL_KEY, url)
+ appendParam(bf, constant.NacosProtocolKey, url)
return bf.String()
}
diff --git a/registry/servicediscovery/synthesizer/rest/rest_subscribed_urls_synthesizer.go b/registry/servicediscovery/synthesizer/rest/rest_subscribed_urls_synthesizer.go
index 8f94c00..6823662 100644
--- a/registry/servicediscovery/synthesizer/rest/rest_subscribed_urls_synthesizer.go
+++ b/registry/servicediscovery/synthesizer/rest/rest_subscribed_urls_synthesizer.go
@@ -47,9 +47,9 @@
u := common.NewURLWithOptions(common.WithProtocol(subscribedURL.Protocol), common.WithIp(splitHost[0]),
common.WithPort(splitHost[1]), common.WithPath(subscribedURL.GetParam(constant.InterfaceKey, subscribedURL.Path)),
common.WithParams(url.Values{}),
- common.WithParamsValue(constant.SideKey, constant.PROVIDER_PROTOCOL),
+ common.WithParamsValue(constant.SideKey, constant.ProviderProtocol),
common.WithParamsValue(constant.ApplicationKey, s.GetServiceName()),
- common.WithParamsValue(constant.REGISTRY_KEY, "true"),
+ common.WithParamsValue(constant.RegistryKey, "true"),
)
urls[i] = u
}
diff --git a/registry/servicediscovery/synthesizer/rest/rest_subscribed_urls_synthesizer_test.go b/registry/servicediscovery/synthesizer/rest/rest_subscribed_urls_synthesizer_test.go
index 8d111ed..5d809a4 100644
--- a/registry/servicediscovery/synthesizer/rest/rest_subscribed_urls_synthesizer_test.go
+++ b/registry/servicediscovery/synthesizer/rest/rest_subscribed_urls_synthesizer_test.go
@@ -60,15 +60,15 @@
u1 := common.NewURLWithOptions(common.WithProtocol("rest"), common.WithIp("127.0.0.1"),
common.WithPort("80"), common.WithPath("org.apache.dubbo-go.mockService"),
common.WithParams(url.Values{}),
- common.WithParamsValue(constant.SideKey, constant.PROVIDER_PROTOCOL),
+ common.WithParamsValue(constant.SideKey, constant.ProviderProtocol),
common.WithParamsValue(constant.ApplicationKey, "test1"),
- common.WithParamsValue(constant.REGISTRY_KEY, "true"))
+ common.WithParamsValue(constant.RegistryKey, "true"))
u2 := common.NewURLWithOptions(common.WithProtocol("rest"), common.WithIp("127.0.0.2"),
common.WithPort("8081"), common.WithPath("org.apache.dubbo-go.mockService"),
common.WithParams(url.Values{}),
- common.WithParamsValue(constant.SideKey, constant.PROVIDER_PROTOCOL),
+ common.WithParamsValue(constant.SideKey, constant.ProviderProtocol),
common.WithParamsValue(constant.ApplicationKey, "test2"),
- common.WithParamsValue(constant.REGISTRY_KEY, "true"))
+ common.WithParamsValue(constant.RegistryKey, "true"))
expectUrls = append(expectUrls, u1, u2)
result := syn.Synthesize(subUrl, instances)
assert.Equal(t, expectUrls, result)
diff --git a/registry/zookeeper/registry.go b/registry/zookeeper/registry.go
index 029654d..b6c64b9 100644
--- a/registry/zookeeper/registry.go
+++ b/registry/zookeeper/registry.go
@@ -139,7 +139,7 @@
regConfigListener.Close()
}
newDataListener.SubscribeURL(regConfigListener.subscribeURL, NewRegistryConfigurationListener(r.client, r, regConfigListener.subscribeURL))
- go r.listener.ListenServiceEvent(regConfigListener.subscribeURL, fmt.Sprintf("/dubbo/%s/"+constant.DEFAULT_CATEGORY, url.QueryEscape(regConfigListener.subscribeURL.Service())), newDataListener)
+ go r.listener.ListenServiceEvent(regConfigListener.subscribeURL, fmt.Sprintf("/dubbo/%s/"+constant.DefaultCategory, url.QueryEscape(regConfigListener.subscribeURL.Service())), newDataListener)
}
}
@@ -244,8 +244,8 @@
func (r *zkRegistry) getListener(conf *common.URL) (*RegistryConfigurationListener, error) {
var zkListener *RegistryConfigurationListener
dataListener := r.dataListener
- ttl := r.GetParam(constant.REGISTRY_TTL_KEY, constant.DEFAULT_REG_TTL)
- conf.SetParam(constant.REGISTRY_TTL_KEY, ttl)
+ ttl := r.GetParam(constant.RegistryTTLKey, constant.DefaultRegTTL)
+ conf.SetParam(constant.RegistryTTLKey, ttl)
dataListener.mutex.Lock()
defer dataListener.mutex.Unlock()
if r.dataListener.subscribed[conf.ServiceKey()] != nil {
@@ -281,7 +281,7 @@
// Interested register to dataconfig.
r.dataListener.SubscribeURL(conf, zkListener)
- go r.listener.ListenServiceEvent(conf, fmt.Sprintf("/dubbo/%s/"+constant.DEFAULT_CATEGORY, url.QueryEscape(conf.Service())), r.dataListener)
+ go r.listener.ListenServiceEvent(conf, fmt.Sprintf("/dubbo/%s/"+constant.DefaultCategory, url.QueryEscape(conf.Service())), r.dataListener)
return zkListener, nil
}
diff --git a/registry/zookeeper/service_discovery.go b/registry/zookeeper/service_discovery.go
index 6ea4082..b2b1391 100644
--- a/registry/zookeeper/service_discovery.go
+++ b/registry/zookeeper/service_discovery.go
@@ -45,7 +45,7 @@
// init will put the service discovery into extension
func init() {
- extension.SetServiceDiscovery(constant.ZOOKEEPER_KEY, newZookeeperServiceDiscovery)
+ extension.SetServiceDiscovery(constant.ZookeeperKey, newZookeeperServiceDiscovery)
}
type zookeeperServiceDiscovery struct {
@@ -70,7 +70,7 @@
common.WithParams(make(url.Values)),
common.WithPassword(metadataReportConfig.Password),
common.WithUsername(metadataReportConfig.Username),
- common.WithParamsValue(constant.REGISTRY_TIMEOUT_KEY, metadataReportConfig.Timeout))
+ common.WithParamsValue(constant.RegistryTimeoutKey, metadataReportConfig.Timeout))
url.Location = metadataReportConfig.Address
zksd := &zookeeperServiceDiscovery{
url: url,
@@ -274,9 +274,9 @@
// to resolve event to do DispatchEventByServiceName
func (zksd *zookeeperServiceDiscovery) DataChange(eventType remoting.Event) bool {
path := strings.TrimPrefix(eventType.Path, zksd.rootPath)
- path = strings.TrimPrefix(path, constant.PATH_SEPARATOR)
+ path = strings.TrimPrefix(path, constant.PathSeparator)
// get service name in zk path
- serviceName := strings.Split(path, constant.PATH_SEPARATOR)[0]
+ serviceName := strings.Split(path, constant.PathSeparator)[0]
var err error
instances := zksd.GetInstances(serviceName)
diff --git a/remoting/getty/dubbo_codec_for_test.go b/remoting/getty/dubbo_codec_for_test.go
index 9a2b84d..39abebd 100644
--- a/remoting/getty/dubbo_codec_for_test.go
+++ b/remoting/getty/dubbo_codec_for_test.go
@@ -58,12 +58,12 @@
tmpInvocation := invoc
svc := impl.Service{}
- svc.Path = tmpInvocation.AttachmentsByKey(constant.PATH_KEY, "")
+ svc.Path = tmpInvocation.AttachmentsByKey(constant.PathKey, "")
svc.Interface = tmpInvocation.AttachmentsByKey(constant.InterfaceKey, "")
svc.Version = tmpInvocation.AttachmentsByKey(constant.VersionKey, "")
svc.Group = tmpInvocation.AttachmentsByKey(constant.GroupKey, "")
svc.Method = tmpInvocation.MethodName()
- timeout, err := strconv.Atoi(tmpInvocation.AttachmentsByKey(constant.TimeoutKey, strconv.Itoa(constant.DEFAULT_REMOTING_TIMEOUT)))
+ timeout, err := strconv.Atoi(tmpInvocation.AttachmentsByKey(constant.TimeoutKey, strconv.Itoa(constant.DefaultRemotingTimeout)))
if err != nil {
// it will be wrapped in readwrite.Write .
return nil, perrors.WithStack(err)
@@ -71,11 +71,11 @@
svc.Timeout = time.Duration(timeout)
header := impl.DubboHeader{}
- serialization := tmpInvocation.AttachmentsByKey(constant.SerializationKey, constant.HESSIAN2_SERIALIZATION)
- if serialization == constant.PROTOBUF_SERIALIZATION {
- header.SerialID = constant.S_Proto
+ serialization := tmpInvocation.AttachmentsByKey(constant.SerializationKey, constant.Hessian2Serialization)
+ if serialization == constant.ProtobufSerialization {
+ header.SerialID = constant.SProto
} else {
- header.SerialID = constant.S_Hessian2
+ header.SerialID = constant.SHessian2
}
header.ID = request.ID
if request.TwoWay {
@@ -103,7 +103,7 @@
func (c *DubboTestCodec) encodeHeartbeartReqeust(request *remoting.Request) (*bytes.Buffer, error) {
header := impl.DubboHeader{
Type: impl.PackageHeartbeat,
- SerialID: constant.S_Hessian2,
+ SerialID: constant.SHessian2,
ID: request.ID,
}
@@ -208,7 +208,7 @@
request.Version = req[impl.DubboVersionKey].(string)
}
// path
- attachments[constant.PATH_KEY] = pkg.Service.Path
+ attachments[constant.PathKey] = pkg.Service.Path
// version
attachments[constant.VersionKey] = pkg.Service.Version
// method
diff --git a/remoting/getty/getty_client.go b/remoting/getty/getty_client.go
index d6ca10d..9931194 100644
--- a/remoting/getty/getty_client.go
+++ b/remoting/getty/getty_client.go
@@ -161,7 +161,7 @@
func (c *Client) Connect(url *common.URL) error {
initClient(url.Protocol)
c.conf = *clientConf
- c.sslEnabled = url.GetParamBool(constant.SSL_ENABLED_KEY, false)
+ c.sslEnabled = url.GetParamBool(constant.SslEnabledKey, false)
// codec
c.codec = remoting.GetCodec(url.Protocol)
c.addr = url.Location
diff --git a/remoting/getty/getty_server.go b/remoting/getty/getty_server.go
index e53f0d4..d1f0a5f 100644
--- a/remoting/getty/getty_server.go
+++ b/remoting/getty/getty_server.go
@@ -117,7 +117,7 @@
// init
initServer(url.Protocol)
- srvConf.SSLEnabled = url.GetParamBool(constant.SSL_ENABLED_KEY, false)
+ srvConf.SSLEnabled = url.GetParamBool(constant.SslEnabledKey, false)
s := &Server{
conf: *srvConf,
diff --git a/remoting/getty/listener.go b/remoting/getty/listener.go
index fc9d2f4..78b0f61 100644
--- a/remoting/getty/listener.go
+++ b/remoting/getty/listener.go
@@ -300,8 +300,8 @@
panic("create invocation occur some exception for the type is not suitable one.")
}
attachments := invoc.Attachments()
- attachments[constant.LOCAL_ADDR] = session.LocalAddr()
- attachments[constant.REMOTE_ADDR] = session.RemoteAddr()
+ attachments[constant.LocalAddr] = session.LocalAddr()
+ attachments[constant.RemoteAddr] = session.RemoteAddr()
result := h.server.requestHandler(invoc)
if !req.TwoWay {
diff --git a/remoting/getty/listener_test.go b/remoting/getty/listener_test.go
index a75a4e6..d5adc48 100644
--- a/remoting/getty/listener_test.go
+++ b/remoting/getty/listener_test.go
@@ -45,7 +45,7 @@
// attachment doesn't contains any tracing key-value pair,
ctx := rebuildCtx(inv)
assert.NotNil(t, ctx)
- assert.Nil(t, ctx.Value(constant.TRACING_REMOTE_SPAN_CTX))
+ assert.Nil(t, ctx.Value(constant.TracingRemoteSpanCtx))
span, ctx := opentracing.StartSpanFromContext(ctx, "Test-Client")
assert.NotNil(t, ctx)
@@ -57,7 +57,7 @@
ctx = rebuildCtx(inv)
span.Finish()
assert.NotNil(t, ctx)
- assert.NotNil(t, ctx.Value(constant.TRACING_REMOTE_SPAN_CTX))
+ assert.NotNil(t, ctx.Value(constant.TracingRemoteSpanCtx))
}
// rebuildCtx rebuild the context by attachment.
@@ -70,7 +70,7 @@
spanCtx, err := opentracing.GlobalTracer().Extract(opentracing.TextMap,
opentracing.TextMapCarrier(filterContext(inv.Attachments())))
if err == nil {
- ctx = context.WithValue(ctx, constant.TRACING_REMOTE_SPAN_CTX, spanCtx)
+ ctx = context.WithValue(ctx, constant.TracingRemoteSpanCtx, spanCtx)
}
return ctx
}
diff --git a/remoting/getty/readwriter_test.go b/remoting/getty/readwriter_test.go
index d0c20fe..0990292 100644
--- a/remoting/getty/readwriter_test.go
+++ b/remoting/getty/readwriter_test.go
@@ -53,7 +53,7 @@
[]reflect.Value{reflect.ValueOf([]interface{}{"1", "username"}), reflect.ValueOf(ap)})
attachment := map[string]string{
constant.InterfaceKey: "com.ikurento.user.AdminProvider",
- constant.PATH_KEY: "AdminProvider",
+ constant.PathKey: "AdminProvider",
constant.VersionKey: "1.0.0",
}
setAttachment(rpcInvocation, attachment)
diff --git a/remoting/nacos/builder.go b/remoting/nacos/builder.go
index 34f63a8..ef440fb 100644
--- a/remoting/nacos/builder.go
+++ b/remoting/nacos/builder.go
@@ -72,25 +72,25 @@
serverConfigs = append(serverConfigs, nacosConstant.ServerConfig{IpAddr: ip, Port: uint64(port)})
}
- timeout := url.GetParamDuration(constant.CONFIG_TIMEOUT_KEY, constant.DEFAULT_REG_TIMEOUT)
+ timeout := url.GetParamDuration(constant.ConfigTimeoutKey, constant.DefaultRegTimeout)
clientConfig := nacosConstant.ClientConfig{
TimeoutMs: uint64(int32(timeout / time.Millisecond)),
- BeatInterval: url.GetParamInt(constant.NACOS_BEAT_INTERVAL_KEY, 5000),
- NamespaceId: url.GetParam(constant.NACOS_NAMESPACE_ID, ""),
- AppName: url.GetParam(constant.NACOS_APP_NAME_KEY, ""),
- Endpoint: url.GetParam(constant.NACOS_ENDPOINT, ""),
- RegionId: url.GetParam(constant.NACOS_REGION_ID_KEY, ""),
- AccessKey: url.GetParam(constant.NACOS_ACCESS_KEY, ""),
- SecretKey: url.GetParam(constant.NACOS_SECRET_KEY, ""),
- OpenKMS: url.GetParamBool(constant.NACOS_OPEN_KMS_KEY, false),
- CacheDir: url.GetParam(constant.NACOS_CACHE_DIR_KEY, ""),
- UpdateThreadNum: url.GetParamByIntValue(constant.NACOS_UPDATE_THREAD_NUM_KEY, 20),
- NotLoadCacheAtStart: url.GetParamBool(constant.NACOS_NOT_LOAD_LOCAL_CACHE, true),
- Username: url.GetParam(constant.NACOS_USERNAME, ""),
- Password: url.GetParam(constant.NACOS_PASSWORD, ""),
- LogDir: url.GetParam(constant.NACOS_LOG_DIR_KEY, ""),
- LogLevel: url.GetParam(constant.NACOS_LOG_LEVEL_KEY, "info"),
+ BeatInterval: url.GetParamInt(constant.NacosBeatIntervalKey, 5000),
+ NamespaceId: url.GetParam(constant.NacosNamespaceID, ""),
+ AppName: url.GetParam(constant.NacosAppNameKey, ""),
+ Endpoint: url.GetParam(constant.NacosEndpoint, ""),
+ RegionId: url.GetParam(constant.NacosRegionIDKey, ""),
+ AccessKey: url.GetParam(constant.NacosAccessKey, ""),
+ SecretKey: url.GetParam(constant.NacosSecretKey, ""),
+ OpenKMS: url.GetParamBool(constant.NacosOpenKmsKey, false),
+ CacheDir: url.GetParam(constant.NacosCacheDirKey, ""),
+ UpdateThreadNum: url.GetParamByIntValue(constant.NacosUpdateThreadNumKey, 20),
+ NotLoadCacheAtStart: url.GetParamBool(constant.NacosNotLoadLocalCache, true),
+ Username: url.GetParam(constant.NacosUsername, ""),
+ Password: url.GetParam(constant.NacosPassword, ""),
+ LogDir: url.GetParam(constant.NacosLogDirKey, ""),
+ LogLevel: url.GetParam(constant.NacosLogLevelKey, "info"),
}
return serverConfigs, clientConfig, nil
}
diff --git a/remoting/nacos/builder_test.go b/remoting/nacos/builder_test.go
index eb4c1a6..74eba4f 100644
--- a/remoting/nacos/builder_test.go
+++ b/remoting/nacos/builder_test.go
@@ -85,10 +85,10 @@
func TestTimeoutConfig(t *testing.T) {
regurlMap := url.Values{}
- regurlMap.Set(constant.NACOS_NOT_LOAD_LOCAL_CACHE, "true")
- // regurlMap.Set(constant.NACOS_USERNAME, "nacos")
- // regurlMap.Set(constant.NACOS_PASSWORD, "nacos")
- regurlMap.Set(constant.NACOS_NAMESPACE_ID, "nacos")
+ regurlMap.Set(constant.NacosNotLoadLocalCache, "true")
+ // regurlMap.Set(constant.NacosUsername, "nacos")
+ // regurlMap.Set(constant.NacosPassword, "nacos")
+ regurlMap.Set(constant.NacosNamespaceID, "nacos")
t.Run("default timeout", func(t *testing.T) {
newURL, _ := common.NewURL("registry://console.nacos.io:80", common.WithParams(regurlMap))
@@ -101,7 +101,7 @@
t.Run("right timeout", func(t *testing.T) {
- regurlMap.Set(constant.CONFIG_TIMEOUT_KEY, "5s")
+ regurlMap.Set(constant.ConfigTimeoutKey, "5s")
newURL, _ := common.NewURL("registry://console.nacos.io:80", common.WithParams(regurlMap))
@@ -112,7 +112,7 @@
})
t.Run("invalid timeout", func(t *testing.T) {
- regurlMap.Set(constant.CONFIG_TIMEOUT_KEY, "5ab")
+ regurlMap.Set(constant.ConfigTimeoutKey, "5ab")
newURL, _ := common.NewURL("registry://console.nacos.io:80", common.WithParams(regurlMap))
_, cc, err := GetNacosConfig(newURL)
@@ -126,11 +126,11 @@
func getRegUrl() *common.URL {
regurlMap := url.Values{}
- regurlMap.Set(constant.NACOS_NOT_LOAD_LOCAL_CACHE, "true")
- // regurlMap.Set(constant.NACOS_USERNAME, "nacos")
- // regurlMap.Set(constant.NACOS_PASSWORD, "nacos")
- regurlMap.Set(constant.NACOS_NAMESPACE_ID, "nacos")
- regurlMap.Set(constant.CONFIG_TIMEOUT_KEY, "5s")
+ regurlMap.Set(constant.NacosNotLoadLocalCache, "true")
+ // regurlMap.Set(constant.NacosUsername, "nacos")
+ // regurlMap.Set(constant.NacosPassword, "nacos")
+ regurlMap.Set(constant.NacosNamespaceID, "nacos")
+ regurlMap.Set(constant.ConfigTimeoutKey, "5s")
regurl, _ := common.NewURL("registry://console.nacos.io:80", common.WithParams(regurlMap))
diff --git a/remoting/zookeeper/client.go b/remoting/zookeeper/client.go
index cf0b572..9c639d6 100644
--- a/remoting/zookeeper/client.go
+++ b/remoting/zookeeper/client.go
@@ -55,7 +55,7 @@
if container.ZkClient() == nil {
// in dubbo, every registry only connect one node, so this is []string{r.Address}
- timeout := url.GetParamDuration(constant.CONFIG_TIMEOUT_KEY, constant.DEFAULT_REG_TIMEOUT)
+ timeout := url.GetParamDuration(constant.ConfigTimeoutKey, constant.DefaultRegTimeout)
zkAddresses := strings.Split(url.Location, ",")
newClient, cltErr := gxzookeeper.NewZookeeperClient(zkName, zkAddresses, true, gxzookeeper.WithZkTimeOut(timeout))
diff --git a/remoting/zookeeper/curator_discovery/service_discovery.go b/remoting/zookeeper/curator_discovery/service_discovery.go
index efa0a40..582a2e2 100644
--- a/remoting/zookeeper/curator_discovery/service_discovery.go
+++ b/remoting/zookeeper/curator_discovery/service_discovery.go
@@ -259,8 +259,8 @@
// getNameAndID get service name and instance id by path
func (sd *ServiceDiscovery) getNameAndID(path string) (string, string, error) {
path = strings.TrimPrefix(path, sd.basePath)
- path = strings.TrimPrefix(path, constant.PATH_SEPARATOR)
- pathSlice := strings.Split(path, constant.PATH_SEPARATOR)
+ path = strings.TrimPrefix(path, constant.PathSeparator)
+ pathSlice := strings.Split(path, constant.PathSeparator)
if len(pathSlice) < 2 {
return "", "", perrors.Errorf("[ServiceDiscovery] path{%s} dont contain name and id", path)
}
diff --git a/remoting/zookeeper/listener.go b/remoting/zookeeper/listener.go
index 34d6c13..8bfe743 100644
--- a/remoting/zookeeper/listener.go
+++ b/remoting/zookeeper/listener.go
@@ -213,19 +213,18 @@
}
}
-func (l *ZkEventListener) listenDirEvent(conf *common.URL, zkPath string, listener remoting.DataListener) {
+func (l *ZkEventListener) listenDirEvent(conf *common.URL, zkRootPath string, listener remoting.DataListener) {
defer l.wg.Done()
var (
failTimes int
ttl time.Duration
event chan struct{}
- zkEvent zk.Event
)
event = make(chan struct{}, 4)
ttl = defaultTTL
if conf != nil {
- timeout, err := time.ParseDuration(conf.GetParam(constant.REGISTRY_TTL_KEY, constant.DEFAULT_REG_TTL))
+ timeout, err := time.ParseDuration(conf.GetParam(constant.RegistryTTLKey, constant.DefaultRegTTL))
if err == nil {
ttl = timeout
} else {
@@ -235,13 +234,13 @@
defer close(event)
for {
// get current children for a zkPath
- children, childEventCh, err := l.client.GetChildrenW(zkPath)
+ children, childEventCh, err := l.client.GetChildrenW(zkRootPath)
if err != nil {
failTimes++
if MaxFailTimes <= failTimes {
failTimes = MaxFailTimes
}
- logger.Debugf("listenDirEvent(path{%s}) = error{%v}", zkPath, err)
+ logger.Debugf("listenDirEvent(path{%s}) = error{%v}", zkRootPath, err)
// clear the event channel
CLEAR:
for {
@@ -251,34 +250,33 @@
break CLEAR
}
}
- l.client.RegisterEvent(zkPath, &event)
+ l.client.RegisterEvent(zkRootPath, &event)
if err == errNilNode {
- logger.Warnf("listenDirEvent(path{%s}) got errNilNode,so exit listen", zkPath)
- l.client.UnregisterEvent(zkPath, &event)
+ logger.Warnf("listenDirEvent(path{%s}) got errNilNode,so exit listen", zkRootPath)
+ l.client.UnregisterEvent(zkRootPath, &event)
return
}
after := time.After(timeSecondDuration(failTimes * ConnDelay))
select {
case <-after:
- l.client.UnregisterEvent(zkPath, &event)
+ l.client.UnregisterEvent(zkRootPath, &event)
continue
case <-l.exit:
- l.client.UnregisterEvent(zkPath, &event)
- logger.Debugf("listen(path{%s}) goroutine exit now...", zkPath)
+ l.client.UnregisterEvent(zkRootPath, &event)
+ logger.Debugf("listen(path{%s}) goroutine exit now...", zkRootPath)
return
case <-event:
logger.Debugf("get zk.EventNodeDataChange notify event")
- l.client.UnregisterEvent(zkPath, &event)
- l.handleZkNodeEvent(zkPath, nil, listener)
+ l.client.UnregisterEvent(zkRootPath, &event)
+ l.handleZkNodeEvent(zkRootPath, nil, listener)
continue
}
}
failTimes = 0
for _, c := range children {
-
// Only need to compare Path when subscribing to provider
- if strings.LastIndex(zkPath, constant.PROVIDER_CATEGORY) != -1 {
+ if strings.LastIndex(zkRootPath, constant.ProviderCategory) != -1 {
provider, _ := common.NewURL(c)
if provider.ServiceKey() != conf.ServiceKey() {
continue
@@ -286,17 +284,17 @@
}
// listen l service node
- dubboPath := path.Join(zkPath, c)
+ zkNodePath := path.Join(zkRootPath, c)
// Save the path to avoid listen repeatedly
l.pathMapLock.Lock()
- _, ok := l.pathMap[dubboPath]
+ _, ok := l.pathMap[zkNodePath]
if !ok {
- l.pathMap[dubboPath] = uatomic.NewInt32(0)
+ l.pathMap[zkNodePath] = uatomic.NewInt32(0)
}
l.pathMapLock.Unlock()
if ok {
- logger.Warnf("@zkPath %s has already been listened.", dubboPath)
+ logger.Warnf("@zkPath %s has already been listened.", zkNodePath)
continue
}
@@ -306,16 +304,17 @@
l.client.RUnlock()
break
}
- content, _, err := l.client.Conn.Get(dubboPath)
+ content, _, err := l.client.Conn.Get(zkNodePath)
+
l.client.RUnlock()
if err != nil {
- logger.Errorf("Get new node path {%v} 's content error,message is {%v}", dubboPath, perrors.WithStack(err))
+ logger.Errorf("Get new node path {%v} 's content error,message is {%v}", zkNodePath, perrors.WithStack(err))
}
- logger.Debugf("Get children!{%s}", dubboPath)
- if !listener.DataChange(remoting.Event{Path: dubboPath, Action: remoting.EventTypeAdd, Content: string(content)}) {
+ logger.Debugf("Get children!{%s}", zkNodePath)
+ if !listener.DataChange(remoting.Event{Path: zkNodePath, Action: remoting.EventTypeAdd, Content: string(content)}) {
continue
}
- logger.Infof("listen dubbo service key{%s}", dubboPath)
+ logger.Infof("listen dubbo service key{%s}", zkNodePath)
l.wg.Add(1)
go func(zkPath string, listener remoting.DataListener) {
// invoker l.wg.Done() in l.listenServiceNodeEvent
@@ -326,54 +325,59 @@
l.pathMapLock.Unlock()
}
logger.Warnf("listenDirEvent->listenSelf(zk path{%s}) goroutine exit now", zkPath)
- }(dubboPath, listener)
+ }(zkNodePath, listener)
// listen sub path recursive
// if zkPath is end of "providers/ & consumers/" we do not listen children dir
- if strings.LastIndex(zkPath, constant.PROVIDER_CATEGORY) == -1 &&
- strings.LastIndex(zkPath, constant.CONSUMER_CATEGORY) == -1 {
+ if strings.LastIndex(zkRootPath, constant.ProviderCategory) == -1 &&
+ strings.LastIndex(zkRootPath, constant.ConsumerCategory) == -1 {
l.wg.Add(1)
go func(zkPath string, listener remoting.DataListener) {
l.listenDirEvent(conf, zkPath, listener)
logger.Warnf("listenDirEvent(zkPath{%s}) goroutine exit now", zkPath)
- }(dubboPath, listener)
+ }(zkNodePath, listener)
}
}
- // Periodically update provider information
- tickerTTL := ttl
- if tickerTTL > 20e9 {
- tickerTTL = 20e9
+ if l.startScheduleWatchTask(zkRootPath, children, ttl, listener, childEventCh) {
+ return
}
- ticker := time.NewTicker(tickerTTL)
- WATCH:
- for {
- select {
- case <-ticker.C:
- l.handleZkNodeEvent(zkPath, children, listener)
- if tickerTTL < ttl {
- tickerTTL *= 2
- if tickerTTL > ttl {
- tickerTTL = ttl
- }
- ticker.Stop()
- ticker = time.NewTicker(tickerTTL)
- }
- case zkEvent = <-childEventCh:
- logger.Warnf("get a zookeeper childEventCh{type:%s, server:%s, path:%s, state:%d-%s, err:%v}",
- zkEvent.Type.String(), zkEvent.Server, zkEvent.Path, zkEvent.State, gxzookeeper.StateToString(zkEvent.State), zkEvent.Err)
- ticker.Stop()
- if zkEvent.Type != zk.EventNodeChildrenChanged {
- break WATCH
- }
- l.handleZkNodeEvent(zkEvent.Path, children, listener)
- break WATCH
- case <-l.exit:
- logger.Warnf("listen(path{%s}) goroutine exit now...", zkPath)
- ticker.Stop()
- return
- }
- }
+ }
+}
+func (l *ZkEventListener) startScheduleWatchTask(
+ zkRootPath string, children []string, ttl time.Duration,
+ listener remoting.DataListener, childEventCh <-chan zk.Event) bool {
+ // Periodically update provider information
+ tickerTTL := ttl
+ if tickerTTL > 20e9 {
+ tickerTTL = 20e9
+ }
+ ticker := time.NewTicker(tickerTTL)
+ for {
+ select {
+ case <-ticker.C:
+ l.handleZkNodeEvent(zkRootPath, children, listener)
+ if tickerTTL < ttl {
+ tickerTTL *= 2
+ if tickerTTL > ttl {
+ tickerTTL = ttl
+ }
+ ticker.Stop()
+ ticker = time.NewTicker(tickerTTL)
+ }
+ case zkEvent := <-childEventCh:
+ logger.Warnf("get a zookeeper childEventCh{type:%s, server:%s, path:%s, state:%d-%s, err:%v}",
+ zkEvent.Type.String(), zkEvent.Server, zkEvent.Path, zkEvent.State, gxzookeeper.StateToString(zkEvent.State), zkEvent.Err)
+ ticker.Stop()
+ if zkEvent.Type == zk.EventNodeChildrenChanged {
+ l.handleZkNodeEvent(zkEvent.Path, children, listener)
+ }
+ return false
+ case <-l.exit:
+ logger.Warnf("listen(path{%s}) goroutine exit now...", zkRootPath)
+ ticker.Stop()
+ return true
+ }
}
}