Merge branch '3.0' into Ftr/proxy-service
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..457b84d
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "samples"]
+ path = samples
+ url = git@github.com:apache/dubbo-go-samples.git
diff --git a/CHANGE.md b/CHANGE.md
index 28ffeb8..a983451 100644
--- a/CHANGE.md
+++ b/CHANGE.md
@@ -6,12 +6,17 @@
- [Add dubbo-go-cli telnet tool](https://github.com/apache/dubbo-go/pull/818)
- [Add Prox ImplementFunc to allow override impl](https://github.com/apache/dubbo-go/pull/1019)
- [Add read configuration path from the command line when start](https://github.com/apache/dubbo-go/pull/1039)
+- [Add use invoker with same ip as client first](https://github.com/apache/dubbo-go/pull/1023)
+- [Add an "api way" to set general configure](https://github.com/apache/dubbo-go/pull/1020)
+- [Add registry ip:port set from enviroment variable](https://github.com/apache/dubbo-go/pull/1036)
### Enhancement
- [introduce ConfigPostProcessor extension](https://github.com/apache/dubbo-go/pull/943)
- [Impl extension of two urls comparison](https://github.com/apache/dubbo-go/pull/854)
- [using event-driven to let router send signal to notify channel](https://github.com/apache/dubbo-go/pull/976)
- [lint codes](https://github.com/apache/dubbo-go/pull/941)
+- [Imp: destroy invoker smoothly](https://github.com/apache/dubbo-go/pull/1045)
+- [Improve config center](https://github.com/apache/dubbo-go/pull/1030)
### Bugfixes
- [Fix: generic struct2MapAll key of map keep type](https://github.com/apache/dubbo-go/pull/928)
@@ -23,8 +28,21 @@
- [Fix: etcd exit panic](https://github.com/apache/dubbo-go/pull/1013)
- [Fix: when connect to provider fail, will occur panic](https://github.com/apache/dubbo-go/pull/1021)
- [Fix: support getty send Length, when the data transfer failed](https://github.com/apache/dubbo-go/pull/1028)
+- [Fix: RPCInvocation.ServiceKey use PATH_KEY instead of INTERFACE_KEY ](https://github.com/apache/dubbo-go/pull/1078/files)
+- [Fix: zk too many tcp conn](https://github.com/apache/dubbo-go/pull/1010)
+- [Fix: fix zk listener func pathToKey](https://github.com/apache/dubbo-go/pull/1066)
+- [Fix: graceful shutdown](https://github.com/apache/dubbo-go/pull/1007)
+- [Fix: nacos service provider does not require subscribe](https://github.com/apache/dubbo-go/pull/1056)
+- [Fix: key of generic map convert is more general](https://github.com/apache/dubbo-go/pull/1041)
+- [Fix: body buffer too short](https://github.com/apache/dubbo-go/pull/1090)
-Milestone: [https://github.com/apache/dubbo-go/milestone/7](https://github.com/apache/dubbo-go/milestone/7?closed=1)
+### Dependencies
+- [Bump dubbo-go-hessian2 from v1.9.0-rc1 to v1.9.1](https://github.com/apache/dubbo-go/pull/1088/files)
+- [Bump github.com/nacos-group/nacos-sdk-go from 1.0.5 to v1.0.7](https://github.com/apache/dubbo-go/pull/1106)
+
+Milestone:
+- [https://github.com/apache/dubbo-go/milestone/7](https://github.com/apache/dubbo-go/milestone/7?closed=1)
+- [https://github.com/apache/dubbo-go/milestone/10](https://github.com/apache/dubbo-go/milestone/10?closed=1)
## 1.5.5
diff --git a/README.md b/README.md
index 01cbb8c..7460d8e 100644
--- a/README.md
+++ b/README.md
@@ -73,6 +73,7 @@
- Router
* [Condition router](https://github.com/apache/dubbo-go/pull/294)
* [Health check router](https://github.com/apache/dubbo-go/pull/389)
+ * [Dynamic_tag_router](https://github.com/apache/dubbo-go/pull/703)
- Registry
* ZooKeeper
@@ -134,6 +135,10 @@
* [Nacos](https://github.com/apache/dubbo-go/blob/9a5990d9a9c3d5e6633c0d7d926c156416bcb931/registry/nacos/service_discovery.go)
* [Zookeeper](https://github.com/apache/dubbo-go/blob/9a5990d9a9c3d5e6633c0d7d926c156416bcb931/registry/zookeeper/service_discovery.go)
* [Etcd](https://github.com/apache/dubbo-go/blob/9a5990d9a9c3d5e6633c0d7d926c156416bcb931/registry/etcdv3/service_discovery.go)
+ * [File](https://github.com/apache/dubbo-go/pull/732)
+
+- Tool
+ * [Dubbo-go-cli](https://github.com/apache/dubbo-go/pull/818)
You can know more about dubbo-go by its [roadmap](https://github.com/apache/dubbo-go/wiki/Roadmap).
diff --git a/README_CN.md b/README_CN.md
index 92df996..060b5de 100644
--- a/README_CN.md
+++ b/README_CN.md
@@ -72,6 +72,7 @@
- 路由器
* [Condition router](https://github.com/apache/dubbo-go/pull/294)
* [Health check router](https://github.com/apache/dubbo-go/pull/389)
+ * [Dynamic_tag_router](https://github.com/apache/dubbo-go/pull/703)
- 注册中心
* ZooKeeper
@@ -133,6 +134,10 @@
* [Nacos](https://github.com/apache/dubbo-go/blob/9a5990d9a9c3d5e6633c0d7d926c156416bcb931/registry/nacos/service_discovery.go)
* [Zookeeper](https://github.com/apache/dubbo-go/blob/9a5990d9a9c3d5e6633c0d7d926c156416bcb931/registry/zookeeper/service_discovery.go)
* [Etcd](https://github.com/apache/dubbo-go/blob/9a5990d9a9c3d5e6633c0d7d926c156416bcb931/registry/etcdv3/service_discovery.go)
+ * [File](https://github.com/apache/dubbo-go/pull/732)
+
+- 工具箱
+ * [Dubbo-go-cli](https://github.com/apache/dubbo-go/pull/818)
你可以通过访问 [roadmap](https://github.com/apache/dubbo-go/wiki/Roadmap) 知道更多关于 dubbo-go 的信息。
@@ -194,7 +199,22 @@
</table>
</div>
-如果想加入到社区微信群,可以先添加社区负责人 于雨 的微信 AlexanderStocks 。添加微信之前,请先给 dubbo-go 点 star 作为对项目的支持,添加好友时请报上 github ID 以进行验证。
+dubbogo 社区已经开通微信公众号 "dubbogo大区",可在微信搜索 "dubbogo大区" 或者扫描如下二维码关注,可通过公众号私信留言加入 dubbogo 微信社区。
+
+<div>
+<table>
+ <tbody>
+ <tr></tr>
+ <tr>
+ <td align="center" valign="middle">
+ <img width="80px" height="115px" src="./doc/pic/misc/dubbogo-wechat.png">
+ </a>
+ </td>
+ </tr>
+ <tr></tr>
+ </tbody>
+</table>
+</div>
作为一个维护已经帮助构建了经受多家大型微服务系统的社区,我们足以为现有的成绩感到自豪。社区欢迎能提出建设性意见者,只知索取者和喷子请绕行。
diff --git a/cluster/cluster_impl/available_cluster_invoker_test.go b/cluster/cluster_impl/available_cluster_invoker_test.go
index 0631000..948f207 100644
--- a/cluster/cluster_impl/available_cluster_invoker_test.go
+++ b/cluster/cluster_impl/available_cluster_invoker_test.go
@@ -40,10 +40,8 @@
"github.com/apache/dubbo-go/protocol/mock"
)
-var (
- availableUrl, _ = common.NewURL(fmt.Sprintf("dubbo://%s:%d/com.ikurento.user.UserProvider",
- constant.LOCAL_HOST_VALUE, constant.DEFAULT_PORT))
-)
+var availableUrl, _ = common.NewURL(fmt.Sprintf("dubbo://%s:%d/com.ikurento.user.UserProvider",
+ constant.LOCAL_HOST_VALUE, constant.DEFAULT_PORT))
func registerAvailable(invoker *mock.MockInvoker) protocol.Invoker {
extension.SetLoadbalance("random", loadbalance.NewRandomLoadBalance)
diff --git a/cluster/cluster_impl/base_cluster_invoker.go b/cluster/cluster_impl/base_cluster_invoker.go
index 0d39bff..2df5f36 100644
--- a/cluster/cluster_impl/base_cluster_invoker.go
+++ b/cluster/cluster_impl/base_cluster_invoker.go
@@ -56,7 +56,7 @@
}
func (invoker *baseClusterInvoker) Destroy() {
- //this is must atom operation
+ // this is must atom operation
if invoker.destroyed.CAS(false, true) {
invoker.directory.Destroy()
}
@@ -69,7 +69,7 @@
return invoker.directory.IsAvailable()
}
-//check invokers availables
+// check invokers availables
func (invoker *baseClusterInvoker) checkInvokers(invokers []protocol.Invoker, invocation protocol.Invocation) error {
if len(invokers) == 0 {
ip := common.GetLocalIp()
@@ -78,10 +78,9 @@
invocation.MethodName(), invoker.directory.GetUrl().SubURL.Key(), invoker.directory.GetUrl().String(), ip, constant.Version)
}
return nil
-
}
-//check cluster invoker is destroyed or not
+// check cluster invoker is destroyed or not
func (invoker *baseClusterInvoker) checkWhetherDestroyed() error {
if invoker.destroyed.Load() {
ip := common.GetLocalIp()
@@ -99,7 +98,7 @@
url := invokers[0].GetUrl()
sticky := url.GetParamBool(constant.STICKY_KEY, false)
- //Get the service method sticky config if have
+ // Get the service method sticky config if have
sticky = url.GetMethodParamBool(invocation.MethodName(), constant.STICKY_KEY, sticky)
if invoker.stickyInvoker != nil && !isInvoked(invoker.stickyInvoker, invokers) {
@@ -135,7 +134,7 @@
selectedInvoker := lb.Select(invokers, invocation)
- //judge if the selected Invoker is invoked and available
+ // judge if the selected Invoker is invoked and available
if (!selectedInvoker.IsAvailable() && invoker.availablecheck) || isInvoked(selectedInvoker, invoked) {
protocol.SetInvokerUnhealthyStatus(selectedInvoker)
otherInvokers := getOtherInvokers(invokers, selectedInvoker)
@@ -193,10 +192,10 @@
url := invoker.GetUrl()
methodName := invocation.MethodName()
- //Get the service loadbalance config
+ // Get the service loadbalance config
lb := url.GetParam(constant.LOADBALANCE_KEY, constant.DEFAULT_LOADBALANCE)
- //Get the service method loadbalance config if have
+ // Get the service method loadbalance config if have
if v := url.GetMethodParam(methodName, constant.LOADBALANCE_KEY, ""); len(v) > 0 {
lb = v
}
diff --git a/cluster/cluster_impl/broadcast_cluster_invoker.go b/cluster/cluster_impl/broadcast_cluster_invoker.go
index b117dbb..52ae65c 100644
--- a/cluster/cluster_impl/broadcast_cluster_invoker.go
+++ b/cluster/cluster_impl/broadcast_cluster_invoker.go
@@ -20,6 +20,7 @@
import (
"context"
)
+
import (
"github.com/apache/dubbo-go/cluster"
"github.com/apache/dubbo-go/common/logger"
diff --git a/cluster/cluster_impl/broadcast_cluster_invoker_test.go b/cluster/cluster_impl/broadcast_cluster_invoker_test.go
index 08d0002..a654fb7 100644
--- a/cluster/cluster_impl/broadcast_cluster_invoker_test.go
+++ b/cluster/cluster_impl/broadcast_cluster_invoker_test.go
@@ -40,10 +40,8 @@
"github.com/apache/dubbo-go/protocol/mock"
)
-var (
- broadcastUrl, _ = common.NewURL(
- fmt.Sprintf("dubbo://%s:%d/com.ikurento.user.UserProvider", constant.LOCAL_HOST_VALUE, constant.DEFAULT_PORT))
-)
+var broadcastUrl, _ = common.NewURL(
+ fmt.Sprintf("dubbo://%s:%d/com.ikurento.user.UserProvider", constant.LOCAL_HOST_VALUE, constant.DEFAULT_PORT))
func registerBroadcast(mockInvokers ...*mock.MockInvoker) protocol.Invoker {
extension.SetLoadbalance("random", loadbalance.NewRandomLoadBalance)
diff --git a/cluster/cluster_impl/failback_cluster_invoker.go b/cluster/cluster_impl/failback_cluster_invoker.go
index 5e0d133..2ed1bae 100644
--- a/cluster/cluster_impl/failback_cluster_invoker.go
+++ b/cluster/cluster_impl/failback_cluster_invoker.go
@@ -137,10 +137,10 @@
return &protocol.RPCResult{}
}
- //Get the service loadbalance config
+ // Get the service loadbalance config
url := invokers[0].GetUrl()
lb := url.GetParam(constant.LOADBALANCE_KEY, constant.DEFAULT_LOADBALANCE)
- //Get the service method loadbalance config if have
+ // Get the service method loadbalance config if have
methodName := invocation.MethodName()
if v := url.GetMethodParam(methodName, constant.LOADBALANCE_KEY, ""); v != "" {
lb = v
@@ -149,7 +149,7 @@
loadBalance := extension.GetLoadbalance(lb)
invoked := make([]protocol.Invoker, 0, len(invokers))
ivk := invoker.doSelect(loadBalance, invocation, invokers, invoked)
- //DO INVOKE
+ // DO INVOKE
result := ivk.Invoke(ctx, invocation)
if result.Error() != nil {
invoker.once.Do(func() {
diff --git a/cluster/cluster_impl/failback_cluster_test.go b/cluster/cluster_impl/failback_cluster_test.go
index d36e16e..8fbd24f 100644
--- a/cluster/cluster_impl/failback_cluster_test.go
+++ b/cluster/cluster_impl/failback_cluster_test.go
@@ -42,10 +42,8 @@
"github.com/apache/dubbo-go/protocol/mock"
)
-var (
- failbackUrl, _ = common.NewURL(
- fmt.Sprintf("dubbo://%s:%d/com.ikurento.user.UserProvider", constant.LOCAL_HOST_VALUE, constant.DEFAULT_PORT))
-)
+var failbackUrl, _ = common.NewURL(
+ fmt.Sprintf("dubbo://%s:%d/com.ikurento.user.UserProvider", constant.LOCAL_HOST_VALUE, constant.DEFAULT_PORT))
// registerFailback register failbackCluster to cluster extension.
func registerFailback(invoker *mock.MockInvoker) protocol.Invoker {
diff --git a/cluster/cluster_impl/failfast_cluster_invoker.go b/cluster/cluster_impl/failfast_cluster_invoker.go
index d71ef5f..a7faa1b 100644
--- a/cluster/cluster_impl/failfast_cluster_invoker.go
+++ b/cluster/cluster_impl/failfast_cluster_invoker.go
@@ -20,6 +20,7 @@
import (
"context"
)
+
import (
"github.com/apache/dubbo-go/cluster"
"github.com/apache/dubbo-go/protocol"
diff --git a/cluster/cluster_impl/failfast_cluster_test.go b/cluster/cluster_impl/failfast_cluster_test.go
index 9ac06b8..6577c99 100644
--- a/cluster/cluster_impl/failfast_cluster_test.go
+++ b/cluster/cluster_impl/failfast_cluster_test.go
@@ -40,10 +40,8 @@
"github.com/apache/dubbo-go/protocol/mock"
)
-var (
- failfastUrl, _ = common.NewURL(
- fmt.Sprintf("dubbo://%s:%d/com.ikurento.user.UserProvider", constant.LOCAL_HOST_VALUE, constant.DEFAULT_PORT))
-)
+var failfastUrl, _ = common.NewURL(
+ fmt.Sprintf("dubbo://%s:%d/com.ikurento.user.UserProvider", constant.LOCAL_HOST_VALUE, constant.DEFAULT_PORT))
// registerFailfast register failfastCluster to cluster extension.
func registerFailfast(invoker *mock.MockInvoker) protocol.Invoker {
diff --git a/cluster/cluster_impl/failover_cluster_invoker.go b/cluster/cluster_impl/failover_cluster_invoker.go
index ca490e7..3d070c1 100644
--- a/cluster/cluster_impl/failover_cluster_invoker.go
+++ b/cluster/cluster_impl/failover_cluster_invoker.go
@@ -64,8 +64,8 @@
loadBalance := getLoadBalance(invokers[0], invocation)
for i := 0; i <= retries; i++ {
- //Reselect before retry to avoid a change of candidate `invokers`.
- //NOTE: if `invokers` changed, then `invoked` also lose accuracy.
+ // Reselect before retry to avoid a change of candidate `invokers`.
+ // NOTE: if `invokers` changed, then `invoked` also lose accuracy.
if i > 0 {
if err := invoker.checkWhetherDestroyed(); err != nil {
return &protocol.RPCResult{Err: err}
@@ -81,7 +81,7 @@
continue
}
invoked = append(invoked, ivk)
- //DO INVOKE
+ // DO INVOKE
result = ivk.Invoke(ctx, invocation)
if result.Error() != nil {
providers = append(providers, ivk.GetUrl().Key())
@@ -105,7 +105,8 @@
"Tried %v times of the providers %v (%v/%v)from the registry %v on the consumer %v using the dubbo version %v. "+
"Last error is %+v.", methodName, invokerSvc, retries, providers, len(providers), len(invokers),
invokerUrl, ip, constant.Version, result.Error().Error()),
- )}
+ ),
+ }
}
func getRetries(invokers []protocol.Invoker, methodName string) int {
@@ -114,9 +115,9 @@
}
url := invokers[0].GetUrl()
- //get reties
+ // get reties
retriesConfig := url.GetParam(constant.RETRIES_KEY, constant.DEFAULT_RETRIES)
- //Get the service method loadbalance config if have
+ // Get the service method loadbalance config if have
if v := url.GetMethodParam(methodName, constant.RETRIES_KEY, ""); len(v) != 0 {
retriesConfig = v
}
diff --git a/cluster/cluster_impl/failover_cluster_test.go b/cluster/cluster_impl/failover_cluster_test.go
index 3ea6232..dd43e0f 100644
--- a/cluster/cluster_impl/failover_cluster_test.go
+++ b/cluster/cluster_impl/failover_cluster_test.go
@@ -23,6 +23,7 @@
"net/url"
"testing"
)
+
import (
perrors "github.com/pkg/errors"
"github.com/stretchr/testify/assert"
diff --git a/cluster/cluster_impl/failsafe_cluster_invoker.go b/cluster/cluster_impl/failsafe_cluster_invoker.go
index 27c59ff..29d8884 100644
--- a/cluster/cluster_impl/failsafe_cluster_invoker.go
+++ b/cluster/cluster_impl/failsafe_cluster_invoker.go
@@ -20,6 +20,7 @@
import (
"context"
)
+
import (
"github.com/apache/dubbo-go/cluster"
"github.com/apache/dubbo-go/common/constant"
@@ -56,9 +57,9 @@
url := invokers[0].GetUrl()
methodName := invocation.MethodName()
- //Get the service loadbalance config
+ // Get the service loadbalance config
lb := url.GetParam(constant.LOADBALANCE_KEY, constant.DEFAULT_LOADBALANCE)
- //Get the service method loadbalance config if have
+ // Get the service method loadbalance config if have
if v := url.GetMethodParam(methodName, constant.LOADBALANCE_KEY, ""); v != "" {
lb = v
}
@@ -68,7 +69,7 @@
var result protocol.Result
ivk := invoker.doSelect(loadbalance, invocation, invokers, invoked)
- //DO INVOKE
+ // DO INVOKE
result = ivk.Invoke(ctx, invocation)
if result.Error() != nil {
// ignore
diff --git a/cluster/cluster_impl/failsafe_cluster_test.go b/cluster/cluster_impl/failsafe_cluster_test.go
index 5e208bd..95e1145 100644
--- a/cluster/cluster_impl/failsafe_cluster_test.go
+++ b/cluster/cluster_impl/failsafe_cluster_test.go
@@ -40,10 +40,8 @@
"github.com/apache/dubbo-go/protocol/mock"
)
-var (
- failsafeUrl, _ = common.NewURL(
- fmt.Sprintf("dubbo://%s:%d/com.ikurento.user.UserProvider", constant.LOCAL_HOST_VALUE, constant.DEFAULT_PORT))
-)
+var failsafeUrl, _ = common.NewURL(
+ fmt.Sprintf("dubbo://%s:%d/com.ikurento.user.UserProvider", constant.LOCAL_HOST_VALUE, constant.DEFAULT_PORT))
// registerFailsafe register failsafeCluster to cluster extension.
func registerFailsafe(invoker *mock.MockInvoker) protocol.Invoker {
diff --git a/cluster/cluster_impl/forking_cluster_test.go b/cluster/cluster_impl/forking_cluster_test.go
index a2fa136..6549be5 100644
--- a/cluster/cluster_impl/forking_cluster_test.go
+++ b/cluster/cluster_impl/forking_cluster_test.go
@@ -42,10 +42,8 @@
"github.com/apache/dubbo-go/protocol/mock"
)
-var (
- forkingUrl, _ = common.NewURL(
- fmt.Sprintf("dubbo://%s:%d/com.ikurento.user.UserProvider", constant.LOCAL_HOST_VALUE, constant.DEFAULT_PORT))
-)
+var forkingUrl, _ = common.NewURL(
+ fmt.Sprintf("dubbo://%s:%d/com.ikurento.user.UserProvider", constant.LOCAL_HOST_VALUE, constant.DEFAULT_PORT))
func registerForking(mockInvokers ...*mock.MockInvoker) protocol.Invoker {
extension.SetLoadbalance(loadbalance.RoundRobin, loadbalance.NewRoundRobinLoadBalance)
@@ -72,7 +70,7 @@
mockResult := &protocol.RPCResult{Rest: rest{tried: 0, success: true}}
forkingUrl.AddParam(constant.FORKS_KEY, strconv.Itoa(3))
- //forkingUrl.AddParam(constant.TIMEOUT_KEY, strconv.Itoa(constant.DEFAULT_TIMEOUT))
+ // forkingUrl.AddParam(constant.TIMEOUT_KEY, strconv.Itoa(constant.DEFAULT_TIMEOUT))
var wg sync.WaitGroup
wg.Add(2)
diff --git a/cluster/cluster_impl/zone_aware_cluster_invoker.go b/cluster/cluster_impl/zone_aware_cluster_invoker.go
index 050f831..9834d87 100644
--- a/cluster/cluster_impl/zone_aware_cluster_invoker.go
+++ b/cluster/cluster_impl/zone_aware_cluster_invoker.go
@@ -125,7 +125,6 @@
}
func (invoker *zoneAwareClusterInvoker) AfterInvoker(ctx context.Context, invocation protocol.Invocation) {
-
}
func matchParam(target, key, def string, invoker protocol.Invoker) bool {
diff --git a/cluster/cluster_impl/zone_aware_cluster_invoker_test.go b/cluster/cluster_impl/zone_aware_cluster_invoker_test.go
index 7f77f33..d681745 100644
--- a/cluster/cluster_impl/zone_aware_cluster_invoker_test.go
+++ b/cluster/cluster_impl/zone_aware_cluster_invoker_test.go
@@ -41,11 +41,12 @@
ctrl := gomock.NewController(t)
// In Go versions 1.14+, if you pass a *testing.T
// into gomock.NewController(t) you no longer need to call ctrl.Finish().
- //defer ctrl.Finish()
+ // defer ctrl.Finish()
mockResult := &protocol.RPCResult{
Attrs: map[string]interface{}{constant.PREFERRED_KEY: "true"},
- Rest: rest{tried: 0, success: true}}
+ Rest: rest{tried: 0, success: true},
+ }
var invokers []protocol.Invoker
for i := 0; i < 2; i++ {
@@ -82,7 +83,7 @@
ctrl := gomock.NewController(t)
// In Go versions 1.14+, if you pass a *testing.T
// into gomock.NewController(t) you no longer need to call ctrl.Finish().
- //defer ctrl.Finish()
+ // defer ctrl.Finish()
w1 := "50"
w2 := "200"
@@ -100,7 +101,8 @@
func(invocation protocol.Invocation) protocol.Result {
return &protocol.RPCResult{
Attrs: map[string]interface{}{constant.WEIGHT_KEY: w1},
- Rest: rest{tried: 0, success: true}}
+ Rest: rest{tried: 0, success: true},
+ }
}).MaxTimes(100)
} else {
url.SetParam(constant.REGISTRY_KEY+"."+constant.WEIGHT_KEY, w2)
@@ -108,7 +110,8 @@
func(invocation protocol.Invocation) protocol.Result {
return &protocol.RPCResult{
Attrs: map[string]interface{}{constant.WEIGHT_KEY: w2},
- Rest: rest{tried: 0, success: true}}
+ Rest: rest{tried: 0, success: true},
+ }
}).MaxTimes(100)
}
invokers = append(invokers, invoker)
@@ -135,12 +138,12 @@
}
func TestZoneWareInvokerWithZoneSuccess(t *testing.T) {
- var zoneArray = []string{"hangzhou", "shanghai"}
+ zoneArray := []string{"hangzhou", "shanghai"}
ctrl := gomock.NewController(t)
// In Go versions 1.14+, if you pass a *testing.T
// into gomock.NewController(t) you no longer need to call ctrl.Finish().
- //defer ctrl.Finish()
+ // defer ctrl.Finish()
var invokers []protocol.Invoker
for i := 0; i < 2; i++ {
@@ -155,7 +158,8 @@
func(invocation protocol.Invocation) protocol.Result {
return &protocol.RPCResult{
Attrs: map[string]interface{}{constant.ZONE_KEY: zoneValue},
- Rest: rest{tried: 0, success: true}}
+ Rest: rest{tried: 0, success: true},
+ }
})
invokers = append(invokers, invoker)
}
@@ -178,7 +182,7 @@
ctrl := gomock.NewController(t)
// In Go versions 1.14+, if you pass a *testing.T
// into gomock.NewController(t) you no longer need to call ctrl.Finish().
- //defer ctrl.Finish()
+ // defer ctrl.Finish()
var invokers []protocol.Invoker
for i := 0; i < 2; i++ {
diff --git a/cluster/directory/base_directory_test.go b/cluster/directory/base_directory_test.go
index 443f07d..9bbcac3 100644
--- a/cluster/directory/base_directory_test.go
+++ b/cluster/directory/base_directory_test.go
@@ -47,7 +47,6 @@
}
func TestBuildRouterChain(t *testing.T) {
-
regURL := url
regURL.AddParam(constant.INTERFACE_KEY, "mock-app")
directory := NewBaseDirectory(regURL)
diff --git a/cluster/directory/static_directory.go b/cluster/directory/static_directory.go
index d9695d4..e184dc6 100644
--- a/cluster/directory/static_directory.go
+++ b/cluster/directory/static_directory.go
@@ -48,7 +48,7 @@
return dir
}
-//for-loop invokers ,if all invokers is available ,then it means directory is available
+// for-loop invokers ,if all invokers is available ,then it means directory is available
func (dir *staticDirectory) IsAvailable() bool {
if len(dir.invokers) == 0 {
return false
diff --git a/cluster/loadbalance/consistent_hash.go b/cluster/loadbalance/consistent_hash.go
index 3d036b4..314728a 100644
--- a/cluster/loadbalance/consistent_hash.go
+++ b/cluster/loadbalance/consistent_hash.go
@@ -27,9 +27,11 @@
"strconv"
"strings"
)
+
import (
gxsort "github.com/dubbogo/gost/sort"
)
+
import (
"github.com/apache/dubbo-go/cluster"
"github.com/apache/dubbo-go/common/constant"
@@ -56,8 +58,7 @@
}
// ConsistentHashLoadBalance implementation of load balancing: using consistent hashing
-type ConsistentHashLoadBalance struct {
-}
+type ConsistentHashLoadBalance struct{}
// NewConsistentHashLoadBalance creates NewConsistentHashLoadBalance
//
diff --git a/cluster/loadbalance/least_active.go b/cluster/loadbalance/least_active.go
index 8776735..f8fc015 100644
--- a/cluster/loadbalance/least_active.go
+++ b/cluster/loadbalance/least_active.go
@@ -36,8 +36,7 @@
extension.SetLoadbalance(LeastActive, NewLeastActiveLoadBalance)
}
-type leastActiveLoadBalance struct {
-}
+type leastActiveLoadBalance struct{}
// NewLeastActiveLoadBalance returns a least active load balance.
//
diff --git a/cluster/loadbalance/random.go b/cluster/loadbalance/random.go
index cdde1b4..a2ae2be 100644
--- a/cluster/loadbalance/random.go
+++ b/cluster/loadbalance/random.go
@@ -35,8 +35,7 @@
extension.SetLoadbalance(name, NewRandomLoadBalance)
}
-type randomLoadBalance struct {
-}
+type randomLoadBalance struct{}
// NewRandomLoadBalance returns a random load balance instance.
//
diff --git a/cluster/loadbalance/round_robin.go b/cluster/loadbalance/round_robin.go
index 51a76da..f7653b6 100644
--- a/cluster/loadbalance/round_robin.go
+++ b/cluster/loadbalance/round_robin.go
@@ -83,7 +83,7 @@
)
for _, invoker := range invokers {
- var weight = GetWeight(invoker, invocation)
+ weight := GetWeight(invoker, invocation)
if weight < 0 {
weight = 0
}
diff --git a/cluster/loadbalance/util.go b/cluster/loadbalance/util.go
index 684ffe1..2dd55d3 100644
--- a/cluster/loadbalance/util.go
+++ b/cluster/loadbalance/util.go
@@ -38,7 +38,7 @@
weight = url.GetMethodParamInt64(invocation.MethodName(), constant.WEIGHT_KEY, constant.DEFAULT_WEIGHT)
if weight > 0 {
- //get service register time an do warm up time
+ // get service register time an do warm up time
now := time.Now().Unix()
timestamp := url.GetParamInt(constant.REMOTE_TIMESTAMP_KEY, now)
if uptime := now - timestamp; uptime > 0 {
diff --git a/cluster/router/chain/chain_test.go b/cluster/router/chain/chain_test.go
index 779f4c7..d38b3be 100644
--- a/cluster/router/chain/chain_test.go
+++ b/cluster/router/chain/chain_test.go
@@ -25,6 +25,8 @@
)
import (
+ zk "github.com/dubbogo/go-zookeeper/zk"
+ gxzookeeper "github.com/dubbogo/gost/database/kv/zk"
"github.com/stretchr/testify/assert"
)
@@ -38,7 +40,6 @@
_ "github.com/apache/dubbo-go/config_center/zookeeper"
"github.com/apache/dubbo-go/protocol"
"github.com/apache/dubbo-go/protocol/invocation"
- "github.com/apache/dubbo-go/remoting/zookeeper"
)
const (
@@ -53,16 +54,19 @@
consumerFormat = "consumer://%s/com.foo.BarService"
dubboForamt = "dubbo://%s:%d/com.foo.BarService"
anyUrlFormat = "condition://%s/com.foo.BarService"
- zk = "zookeeper"
+ zkName = "zookeeper"
applicationKey = "test-condition"
applicationField = "application"
forceField = "force"
forceValue = "true"
)
+var zkCluster *zk.TestCluster
+
func TestNewRouterChain(t *testing.T) {
- ts, z, _, err := zookeeper.NewMockZookeeperClient("test", 15*time.Second)
+ ts, z, _, err := gxzookeeper.NewMockZookeeperClient("test", 15*time.Second)
assert.NoError(t, err)
+ zkCluster = ts
err = z.Create(path)
assert.NoError(t, err)
testyml := `scope: application
@@ -77,12 +81,12 @@
_, err = z.Conn.Set(path, []byte(testyml), 0)
assert.NoError(t, err)
defer func() {
- _ = ts.Stop()
+ z.Delete(path)
z.Close()
}()
zkUrl, _ := common.NewURL(fmt.Sprintf(zkFormat, localIP, ts.Servers[0].Port))
- configuration, err := extension.GetConfigCenterFactory(zk).GetDynamicConfiguration(zkUrl)
+ configuration, err := extension.GetConfigCenterFactory(zkName).GetDynamicConfiguration(zkUrl)
config.GetEnvInstance().SetDynamicConfiguration(configuration)
assert.Nil(t, err)
@@ -114,7 +118,7 @@
}
func TestRouterChainAddRouters(t *testing.T) {
- ts, z, _, err := zookeeper.NewMockZookeeperClient("test", 15*time.Second)
+ _, z, _, err := gxzookeeper.NewMockZookeeperClient("test", 15*time.Second, gxzookeeper.WithTestCluster(zkCluster))
assert.NoError(t, err)
err = z.Create(path)
assert.NoError(t, err)
@@ -131,13 +135,12 @@
_, err = z.Conn.Set(path, []byte(testyml), 0)
assert.NoError(t, err)
defer func() {
- _ = ts.Stop()
- assert.NoError(t, err)
+ z.Delete(path)
z.Close()
}()
- zkUrl, _ := common.NewURL(fmt.Sprintf(zkFormat, localIP, ts.Servers[0].Port))
- configuration, err := extension.GetConfigCenterFactory(zk).GetDynamicConfiguration(zkUrl)
+ zkUrl, _ := common.NewURL(fmt.Sprintf(zkFormat, localIP, zkCluster.Servers[0].Port))
+ configuration, err := extension.GetConfigCenterFactory(zkName).GetDynamicConfiguration(zkUrl)
assert.NoError(t, err)
config.GetEnvInstance().SetDynamicConfiguration(configuration)
@@ -164,15 +167,10 @@
}
func TestRouterChainRoute(t *testing.T) {
- ts, z, _, err := zookeeper.NewMockZookeeperClient("test", 15*time.Second)
- defer func() {
- err = ts.Stop()
- assert.NoError(t, err)
- z.Close()
- }()
-
+ ts, _, _, err := gxzookeeper.NewMockZookeeperClient("test", 15*time.Second, gxzookeeper.WithTestCluster(zkCluster))
+ assert.Nil(t, err)
zkUrl, _ := common.NewURL(fmt.Sprintf(zkFormat, localIP, ts.Servers[0].Port))
- configuration, err := extension.GetConfigCenterFactory(zk).GetDynamicConfiguration(zkUrl)
+ configuration, err := extension.GetConfigCenterFactory(zkName).GetDynamicConfiguration(zkUrl)
assert.NoError(t, err)
config.GetEnvInstance().SetDynamicConfiguration(configuration)
@@ -197,7 +195,7 @@
}
func TestRouterChainRouteAppRouter(t *testing.T) {
- ts, z, _, err := zookeeper.NewMockZookeeperClient("test", 15*time.Second)
+ ts, z, _, err := gxzookeeper.NewMockZookeeperClient("test", 15*time.Second, gxzookeeper.WithTestCluster(zkCluster))
assert.NoError(t, err)
err = z.Create(path)
assert.NoError(t, err)
@@ -214,13 +212,12 @@
_, err = z.Conn.Set(path, []byte(testyml), 0)
assert.NoError(t, err)
defer func() {
- _ = ts.Stop()
- assert.NoError(t, err)
+ z.Delete(path)
z.Close()
}()
zkUrl, _ := common.NewURL(fmt.Sprintf(zkFormat, localIP, ts.Servers[0].Port))
- configuration, err := extension.GetConfigCenterFactory(zk).GetDynamicConfiguration(zkUrl)
+ configuration, err := extension.GetConfigCenterFactory(zkName).GetDynamicConfiguration(zkUrl)
assert.NoError(t, err)
config.GetEnvInstance().SetDynamicConfiguration(configuration)
@@ -242,7 +239,7 @@
}
func TestRouterChainRouteNoRoute(t *testing.T) {
- ts, z, _, err := zookeeper.NewMockZookeeperClient("test", 15*time.Second)
+ ts, z, _, err := gxzookeeper.NewMockZookeeperClient("test", 15*time.Second, gxzookeeper.WithTestCluster(zkCluster))
assert.Nil(t, err)
defer func() {
_ = ts.Stop()
@@ -251,7 +248,7 @@
}()
zkUrl, _ := common.NewURL(fmt.Sprintf(zkFormat, localIP, ts.Servers[0].Port))
- configuration, err := extension.GetConfigCenterFactory(zk).GetDynamicConfiguration(zkUrl)
+ configuration, err := extension.GetConfigCenterFactory(zkName).GetDynamicConfiguration(zkUrl)
config.GetEnvInstance().SetDynamicConfiguration(configuration)
assert.Nil(t, err)
diff --git a/cluster/router/condition/app_router_test.go b/cluster/router/condition/app_router_test.go
index f55818d..6e072b6 100644
--- a/cluster/router/condition/app_router_test.go
+++ b/cluster/router/condition/app_router_test.go
@@ -24,6 +24,7 @@
)
import (
+ gxzookeeper "github.com/dubbogo/gost/database/kv/zk"
"github.com/stretchr/testify/assert"
)
@@ -35,7 +36,6 @@
"github.com/apache/dubbo-go/config_center"
_ "github.com/apache/dubbo-go/config_center/zookeeper"
"github.com/apache/dubbo-go/remoting"
- "github.com/apache/dubbo-go/remoting/zookeeper"
)
const (
@@ -51,7 +51,6 @@
)
func TestNewAppRouter(t *testing.T) {
-
testYML := `scope: application
key: mock-app
enabled: true
@@ -60,7 +59,7 @@
conditions:
- => host != 172.22.3.91
`
- ts, z, _, err := zookeeper.NewMockZookeeperClient("test", 15*time.Second)
+ ts, z, _, err := gxzookeeper.NewMockZookeeperClient("test", 15*time.Second)
assert.NoError(t, err)
err = z.Create(routerPath)
assert.NoError(t, err)
@@ -68,7 +67,6 @@
_, err = z.Conn.Set(routerPath, []byte(testYML), 0)
assert.NoError(t, err)
defer func() {
- err = ts.Stop()
assert.NoError(t, err)
z.Close()
}()
@@ -106,7 +104,6 @@
}
func TestGenerateConditions(t *testing.T) {
-
testYML := `scope: application
key: mock-app
enabled: true
@@ -116,7 +113,7 @@
- => host != 172.22.3.91
- host = 192.168.199.208 => host = 192.168.199.208
`
- ts, z, _, err := zookeeper.NewMockZookeeperClient("test", 15*time.Second)
+ ts, z, _, err := gxzookeeper.NewMockZookeeperClient("test", 15*time.Second)
assert.NoError(t, err)
err = z.Create(routerPath)
assert.NoError(t, err)
@@ -124,7 +121,6 @@
_, err = z.Conn.Set(routerPath, []byte(testYML), 0)
assert.NoError(t, err)
defer func() {
- err = ts.Stop()
assert.NoError(t, err)
z.Close()
}()
@@ -154,7 +150,6 @@
}
func TestProcess(t *testing.T) {
-
testYML := `scope: application
key: mock-app
enabled: true
@@ -163,7 +158,7 @@
conditions:
- => host != 172.22.3.91
`
- ts, z, _, err := zookeeper.NewMockZookeeperClient("test", 15*time.Second)
+ ts, z, _, err := gxzookeeper.NewMockZookeeperClient("test", 15*time.Second)
assert.NoError(t, err)
err = z.Create(routerPath)
assert.NoError(t, err)
diff --git a/cluster/router/condition/factory_test.go b/cluster/router/condition/factory_test.go
index e08016d..7cd6fae 100644
--- a/cluster/router/condition/factory_test.go
+++ b/cluster/router/condition/factory_test.go
@@ -204,7 +204,6 @@
assert.Equal(t, 1, len(ret4.ToArray()))
assert.Equal(t, 2, len(ret5.ToArray()))
assert.Equal(t, 1, len(ret6.ToArray()))
-
}
func TestRoute_methodRoute(t *testing.T) {
@@ -232,7 +231,6 @@
router3, _ := newConditionRouterFactory().NewPriorityRouter(getRouteUrl(rule3), notify)
matchWhen = router3.(*ConditionRouter).MatchWhen(url3, inv)
assert.Equal(t, true, matchWhen)
-
}
func TestRoute_ReturnFalse(t *testing.T) {
diff --git a/cluster/router/condition/listenable_router.go b/cluster/router/condition/listenable_router.go
index 2e55b20..79d80da 100644
--- a/cluster/router/condition/listenable_router.go
+++ b/cluster/router/condition/listenable_router.go
@@ -83,7 +83,8 @@
l.Process(&config_center.ConfigChangeEvent{
Key: routerKey,
Value: rule,
- ConfigType: remoting.EventTypeUpdate})
+ ConfigType: remoting.EventTypeUpdate,
+ })
logger.Info("Init app router success")
return l, nil
diff --git a/cluster/router/condition/router.go b/cluster/router/condition/router.go
index d543ca3..e1aef98 100644
--- a/cluster/router/condition/router.go
+++ b/cluster/router/condition/router.go
@@ -42,16 +42,12 @@
pattern = `([&!=,]*)\\s*([^&!=,\\s]+)`
)
-var (
- routerPatternReg = regexp.MustCompile(`([&!=,]*)\s*([^&!=,\s]+)`)
-)
+var routerPatternReg = regexp.MustCompile(`([&!=,]*)\s*([^&!=,\s]+)`)
-var (
- emptyMatchPair = MatchPair{
- Matches: gxset.NewSet(),
- Mismatches: gxset.NewSet(),
- }
-)
+var emptyMatchPair = MatchPair{
+ Matches: gxset.NewSet(),
+ Mismatches: gxset.NewSet(),
+}
// ConditionRouter Condition router struct
type ConditionRouter struct {
@@ -231,26 +227,26 @@
}
case "=":
if pair == emptyMatchPair {
- var startIndex = getStartIndex(rule)
+ startIndex := getStartIndex(rule)
return nil, perrors.Errorf("Illegal route rule \"%s\", The error char '%s' at index %d before \"%d\".", rule, separator, startIndex, startIndex)
}
values = pair.Matches
values.Add(content)
case "!=":
if pair == emptyMatchPair {
- var startIndex = getStartIndex(rule)
+ startIndex := getStartIndex(rule)
return nil, perrors.Errorf("Illegal route rule \"%s\", The error char '%s' at index %d before \"%d\".", rule, separator, startIndex, startIndex)
}
values = pair.Mismatches
values.Add(content)
case ",":
if values.Empty() {
- var startIndex = getStartIndex(rule)
+ startIndex := getStartIndex(rule)
return nil, perrors.Errorf("Illegal route rule \"%s\", The error char '%s' at index %d before \"%d\".", rule, separator, startIndex, startIndex)
}
values.Add(content)
default:
- var startIndex = getStartIndex(rule)
+ startIndex := getStartIndex(rule)
return nil, perrors.Errorf("Illegal route rule \"%s\", The error char '%s' at index %d before \"%d\".", rule, separator, startIndex, startIndex)
}
diff --git a/cluster/router/conncheck/conn_check_route_test.go b/cluster/router/conncheck/conn_check_route_test.go
index fec7331..360e97c 100644
--- a/cluster/router/conncheck/conn_check_route_test.go
+++ b/cluster/router/conncheck/conn_check_route_test.go
@@ -78,7 +78,6 @@
res = hcr.Route(utils.ToBitmap(invokers), setUpAddrCache(hcr.(*ConnCheckRouter), invokers), consumerURL, inv)
// now invoker3 invoker1 is healthy
assert.True(t, len(res.ToArray()) == 2)
-
}
func TestRecovery(t *testing.T) {
diff --git a/cluster/router/conncheck/conn_health_check.go b/cluster/router/conncheck/conn_health_check.go
index 9f05b06..a5cee10 100644
--- a/cluster/router/conncheck/conn_health_check.go
+++ b/cluster/router/conncheck/conn_health_check.go
@@ -30,8 +30,7 @@
}
// DefaultConnChecker is the default implementation of ConnChecker, which determines the health status of invoker conn
-type DefaultConnChecker struct {
-}
+type DefaultConnChecker struct{}
// IsConnHealthy evaluates the healthy state on the given Invoker based on the number of successive bad request
// and the current active request
diff --git a/cluster/router/conncheck/factory.go b/cluster/router/conncheck/factory.go
index a7b19aa..fb03689 100644
--- a/cluster/router/conncheck/factory.go
+++ b/cluster/router/conncheck/factory.go
@@ -30,8 +30,7 @@
// ConnCheckRouteFactory is the factory to create conn check router, it aims at filter ip with unhealthy status
// the unhealthy status is storied in protocol/rpc_status.go with sync.Map
-type ConnCheckRouteFactory struct {
-}
+type ConnCheckRouteFactory struct{}
// newConnCheckRouteFactory construct a new ConnCheckRouteFactory
func newConnCheckRouteFactory() router.PriorityRouterFactory {
diff --git a/cluster/router/healthcheck/default_health_check.go b/cluster/router/healthcheck/default_health_check.go
index eb15e6f..2c84d65 100644
--- a/cluster/router/healthcheck/default_health_check.go
+++ b/cluster/router/healthcheck/default_health_check.go
@@ -77,7 +77,6 @@
// getCircuitBreakerSleepWindowTime get the sleep window time of invoker, the unit is millisecond
func (c *DefaultHealthChecker) getCircuitBreakerSleepWindowTime(status *protocol.RPCStatus) int64 {
-
successiveFailureCount := status.GetSuccessiveRequestFailureCount()
diff := successiveFailureCount - c.GetRequestSuccessiveFailureThreshold()
if diff < 0 {
diff --git a/cluster/router/healthcheck/default_health_check_test.go b/cluster/router/healthcheck/default_health_check_test.go
index c32a607..4583dad 100644
--- a/cluster/router/healthcheck/default_health_check_test.go
+++ b/cluster/router/healthcheck/default_health_check_test.go
@@ -123,7 +123,6 @@
timeout = defaultHc.getCircuitBreakerTimeout(protocol.GetURLStatus(url1))
// timeout must after the current time
assert.True(t, timeout > protocol.CurrentTimeMillis())
-
}
func TestDefaultHealthCheckerIsCircuitBreakerTripped(t *testing.T) {
@@ -139,7 +138,6 @@
}
tripped = defaultHc.isCircuitBreakerTripped(protocol.GetURLStatus(url))
assert.True(t, tripped)
-
}
func TestNewDefaultHealthChecker(t *testing.T) {
diff --git a/cluster/router/healthcheck/factory.go b/cluster/router/healthcheck/factory.go
index a9054c7..e6d876d 100644
--- a/cluster/router/healthcheck/factory.go
+++ b/cluster/router/healthcheck/factory.go
@@ -29,8 +29,7 @@
}
// HealthCheckRouteFactory
-type HealthCheckRouteFactory struct {
-}
+type HealthCheckRouteFactory struct{}
// newHealthCheckRouteFactory construct a new HealthCheckRouteFactory
func newHealthCheckRouteFactory() router.PriorityRouterFactory {
diff --git a/cluster/router/healthcheck/health_check_route_test.go b/cluster/router/healthcheck/health_check_route_test.go
index f499c85..5422c53 100644
--- a/cluster/router/healthcheck/health_check_route_test.go
+++ b/cluster/router/healthcheck/health_check_route_test.go
@@ -112,7 +112,6 @@
// invoker1 go to healthy again after 2s
res = hcr.Route(utils.ToBitmap(invokers), setUpAddrCache(hcr.(*HealthCheckRouter), invokers), consumerURL, inv)
assert.True(t, res.Contains(0))
-
}
func TestNewHealthCheckRouter(t *testing.T) {
diff --git a/cluster/router/local/factory.go b/cluster/router/local/factory.go
index 42e03e2..711a9ea 100644
--- a/cluster/router/local/factory.go
+++ b/cluster/router/local/factory.go
@@ -29,8 +29,7 @@
}
// LocalPriorityRouteFactory
-type LocalPriorityRouteFactory struct {
-}
+type LocalPriorityRouteFactory struct{}
// newLocalPriorityRouteFactory construct a new LocalDiscRouteFactory
func newLocalPriorityRouteFactory() router.PriorityRouterFactory {
diff --git a/cluster/router/local/self_priority_route.go b/cluster/router/local/self_priority_route.go
index 87eaaf7..7fd188c 100644
--- a/cluster/router/local/self_priority_route.go
+++ b/cluster/router/local/self_priority_route.go
@@ -80,7 +80,7 @@
logger.Debug("found local ip ")
return rb, nil
}
- for i, _ := range invokers {
+ for i := range invokers {
rb[localPriority].Add(uint32(i))
}
return rb, nil
diff --git a/cluster/router/tag/file.go b/cluster/router/tag/file.go
index 81c2510..8977ddc 100644
--- a/cluster/router/tag/file.go
+++ b/cluster/router/tag/file.go
@@ -41,7 +41,7 @@
router *tagRouter
routerRule *RouterRule
url *common.URL
- //force bool
+ // force bool
}
// NewFileTagRouter Create file tag router instance with content (from config file)
diff --git a/cluster/router/tag/file_test.go b/cluster/router/tag/file_test.go
index 513ba0c..1866ec0 100644
--- a/cluster/router/tag/file_test.go
+++ b/cluster/router/tag/file_test.go
@@ -52,7 +52,6 @@
priority := url.GetParam(constant.RouterPriority, "0")
assert.Equal(t, "true", force)
assert.Equal(t, "100", priority)
-
}
func TestFileTagRouterPriority(t *testing.T) {
diff --git a/cluster/router/tag/router_rule.go b/cluster/router/tag/router_rule.go
index 512d8f1..1259c42 100644
--- a/cluster/router/tag/router_rule.go
+++ b/cluster/router/tag/router_rule.go
@@ -69,7 +69,7 @@
}
func (t *RouterRule) getAddresses() []string {
- var result = make([]string, 0, 2*len(t.Tags))
+ result := make([]string, 0, 2*len(t.Tags))
for _, tag := range t.Tags {
result = append(result, tag.Addresses...)
}
@@ -77,7 +77,7 @@
}
func (t *RouterRule) getTagNames() []string {
- var result = make([]string, 0, len(t.Tags))
+ result := make([]string, 0, len(t.Tags))
for _, tag := range t.Tags {
result = append(result, tag.Name)
}
diff --git a/cluster/router/tag/tag_router.go b/cluster/router/tag/tag_router.go
index 3d0393a..e0522d4 100644
--- a/cluster/router/tag/tag_router.go
+++ b/cluster/router/tag/tag_router.go
@@ -53,7 +53,7 @@
// application name
application string
// is rule a runtime rule
- //ruleRuntime bool
+ // ruleRuntime bool
// is rule a force rule
ruleForce bool
// is rule a valid rule
@@ -267,7 +267,8 @@
c.Process(&config_center.ConfigChangeEvent{
Key: routerKey,
Value: rule,
- ConfigType: remoting.EventTypeUpdate})
+ ConfigType: remoting.EventTypeUpdate,
+ })
}
}
diff --git a/cluster/router/tag/tag_router_test.go b/cluster/router/tag/tag_router_test.go
index efee5bd..e5abf4e 100644
--- a/cluster/router/tag/tag_router_test.go
+++ b/cluster/router/tag/tag_router_test.go
@@ -27,6 +27,7 @@
import (
"github.com/RoaringBitmap/roaring"
"github.com/dubbogo/go-zookeeper/zk"
+ gxzookeeper "github.com/dubbogo/gost/database/kv/zk"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
)
@@ -43,7 +44,6 @@
"github.com/apache/dubbo-go/protocol"
"github.com/apache/dubbo-go/protocol/invocation"
"github.com/apache/dubbo-go/remoting"
- "github.com/apache/dubbo-go/remoting/zookeeper"
)
const (
@@ -72,9 +72,7 @@
routerZk = "zookeeper"
)
-var (
- zkFormat = "zookeeper://%s:%d"
-)
+var zkFormat = "zookeeper://%s:%d"
// MockInvoker is only mock the Invoker to support test tagRouter
type MockInvoker struct {
@@ -257,10 +255,10 @@
type DynamicTagRouter struct {
suite.Suite
- //rule *RouterRule
+ // rule *RouterRule
route *tagRouter
- zkClient *zookeeper.ZookeeperClient
+ zkClient *gxzookeeper.ZookeeperClient
testCluster *zk.TestCluster
invokers []protocol.Invoker
url *common.URL
@@ -299,7 +297,7 @@
- name: tag3
addresses: ["127.0.0.1:20003", "127.0.0.1:20004"]
`
- ts, z, _, err := zookeeper.NewMockZookeeperClient("test", 15*time.Second)
+ ts, z, _, err := gxzookeeper.NewMockZookeeperClient("test", 15*time.Second)
suite.NoError(err)
err = z.Create(routerPath)
suite.NoError(err)
@@ -334,8 +332,6 @@
func (suite *DynamicTagRouter) TearDownTest() {
suite.zkClient.Close()
- err := suite.testCluster.Stop()
- suite.Nil(err)
}
func (suite *DynamicTagRouter) TestDynamicTagRouterSetByIPv4() {
diff --git a/common/config/environment.go b/common/config/environment.go
index c5651a3..c568646 100644
--- a/common/config/environment.go
+++ b/common/config/environment.go
@@ -35,7 +35,7 @@
// But for add these features in future ,I finish the environment struct following Environment class in java.
type Environment struct {
configCenterFirst bool
- //externalConfigs sync.Map
+ // externalConfigs sync.Map
externalConfigMap sync.Map
appExternalConfigMap sync.Map
dynamicConfiguration config_center.DynamicConfiguration
@@ -72,6 +72,12 @@
for k, v := range externalMap {
env.externalConfigMap.Store(k, v)
}
+ env.externalConfigMap.Range(func(key, value interface{}) bool {
+ if _, ok := externalMap[key.(string)]; !ok {
+ env.externalConfigMap.Delete(key)
+ }
+ return true
+ })
}
// UpdateAppExternalConfigMap updates env appExternalConfigMap field
@@ -79,15 +85,21 @@
for k, v := range externalMap {
env.appExternalConfigMap.Store(k, v)
}
+ env.appExternalConfigMap.Range(func(key, value interface{}) bool {
+ if _, ok := externalMap[key.(string)]; !ok {
+ env.appExternalConfigMap.Delete(key)
+ }
+ return true
+ })
}
// Configuration puts externalConfigMap and appExternalConfigMap into list
// List represents a doubly linked list.
func (env *Environment) Configuration() *list.List {
cfgList := list.New()
- // The sequence would be: SystemConfiguration -> ExternalConfiguration -> AppExternalConfiguration -> AbstractConfig -> PropertiesConfiguration
- cfgList.PushFront(newInmemoryConfiguration(&(env.externalConfigMap)))
- cfgList.PushFront(newInmemoryConfiguration(&(env.appExternalConfigMap)))
+ // The sequence would be: SystemConfiguration -> AppExternalConfiguration -> ExternalConfiguration -> AbstractConfig -> PropertiesConfiguration
+ cfgList.PushBack(newInmemoryConfiguration(&(env.appExternalConfigMap)))
+ cfgList.PushBack(newInmemoryConfiguration(&(env.externalConfigMap)))
return cfgList
}
diff --git a/common/config/environment_test.go b/common/config/environment_test.go
index 183071b..ed3ca55 100644
--- a/common/config/environment_test.go
+++ b/common/config/environment_test.go
@@ -34,6 +34,29 @@
v, ok := GetEnvInstance().externalConfigMap.Load("1")
assert.True(t, ok)
assert.Equal(t, "2", v)
+
+ GetEnvInstance().UpdateExternalConfigMap(map[string]string{"a": "b"})
+ v, ok = GetEnvInstance().externalConfigMap.Load("a")
+ assert.True(t, ok)
+ assert.Equal(t, "b", v)
+ v, ok = GetEnvInstance().externalConfigMap.Load("1")
+ assert.False(t, ok)
+ assert.Equal(t, nil, v)
+}
+
+func TestEnvironmentUpdateAppExternalConfigMap(t *testing.T) {
+ GetEnvInstance().UpdateAppExternalConfigMap(map[string]string{"1": "2"})
+ v, ok := GetEnvInstance().appExternalConfigMap.Load("1")
+ assert.True(t, ok)
+ assert.Equal(t, "2", v)
+
+ GetEnvInstance().UpdateAppExternalConfigMap(map[string]string{"a": "b"})
+ v, ok = GetEnvInstance().appExternalConfigMap.Load("a")
+ assert.True(t, ok)
+ assert.Equal(t, "b", v)
+ v, ok = GetEnvInstance().appExternalConfigMap.Load("1")
+ assert.False(t, ok)
+ assert.Equal(t, nil, v)
}
func TestEnvironmentConfigurationAndGetProperty(t *testing.T) {
diff --git a/common/constant/default.go b/common/constant/default.go
index bbe022c..f52a3f0 100644
--- a/common/constant/default.go
+++ b/common/constant/default.go
@@ -20,7 +20,7 @@
const (
DUBBO = "dubbo"
PROVIDER_PROTOCOL = "provider"
- //compatible with 2.6.x
+ // compatible with 2.6.x
OVERRIDE_PROTOCOL = "override"
EMPTY_PROTOCOL = "empty"
ROUTER_PROTOCOL = "router"
@@ -87,3 +87,10 @@
const (
SERVICE_DISCOVERY_DEFAULT_GROUP = "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"
+)
diff --git a/common/constant/key.go b/common/constant/key.go
index 3afcc5e..fb77a13 100644
--- a/common/constant/key.go
+++ b/common/constant/key.go
@@ -146,6 +146,7 @@
CONFIG_VERSION_KEY = "configVersion"
COMPATIBLE_CONFIG_KEY = "compatible_config"
)
+
const (
RegistryConfigPrefix = "dubbo.registries."
SingleRegistryConfigPrefix = "dubbo.registry."
diff --git a/common/constant/time.go b/common/constant/time.go
index 3bb3392..d50990c 100644
--- a/common/constant/time.go
+++ b/common/constant/time.go
@@ -21,8 +21,6 @@
"time"
)
-var (
- // The value will be 10^6
- // 1ms = 10^6ns
- MsToNanoRate = int64(time.Millisecond / time.Nanosecond)
-)
+// The value will be 10^6
+// 1ms = 10^6ns
+var MsToNanoRate = int64(time.Millisecond / time.Nanosecond)
diff --git a/common/constant/version.go b/common/constant/version.go
index 0403e3a..d24a9fd 100644
--- a/common/constant/version.go
+++ b/common/constant/version.go
@@ -19,9 +19,9 @@
const (
// Version apache/dubbo-go version
- Version = "1.5.5"
+ Version = "1.5.6"
// Name module name
Name = "dubbogo"
// Date release date
- DATE = "2021/01/05"
+ DATE = "2021/03/22"
)
diff --git a/common/extension/cluster.go b/common/extension/cluster.go
index 8be27a1..1f6ab10 100644
--- a/common/extension/cluster.go
+++ b/common/extension/cluster.go
@@ -21,9 +21,7 @@
"github.com/apache/dubbo-go/cluster"
)
-var (
- clusters = make(map[string]func() cluster.Cluster)
-)
+var clusters = make(map[string]func() cluster.Cluster)
// SetCluster sets the cluster fault-tolerant mode with @name
// For example: available/failfast/broadcast/failfast/failsafe/...
diff --git a/common/extension/config_center.go b/common/extension/config_center.go
index 5a2c52f..9c616d3 100644
--- a/common/extension/config_center.go
+++ b/common/extension/config_center.go
@@ -22,9 +22,7 @@
"github.com/apache/dubbo-go/config_center"
)
-var (
- configCenters = make(map[string]func(config *common.URL) (config_center.DynamicConfiguration, error))
-)
+var configCenters = make(map[string]func(config *common.URL) (config_center.DynamicConfiguration, error))
// SetConfigCenter sets the DynamicConfiguration with @name
func SetConfigCenter(name string, v func(*common.URL) (config_center.DynamicConfiguration, error)) {
@@ -37,5 +35,4 @@
panic("config center for " + name + " is not existing, make sure you have import the package.")
}
return configCenters[name](config)
-
}
diff --git a/common/extension/config_center_factory.go b/common/extension/config_center_factory.go
index dff8975..9d3f0d9 100644
--- a/common/extension/config_center_factory.go
+++ b/common/extension/config_center_factory.go
@@ -21,9 +21,7 @@
"github.com/apache/dubbo-go/config_center"
)
-var (
- configCenterFactories = make(map[string]func() config_center.DynamicConfigurationFactory)
-)
+var configCenterFactories = make(map[string]func() config_center.DynamicConfigurationFactory)
// SetConfigCenterFactory sets the DynamicConfigurationFactory with @name
func SetConfigCenterFactory(name string, v func() config_center.DynamicConfigurationFactory) {
diff --git a/common/extension/config_post_processor.go b/common/extension/config_post_processor.go
index db126b7..19a479e 100644
--- a/common/extension/config_post_processor.go
+++ b/common/extension/config_post_processor.go
@@ -21,9 +21,7 @@
"github.com/apache/dubbo-go/config/interfaces"
)
-var (
- processors = make(map[string]interfaces.ConfigPostProcessor)
-)
+var processors = make(map[string]interfaces.ConfigPostProcessor)
// SetConfigPostProcessor registers a ConfigPostProcessor with the given name.
func SetConfigPostProcessor(name string, processor interfaces.ConfigPostProcessor) {
diff --git a/common/extension/configurator.go b/common/extension/configurator.go
index dc2bea7..3cc7ffc 100644
--- a/common/extension/configurator.go
+++ b/common/extension/configurator.go
@@ -29,9 +29,7 @@
type getConfiguratorFunc func(url *common.URL) config_center.Configurator
-var (
- configurator = make(map[string]getConfiguratorFunc)
-)
+var configurator = make(map[string]getConfiguratorFunc)
// SetConfigurator sets the getConfiguratorFunc with @name
func SetConfigurator(name string, v getConfiguratorFunc) {
@@ -44,7 +42,6 @@
panic("configurator for " + name + " is not existing, make sure you have import the package.")
}
return configurator[name](url)
-
}
// SetDefaultConfigurator sets the default Configurator
@@ -58,7 +55,6 @@
panic("configurator for default is not existing, make sure you have import the package.")
}
return configurator[DefaultKey](url)
-
}
// GetDefaultConfiguratorFunc gets default configurator function
diff --git a/common/extension/conn_checker.go b/common/extension/conn_checker.go
index fbd9e34..38659d7 100644
--- a/common/extension/conn_checker.go
+++ b/common/extension/conn_checker.go
@@ -22,9 +22,7 @@
"github.com/apache/dubbo-go/common"
)
-var (
- connCheckers = make(map[string]func(url *common.URL) router.ConnChecker)
-)
+var connCheckers = make(map[string]func(url *common.URL) router.ConnChecker)
// SetHealthChecker sets the HealthChecker with @name
func SetConnChecker(name string, fcn func(_ *common.URL) router.ConnChecker) {
diff --git a/common/extension/event_dispatcher.go b/common/extension/event_dispatcher.go
index f0503e0..3504d9b 100644
--- a/common/extension/event_dispatcher.go
+++ b/common/extension/event_dispatcher.go
@@ -32,9 +32,7 @@
initEventOnce sync.Once
)
-var (
- dispatchers = make(map[string]func() observer.EventDispatcher, 8)
-)
+var dispatchers = make(map[string]func() observer.EventDispatcher, 8)
// SetEventDispatcher, actually, it doesn't really init the global dispatcher
func SetEventDispatcher(name string, v func() observer.EventDispatcher) {
diff --git a/common/extension/event_dispatcher_test.go b/common/extension/event_dispatcher_test.go
index 472360c..fbcf452 100644
--- a/common/extension/event_dispatcher_test.go
+++ b/common/extension/event_dispatcher_test.go
@@ -25,6 +25,7 @@
import (
"github.com/stretchr/testify/assert"
)
+
import (
"github.com/apache/dubbo-go/common/observer"
)
@@ -64,8 +65,7 @@
assert.Equal(t, 2, len(initEventListeners))
}
-type mockEventListener struct {
-}
+type mockEventListener struct{}
func (m mockEventListener) GetPriority() int {
panic("implement me")
@@ -79,8 +79,7 @@
panic("implement me")
}
-type mockEventDispatcher struct {
-}
+type mockEventDispatcher struct{}
func (m mockEventDispatcher) AddEventListener(listener observer.EventListener) {
panic("implement me")
diff --git a/common/extension/graceful_shutdown.go b/common/extension/graceful_shutdown.go
index cb55419..8c98192 100644
--- a/common/extension/graceful_shutdown.go
+++ b/common/extension/graceful_shutdown.go
@@ -21,9 +21,7 @@
"container/list"
)
-var (
- customShutdownCallbacks = list.New()
-)
+var customShutdownCallbacks = list.New()
/**
* AddCustomShutdownCallback
diff --git a/common/extension/health_checker.go b/common/extension/health_checker.go
index cec4c2d..c0cc0f6 100644
--- a/common/extension/health_checker.go
+++ b/common/extension/health_checker.go
@@ -22,9 +22,7 @@
"github.com/apache/dubbo-go/common"
)
-var (
- healthCheckers = make(map[string]func(url *common.URL) router.HealthChecker)
-)
+var healthCheckers = make(map[string]func(url *common.URL) router.HealthChecker)
// SetHealthChecker sets the HealthChecker with @name
func SetHealthChecker(name string, fcn func(_ *common.URL) router.HealthChecker) {
diff --git a/common/extension/health_checker_test.go b/common/extension/health_checker_test.go
index af6b114..cee12ce 100644
--- a/common/extension/health_checker_test.go
+++ b/common/extension/health_checker_test.go
@@ -37,8 +37,7 @@
assert.NotNil(t, checker)
}
-type mockHealthChecker struct {
-}
+type mockHealthChecker struct{}
func (m mockHealthChecker) IsHealthy(invoker protocol.Invoker) bool {
return true
diff --git a/common/extension/loadbalance.go b/common/extension/loadbalance.go
index aa19141..bbd0fbc 100644
--- a/common/extension/loadbalance.go
+++ b/common/extension/loadbalance.go
@@ -21,9 +21,7 @@
"github.com/apache/dubbo-go/cluster"
)
-var (
- loadbalances = make(map[string]func() cluster.LoadBalance)
-)
+var loadbalances = make(map[string]func() cluster.LoadBalance)
// SetLoadbalance sets the loadbalance extension with @name
// For example: random/round_robin/consistent_hash/least_active/...
diff --git a/common/extension/metadata_report_factory.go b/common/extension/metadata_report_factory.go
index 593318d..641ba4a 100644
--- a/common/extension/metadata_report_factory.go
+++ b/common/extension/metadata_report_factory.go
@@ -21,9 +21,7 @@
"github.com/apache/dubbo-go/metadata/report/factory"
)
-var (
- metaDataReportFactories = make(map[string]func() factory.MetadataReportFactory, 8)
-)
+var metaDataReportFactories = make(map[string]func() factory.MetadataReportFactory, 8)
// SetMetadataReportFactory sets the MetadataReportFactory with @name
func SetMetadataReportFactory(name string, v func() factory.MetadataReportFactory) {
diff --git a/common/extension/metadata_service_proxy_factory.go b/common/extension/metadata_service_proxy_factory.go
index 2b88d37..3e05c22 100644
--- a/common/extension/metadata_service_proxy_factory.go
+++ b/common/extension/metadata_service_proxy_factory.go
@@ -25,9 +25,7 @@
"github.com/apache/dubbo-go/metadata/service"
)
-var (
- metadataServiceProxyFactoryMap = make(map[string]func() service.MetadataServiceProxyFactory, 2)
-)
+var metadataServiceProxyFactoryMap = make(map[string]func() service.MetadataServiceProxyFactory, 2)
type MetadataServiceProxyFactoryFunc func() service.MetadataServiceProxyFactory
diff --git a/common/extension/metrics.go b/common/extension/metrics.go
index 60cf6ba..3e221b7 100644
--- a/common/extension/metrics.go
+++ b/common/extension/metrics.go
@@ -21,11 +21,9 @@
"github.com/apache/dubbo-go/metrics"
)
-var (
- // we couldn't store the instance because the some instance may initialize before loading configuration
- // so lazy initialization will be better.
- metricReporterMap = make(map[string]func() metrics.Reporter, 4)
-)
+// we couldn't store the instance because the some instance may initialize before loading configuration
+// so lazy initialization will be better.
+var metricReporterMap = make(map[string]func() metrics.Reporter, 4)
// SetMetricReporter sets a reporter with the @name
func SetMetricReporter(name string, reporterFunc func() metrics.Reporter) {
diff --git a/common/extension/metrics_test.go b/common/extension/metrics_test.go
index 2aaae75..bcd86a8 100644
--- a/common/extension/metrics_test.go
+++ b/common/extension/metrics_test.go
@@ -42,8 +42,7 @@
assert.Equal(t, reporter, res)
}
-type mockReporter struct {
-}
+type mockReporter struct{}
// Report method for feature expansion
func (m mockReporter) Report(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation, cost time.Duration, res protocol.Result) {
diff --git a/common/extension/protocol.go b/common/extension/protocol.go
index c89dd08..0c77ead 100644
--- a/common/extension/protocol.go
+++ b/common/extension/protocol.go
@@ -21,9 +21,7 @@
"github.com/apache/dubbo-go/protocol"
)
-var (
- protocols = make(map[string]func() protocol.Protocol)
-)
+var protocols = make(map[string]func() protocol.Protocol)
// SetProtocol sets the protocol extension with @name
func SetProtocol(name string, v func() protocol.Protocol) {
diff --git a/common/extension/proxy_factory.go b/common/extension/proxy_factory.go
index 1e326d8..414905f 100644
--- a/common/extension/proxy_factory.go
+++ b/common/extension/proxy_factory.go
@@ -21,9 +21,7 @@
"github.com/apache/dubbo-go/common/proxy"
)
-var (
- proxyFactories = make(map[string]func(...proxy.Option) proxy.ProxyFactory)
-)
+var proxyFactories = make(map[string]func(...proxy.Option) proxy.ProxyFactory)
// SetProxyFactory sets the ProxyFactory extension with @name
func SetProxyFactory(name string, f func(...proxy.Option) proxy.ProxyFactory) {
diff --git a/common/extension/registry.go b/common/extension/registry.go
index 187c8fe..411ee37 100644
--- a/common/extension/registry.go
+++ b/common/extension/registry.go
@@ -22,9 +22,7 @@
"github.com/apache/dubbo-go/registry"
)
-var (
- registrys = make(map[string]func(config *common.URL) (registry.Registry, error))
-)
+var registrys = make(map[string]func(config *common.URL) (registry.Registry, error))
// SetRegistry sets the registry extension with @name
func SetRegistry(name string, v func(_ *common.URL) (registry.Registry, error)) {
@@ -37,5 +35,4 @@
panic("registry for " + name + " does not exist. please make sure that you have imported the package `github.com/apache/dubbo-go/registry/" + name + "`.")
}
return registrys[name](config)
-
}
diff --git a/common/extension/rest_client.go b/common/extension/rest_client.go
index 0c2f4dd..be60d28 100644
--- a/common/extension/rest_client.go
+++ b/common/extension/rest_client.go
@@ -21,9 +21,7 @@
"github.com/apache/dubbo-go/protocol/rest/client"
)
-var (
- restClients = make(map[string]func(restOptions *client.RestOptions) client.RestClient, 8)
-)
+var restClients = make(map[string]func(restOptions *client.RestOptions) client.RestClient, 8)
// SetRestClient sets the RestClient with @name
func SetRestClient(name string, fun func(_ *client.RestOptions) client.RestClient) {
diff --git a/common/extension/rest_server.go b/common/extension/rest_server.go
index 37a231a..c055309 100644
--- a/common/extension/rest_server.go
+++ b/common/extension/rest_server.go
@@ -21,9 +21,7 @@
"github.com/apache/dubbo-go/protocol/rest/server"
)
-var (
- restServers = make(map[string]func() server.RestServer, 8)
-)
+var restServers = make(map[string]func() server.RestServer, 8)
// SetRestServer sets the RestServer with @name
func SetRestServer(name string, fun func() server.RestServer) {
diff --git a/common/extension/service_discovery.go b/common/extension/service_discovery.go
index 0227920..6a691e1 100644
--- a/common/extension/service_discovery.go
+++ b/common/extension/service_discovery.go
@@ -20,13 +20,12 @@
import (
perrors "github.com/pkg/errors"
)
+
import (
"github.com/apache/dubbo-go/registry"
)
-var (
- discoveryCreatorMap = make(map[string]func(name string) (registry.ServiceDiscovery, error), 4)
-)
+var discoveryCreatorMap = make(map[string]func(name string) (registry.ServiceDiscovery, error), 4)
// SetServiceDiscovery will store the @creator and @name
// protocol indicate the implementation, like nacos
diff --git a/common/extension/service_instance_customizer.go b/common/extension/service_instance_customizer.go
index 3ebb3e4..3ec6af1 100644
--- a/common/extension/service_instance_customizer.go
+++ b/common/extension/service_instance_customizer.go
@@ -25,9 +25,7 @@
"github.com/apache/dubbo-go/registry"
)
-var (
- customizers = make([]registry.ServiceInstanceCustomizer, 0, 8)
-)
+var customizers = make([]registry.ServiceInstanceCustomizer, 0, 8)
// AddCustomizers will put the customizer into slices and then sort them;
// this method will be invoked several time, so we sort them here.
diff --git a/common/extension/service_instance_selector_factory.go b/common/extension/service_instance_selector_factory.go
index 66d3e76..9d107c4 100644
--- a/common/extension/service_instance_selector_factory.go
+++ b/common/extension/service_instance_selector_factory.go
@@ -25,9 +25,7 @@
"github.com/apache/dubbo-go/registry/servicediscovery/instance"
)
-var (
- serviceInstanceSelectorMappings = make(map[string]func() instance.ServiceInstanceSelector, 2)
-)
+var serviceInstanceSelectorMappings = make(map[string]func() instance.ServiceInstanceSelector, 2)
// nolint
func SetServiceInstanceSelector(name string, f func() instance.ServiceInstanceSelector) {
diff --git a/common/extension/service_name_mapping.go b/common/extension/service_name_mapping.go
index 99fd4c2..317acf6 100644
--- a/common/extension/service_name_mapping.go
+++ b/common/extension/service_name_mapping.go
@@ -23,9 +23,7 @@
type ServiceNameMappingCreator func() mapping.ServiceNameMapping
-var (
- globalNameMappingCreator ServiceNameMappingCreator
-)
+var globalNameMappingCreator ServiceNameMappingCreator
func SetGlobalServiceNameMapping(nameMappingCreator ServiceNameMappingCreator) {
globalNameMappingCreator = nameMappingCreator
diff --git a/common/logger/logger.go b/common/logger/logger.go
index 8519543..bc01043 100644
--- a/common/logger/logger.go
+++ b/common/logger/logger.go
@@ -37,9 +37,7 @@
"github.com/apache/dubbo-go/common/constant"
)
-var (
- logger Logger
-)
+var logger Logger
// nolint
type DubboLogger struct {
@@ -72,6 +70,9 @@
for len(fs.Args()) != 0 {
fs.Parse(fs.Args()[1:])
}
+ if *logConfFile == "" {
+ *logConfFile = constant.DEFAULT_LOG_CONF_FILE_PATH
+ }
err := InitLog(*logConfFile)
if err != nil {
log.Printf("[InitLog] warn: %v", err)
diff --git a/common/observer/dispatcher/mock_event_dispatcher.go b/common/observer/dispatcher/mock_event_dispatcher.go
index 45cdaa7..012f5ba 100644
--- a/common/observer/dispatcher/mock_event_dispatcher.go
+++ b/common/observer/dispatcher/mock_event_dispatcher.go
@@ -25,8 +25,7 @@
// It is only used by tests
// Now the implementation doing nothing,
// But you can modify this if needed
-type MockEventDispatcher struct {
-}
+type MockEventDispatcher struct{}
// AddEventListener do nothing
func (m MockEventDispatcher) AddEventListener(listener observer.EventListener) {
diff --git a/common/observer/listenable_test.go b/common/observer/listenable_test.go
index 5a03382..3ae6e5e 100644
--- a/common/observer/listenable_test.go
+++ b/common/observer/listenable_test.go
@@ -41,7 +41,6 @@
ts = append(ts, el)
b.AddEventListeners(ts)
assert.Equal(t, len(al), 1)
-
}
type TestEvent struct {
diff --git a/common/proxy/proxy.go b/common/proxy/proxy.go
index fd34810..68d37b7 100644
--- a/common/proxy/proxy.go
+++ b/common/proxy/proxy.go
@@ -53,9 +53,7 @@
ImplementFunc func(p *Proxy, v common.RPCService)
)
-var (
- typError = reflect.Zero(reflect.TypeOf((*error)(nil)).Elem()).Type()
-)
+var typError = reflect.Zero(reflect.TypeOf((*error)(nil)).Elem()).Type()
// NewProxy create service proxy.
func NewProxy(invoke protocol.Invoker, callback interface{}, attachments map[string]string) *Proxy {
@@ -251,7 +249,7 @@
continue
}
- var funcOuts = make([]reflect.Type, outNum)
+ funcOuts := make([]reflect.Type, outNum)
for i := 0; i < outNum; i++ {
funcOuts[i] = t.Type.Out(i)
}
@@ -261,5 +259,4 @@
logger.Debugf("set method [%s]", methodName)
}
}
-
}
diff --git a/common/proxy/proxy_factory/default.go b/common/proxy/proxy_factory/default.go
index ff3d795..4ef828f 100644
--- a/common/proxy/proxy_factory/default.go
+++ b/common/proxy/proxy_factory/default.go
@@ -41,11 +41,10 @@
}
// DefaultProxyFactory is the default proxy factory
-type DefaultProxyFactory struct {
- //delegate ProxyFactory
+type DefaultProxyFactory struct { // delegate ProxyFactory
}
-//you can rewrite DefaultProxyFactory in extension and delegate the default proxy factory like below
+// you can rewrite DefaultProxyFactory in extension and delegate the default proxy factory like below
//func WithDelegate(delegateProxyFactory ProxyFactory) Option {
// return func(proxy ProxyFactory) {
@@ -65,7 +64,7 @@
// GetAsyncProxy gets a async proxy
func (factory *DefaultProxyFactory) GetAsyncProxy(invoker protocol.Invoker, callBack interface{}, url *common.URL) *proxy.Proxy {
- //create proxy
+ // create proxy
attachments := map[string]string{}
attachments[constant.ASYNC_KEY] = url.GetParam(constant.ASYNC_KEY, "false")
return proxy.NewProxy(invoker, callBack, attachments)
@@ -88,7 +87,7 @@
result := &protocol.RPCResult{}
result.SetAttachments(invocation.Attachments())
- //get providerUrl. The origin url may be is registry URL.
+ // get providerUrl. The origin url may be is registry URL.
url := getProviderURL(pi.GetUrl())
methodName := invocation.MethodName()
diff --git a/common/proxy/proxy_factory/default_test.go b/common/proxy/proxy_factory/default_test.go
index 4002ab9..6a8c29a 100644
--- a/common/proxy/proxy_factory/default_test.go
+++ b/common/proxy/proxy_factory/default_test.go
@@ -38,8 +38,7 @@
assert.NotNil(t, proxy)
}
-type TestAsync struct {
-}
+type TestAsync struct{}
func (u *TestAsync) CallBack(res common.CallbackResponse) {
fmt.Println("CallBack res:", res)
diff --git a/common/proxy/proxy_test.go b/common/proxy/proxy_test.go
index c335bf6..86b3b61 100644
--- a/common/proxy/proxy_test.go
+++ b/common/proxy/proxy_test.go
@@ -58,7 +58,6 @@
}
func TestProxyImplement(t *testing.T) {
-
invoker := protocol.NewBaseInvoker(&common.URL{})
p := NewProxy(invoker, nil, map[string]string{constant.ASYNC_KEY: "false"})
s := &TestService{}
@@ -122,7 +121,6 @@
s3 := &S3{TestService: *s}
p.Implement(s3)
assert.Nil(t, s3.MethodOne)
-
}
func TestProxyImplementForContext(t *testing.T) {
diff --git a/common/rpc_service_test.go b/common/rpc_service_test.go
index e8bd393..ce861b7 100644
--- a/common/rpc_service_test.go
+++ b/common/rpc_service_test.go
@@ -39,47 +39,52 @@
testSuiteMethodExpectedString = "interface {}"
)
-type TestService struct {
-}
+type TestService struct{}
func (s *TestService) MethodOne(ctx context.Context, arg1, arg2, arg3 interface{}) error {
return nil
}
+
func (s *TestService) MethodTwo(arg1, arg2, arg3 interface{}) (interface{}, error) {
return struct{}{}, nil
}
+
func (s *TestService) MethodThree() error {
return nil
}
+
func (s *TestService) Reference() string {
return referenceTestPath
}
+
func (s *TestService) MethodMapper() map[string]string {
return map[string]string{
"MethodTwo": "methodTwo",
}
}
-type testService struct {
-}
+type testService struct{}
func (s *testService) Method1(ctx context.Context, args testService, rsp *struct{}) error {
return nil
}
+
func (s *testService) Method2(ctx context.Context, args []interface{}) (testService, error) {
return testService{}, nil
}
+
func (s *testService) Method3(ctx context.Context, args []interface{}, rsp *struct{}) {
}
+
func (s *testService) Method4(ctx context.Context, args []interface{}, rsp *struct{}) *testService {
return nil
}
+
func (s *testService) Reference() string {
return referenceTestPath
}
-type TestService1 struct {
-}
+type TestService1 struct{}
func (s *TestService1) Reference() string {
return referenceTestPathDistinct
diff --git a/common/url.go b/common/url.go
index 80b85fc..0e923c5 100644
--- a/common/url.go
+++ b/common/url.go
@@ -113,7 +113,7 @@
noCopy noCopy
baseUrl
- //url.Values is not safe map, add to avoid concurrent map read and map write error
+ // url.Values is not safe map, add to avoid concurrent map read and map write error
paramsLock sync.RWMutex
params url.Values
diff --git a/common/yaml/yaml.go b/common/yaml/yaml.go
index d7e1ca4..7f61f72 100644
--- a/common/yaml/yaml.go
+++ b/common/yaml/yaml.go
@@ -49,7 +49,7 @@
return confFileStream, yaml.Unmarshal(confFileStream, out)
}
-//UnmarshalYML unmarshals decodes the first document found within the in byte slice and assigns decoded values into the out value.
+// UnmarshalYML unmarshals decodes the first document found within the in byte slice and assigns decoded values into the out value.
func UnmarshalYML(data []byte, out interface{}) error {
return yaml.Unmarshal(data, out)
}
diff --git a/config/base_config.go b/config/base_config.go
index 7cb25a5..0937d51 100644
--- a/config/base_config.go
+++ b/config/base_config.go
@@ -45,11 +45,14 @@
// application config
ApplicationConfig *ApplicationConfig `yaml:"application" json:"application,omitempty" property:"application"`
- //prefix string
+ // prefix string
fatherConfig interface{}
EventDispatcherType string `default:"direct" yaml:"event_dispatcher_type" json:"event_dispatcher_type,omitempty"`
MetricConfig *MetricConfig `yaml:"metrics" json:"metrics,omitempty"`
fileStream *bytes.Buffer
+
+ // cache file used to store the current used configurations.
+ CacheFile string `yaml:"cache_file" json:"cache_file,omitempty" property:"cache_file"`
}
// nolint
@@ -65,9 +68,7 @@
}
func getKeyPrefix(val reflect.Value) []string {
- var (
- prefix string
- )
+ var prefix string
configPrefixMethod := "Prefix"
if val.CanAddr() {
prefix = val.Addr().MethodByName(configPrefixMethod).Call(nil)[0].String()
@@ -94,7 +95,6 @@
f := val.Field(i)
if f.IsValid() {
setBaseValue := func(f reflect.Value) {
-
var (
ok bool
value string
@@ -167,7 +167,6 @@
}
}
-
}
if f.Kind() == reflect.Ptr {
@@ -195,7 +194,6 @@
}
}
-
}
if f.Kind() == reflect.Map {
@@ -240,7 +238,7 @@
func (c *BaseConfig) fresh() {
configList := config.GetEnvInstance().Configuration()
- for element := configList.Front(); element != nil; element = element.Next() {
+ for element := configList.Back(); element != nil; element = element.Prev() {
cfg := element.Value.(*config.InmemoryConfiguration)
c.freshInternalConfig(cfg)
}
diff --git a/config/base_config_test.go b/config/base_config_test.go
index 566b49b..d3f50c8 100644
--- a/config/base_config_test.go
+++ b/config/base_config_test.go
@@ -112,6 +112,7 @@
mockMap["dubbo.shutdown.timeout"] = "12s"
config.GetEnvInstance().UpdateExternalConfigMap(mockMap)
+ config.GetEnvInstance().UpdateAppExternalConfigMap(map[string]string{})
father := &ConsumerConfig{
Check: &[]bool{true}[0],
@@ -144,9 +145,10 @@
mockMap := getMockMap()
mockMap["dubbo.reference.com.MockService.retries"] = "5"
- config.GetEnvInstance().UpdateAppExternalConfigMap(mockMap)
- mockMap["dubbo.consumer.check"] = "true"
config.GetEnvInstance().UpdateExternalConfigMap(mockMap)
+ mockMap["dubbo.consumer.check"] = "true"
+ config.GetEnvInstance().UpdateAppExternalConfigMap(mockMap)
+
father := &ConsumerConfig{
Check: &[]bool{true}[0],
BaseConfig: BaseConfig{
@@ -172,9 +174,9 @@
delete(mockMap, "dubbo.reference.com.MockService.MockService.retries")
mockMap["dubbo.reference.com.MockService.retries"] = "10"
- config.GetEnvInstance().UpdateAppExternalConfigMap(mockMap)
- mockMap["dubbo.consumer.check"] = "true"
config.GetEnvInstance().UpdateExternalConfigMap(mockMap)
+ mockMap["dubbo.consumer.check"] = "true"
+ config.GetEnvInstance().UpdateAppExternalConfigMap(mockMap)
father := &ConsumerConfig{
Check: &[]bool{true}[0],
BaseConfig: BaseConfig{
@@ -204,6 +206,7 @@
mockMap["dubbo.application.name"] = "dubbo"
config.GetEnvInstance().UpdateExternalConfigMap(mockMap)
+ config.GetEnvInstance().UpdateAppExternalConfigMap(map[string]string{})
father := &ConsumerConfig{
Check: &[]bool{true}[0],
@@ -235,6 +238,7 @@
mockMap["dubbo.protocols.jsonrpc1.port"] = "20001"
config.GetEnvInstance().UpdateExternalConfigMap(mockMap)
+ config.GetEnvInstance().UpdateAppExternalConfigMap(map[string]string{})
father := &ProviderConfig{
BaseConfig: BaseConfig{
diff --git a/config/config_api_test.go b/config/config_api_test.go
index fd8d561..c0bba78 100644
--- a/config/config_api_test.go
+++ b/config/config_api_test.go
@@ -160,18 +160,14 @@
assert.Equal(t, v, serviceConfig)
}
assert.NotNil(t, testProviderConfig.Registries)
- i := 0
- for k, v := range testProviderConfig.Registries {
- if i == 0 {
- assert.Equal(t, k, "demoConsul")
- assert.Equal(t, v, defaultConsulRegistry)
- i++
- } else {
- assert.Equal(t, k, "demoNacos")
- assert.Equal(t, v, defaultNacosRegistry)
- }
+
+ if registry, ok := testProviderConfig.Registries["demoConsul"]; ok {
+ assert.Equal(t, registry, defaultConsulRegistry)
}
+ 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 940b7be..90ad972 100644
--- a/config/config_center_config.go
+++ b/config/config_center_config.go
@@ -44,7 +44,7 @@
//
// ConfigCenter has currently supported Zookeeper, Nacos, Etcd, Consul, Apollo
type ConfigCenterConfig struct {
- //context context.Context
+ // context context.Context
Protocol string `required:"true" yaml:"protocol" json:"protocol,omitempty"`
Address string `yaml:"address" json:"address,omitempty"`
Cluster string `yaml:"cluster" json:"cluster,omitempty"`
@@ -58,7 +58,7 @@
AppId string `default:"dubbo" yaml:"app_id" json:"app_id,omitempty"`
TimeoutStr string `yaml:"timeout" json:"timeout,omitempty"`
RemoteRef string `required:"false" yaml:"remote_ref" json:"remote_ref,omitempty"`
- //timeout time.Duration
+ // timeout time.Duration
}
// UnmarshalYAML unmarshals the ConfigCenterConfig by @unmarshal function
@@ -81,8 +81,7 @@
return urlMap
}
-type configCenter struct {
-}
+type configCenter struct{}
// toURL will compatible with baseConfig.ConfigCenterConfig.Address and baseConfig.ConfigCenterConfig.RemoteRef before 1.6.0
// After 1.6.0 will not compatible, only baseConfig.ConfigCenterConfig.RemoteRef
@@ -162,11 +161,11 @@
// appGroup config file
if len(appContent) != 0 {
- appMapConent, err := dynamicConfig.Parser().Parse(appContent)
+ appMapContent, err := dynamicConfig.Parser().Parse(appContent)
if err != nil {
return perrors.WithStack(err)
}
- config.GetEnvInstance().UpdateAppExternalConfigMap(appMapConent)
+ config.GetEnvInstance().UpdateAppExternalConfigMap(appMapContent)
}
return nil
diff --git a/config/config_center_config_test.go b/config/config_center_config_test.go
index 2299167..58faff3 100644
--- a/config/config_center_config_test.go
+++ b/config/config_center_config_test.go
@@ -62,7 +62,8 @@
Group: "dubbo",
RemoteRef: "mock",
ConfigFile: "mockDubbo.properties",
- }}
+ },
+ }
c := &configCenter{}
err := c.startConfigCenter(*baseConfig)
@@ -85,7 +86,8 @@
Group: "dubbo",
RemoteRef: "mock",
ConfigFile: "mockDubbo.properties",
- }}
+ },
+ }
c := &configCenter{}
err := c.startConfigCenter(*baseConfig)
diff --git a/config/config_loader.go b/config/config_loader.go
index 12f57ee..bb1069c 100644
--- a/config/config_loader.go
+++ b/config/config_loader.go
@@ -20,6 +20,7 @@
import (
"flag"
"fmt"
+ "io/ioutil"
"log"
"os"
"reflect"
@@ -38,6 +39,7 @@
"github.com/apache/dubbo-go/common/extension"
"github.com/apache/dubbo-go/common/logger"
_ "github.com/apache/dubbo-go/common/observer/dispatcher"
+ "github.com/apache/dubbo-go/common/yaml"
"github.com/apache/dubbo-go/registry"
)
@@ -72,11 +74,25 @@
for len(fs.Args()) != 0 {
fs.Parse(fs.Args()[1:])
}
+ // If user did not set the environment variables or flags,
+ // we provide default value
+ if confConFile == "" {
+ confConFile = constant.DEFAULT_CONSUMER_CONF_FILE_PATH
+ }
+ if confProFile == "" {
+ confProFile = constant.DEFAULT_PROVIDER_CONF_FILE_PATH
+ }
+ if confRouterFile == "" {
+ confRouterFile = constant.DEFAULT_ROUTER_CONF_FILE_PATH
+ }
if errCon := ConsumerInit(confConFile); errCon != nil {
log.Printf("[consumerInit] %#v", errCon)
consumerConfig = nil
} else {
+ // Check if there are some important key fields missing,
+ // if so, we set a default value for it
+ setDefaultValue(consumerConfig)
// Even though baseConfig has been initialized, we override it
// because we think read from config file is correct config
baseConfig = &consumerConfig.BaseConfig
@@ -86,12 +102,48 @@
log.Printf("[providerInit] %#v", errPro)
providerConfig = nil
} else {
+ // Check if there are some important key fields missing,
+ // if so, we set a default value for it
+ setDefaultValue(providerConfig)
// Even though baseConfig has been initialized, we override it
// because we think read from config file is correct config
baseConfig = &providerConfig.BaseConfig
}
}
+// setDefaultValue set default value for providerConfig or consumerConfig if it is null
+func setDefaultValue(target interface{}) {
+ registryConfig := &RegistryConfig{
+ Protocol: "zookeeper",
+ TimeoutStr: "3s",
+ Address: "127.0.0.1:2181",
+ }
+ switch target.(type) {
+ case *ProviderConfig:
+ p := target.(*ProviderConfig)
+ if len(p.Registries) == 0 {
+ p.Registries["demoZK"] = registryConfig
+ }
+ if len(p.Protocols) == 0 {
+ p.Protocols["dubbo"] = &ProtocolConfig{
+ Name: "dubbo",
+ Port: "20000",
+ }
+ }
+ if p.ApplicationConfig == nil {
+ p.ApplicationConfig = NewDefaultApplicationConfig()
+ }
+ default:
+ c := target.(*ConsumerConfig)
+ if len(c.Registries) == 0 {
+ c.Registries["demoZK"] = registryConfig
+ }
+ if c.ApplicationConfig == nil {
+ c.ApplicationConfig = NewDefaultApplicationConfig()
+ }
+ }
+}
+
func checkRegistries(registries map[string]*RegistryConfig, singleRegistry *RegistryConfig) {
if len(registries) == 0 && singleRegistry != nil {
registries[constant.DEFAULT_KEY] = singleRegistry
@@ -144,6 +196,17 @@
ref.Implement(rpcService)
}
+ // Write current configuration to cache file.
+ if consumerConfig.CacheFile != "" {
+ if data, err := yaml.MarshalYML(consumerConfig); err != nil {
+ logger.Errorf("Marshal consumer config err: %s", err.Error())
+ } else {
+ if err := ioutil.WriteFile(consumerConfig.CacheFile, data, 0o666); err != nil {
+ logger.Errorf("Write consumer config cache file err: %s", err.Error())
+ }
+ }
+ }
+
// wait for invoker is available, if wait over default 3s, then panic
var count int
for {
@@ -200,6 +263,17 @@
}
checkRegistries(providerConfig.Registries, providerConfig.Registry)
+ // Write the current configuration to cache file.
+ if providerConfig.CacheFile != "" {
+ if data, err := yaml.MarshalYML(providerConfig); err != nil {
+ logger.Errorf("Marshal provider config err: %s", err.Error())
+ } else {
+ if err := ioutil.WriteFile(providerConfig.CacheFile, data, 0o666); err != nil {
+ logger.Errorf("Write provider config cache file err: %s", err.Error())
+ }
+ }
+ }
+
for key, svs := range providerConfig.Services {
rpcService := GetProviderService(key)
if rpcService == nil {
@@ -313,7 +387,6 @@
// Load Dubbo Init
func Load() {
-
// init router
initRouter()
@@ -424,9 +497,11 @@
func GetSslEnabled() bool {
return sslEnabled
}
+
func SetSslEnabled(enabled bool) {
sslEnabled = enabled
}
+
func IsProvider() bool {
return providerConfig != nil
}
diff --git a/config/config_loader_test.go b/config/config_loader_test.go
index 5cda3b2..c43a4ae 100644
--- a/config/config_loader_test.go
+++ b/config/config_loader_test.go
@@ -45,8 +45,10 @@
"github.com/apache/dubbo-go/registry"
)
-const mockConsumerConfigPath = "./testdata/consumer_config.yml"
-const mockProviderConfigPath = "./testdata/provider_config.yml"
+const (
+ mockConsumerConfigPath = "./testdata/consumer_config.yml"
+ mockProviderConfigPath = "./testdata/provider_config.yml"
+)
func TestConfigLoader(t *testing.T) {
conPath, err := filepath.Abs(mockConsumerConfigPath)
@@ -191,6 +193,26 @@
providerConfig = nil
}
+func TestSetDefaultValue(t *testing.T) {
+ proConfig := &ProviderConfig{Registries: make(map[string]*RegistryConfig), Protocols: make(map[string]*ProtocolConfig)}
+ assert.Nil(t, proConfig.ApplicationConfig)
+ setDefaultValue(proConfig)
+ assert.Equal(t, proConfig.Registries["demoZK"].Address, "127.0.0.1:2181")
+ assert.Equal(t, proConfig.Registries["demoZK"].TimeoutStr, "3s")
+ assert.Equal(t, proConfig.Registries["demoZK"].Protocol, "zookeeper")
+ assert.Equal(t, proConfig.Protocols["dubbo"].Name, "dubbo")
+ assert.Equal(t, proConfig.Protocols["dubbo"].Port, "20000")
+ assert.NotNil(t, proConfig.ApplicationConfig)
+
+ conConfig := &ConsumerConfig{Registries: make(map[string]*RegistryConfig)}
+ assert.Nil(t, conConfig.ApplicationConfig)
+ setDefaultValue(conConfig)
+ assert.Equal(t, conConfig.Registries["demoZK"].Address, "127.0.0.1:2181")
+ assert.Equal(t, conConfig.Registries["demoZK"].TimeoutStr, "3s")
+ assert.Equal(t, conConfig.Registries["demoZK"].Protocol, "zookeeper")
+ assert.NotNil(t, conConfig.ApplicationConfig)
+
+}
func TestConfigLoaderWithConfigCenter(t *testing.T) {
extension.SetConfigCenterFactory("mock", func() config_center.DynamicConfigurationFactory {
return &config_center.MockDynamicConfigurationFactory{}
@@ -222,7 +244,6 @@
assert.Equal(t, "BDTService", consumerConfig.ApplicationConfig.Name)
assert.Equal(t, "127.0.0.1:2181", consumerConfig.Registries["hangzhouzk"].Address)
-
}
func TestConfigLoaderWithConfigCenterSingleRegistry(t *testing.T) {
@@ -281,7 +302,6 @@
assert.Equal(t, "BDTService", consumerConfig.ApplicationConfig.Name)
assert.Equal(t, "mock://127.0.0.1:2182", consumerConfig.Registries[constant.DEFAULT_KEY].Address)
-
}
func TestGetBaseConfig(t *testing.T) {
@@ -301,7 +321,8 @@
Module: "module",
Version: "1.0.0",
Owner: "dubbo",
- Environment: "test"},
+ Environment: "test",
+ },
},
Registry: &RegistryConfig{
@@ -452,8 +473,7 @@
return res
}
-type mockServiceDiscoveryRegistry struct {
-}
+type mockServiceDiscoveryRegistry struct{}
func (mr *mockServiceDiscoveryRegistry) GetUrl() *common.URL {
panic("implement me")
@@ -487,8 +507,7 @@
return &mockServiceDiscovery{}
}
-type mockServiceDiscovery struct {
-}
+type mockServiceDiscovery struct{}
func (m *mockServiceDiscovery) String() string {
panic("implement me")
diff --git a/config/consumer_config.go b/config/consumer_config.go
index ff53366..39c0e96 100644
--- a/config/consumer_config.go
+++ b/config/consumer_config.go
@@ -43,9 +43,9 @@
// ConsumerConfig is Consumer default configuration
type ConsumerConfig struct {
- BaseConfig `yaml:",inline"`
- configCenter
- Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"`
+ BaseConfig `yaml:",inline"`
+ configCenter `yaml:"-"`
+ Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"`
// client
Connect_Timeout string `default:"100ms" yaml:"connect_timeout" json:"connect_timeout,omitempty" property:"connect_timeout"`
ConnectTimeout time.Duration
@@ -95,9 +95,9 @@
return perrors.Errorf("unmarshalYmlConfig error %v", perrors.WithStack(err))
}
consumerConfig.fileStream = bytes.NewBuffer(fileStream)
- //set method interfaceId & interfaceName
+ // set method interfaceId & interfaceName
for k, v := range consumerConfig.References {
- //set id for reference
+ // set id for reference
for _, n := range consumerConfig.References[k].Methods {
n.InterfaceName = v.InterfaceName
n.InterfaceId = k
@@ -124,7 +124,7 @@
}
func configCenterRefreshConsumer() error {
- //fresh it
+ // fresh it
var err error
if consumerConfig.Request_Timeout != "" {
if consumerConfig.RequestTimeout, err = time.ParseDuration(consumerConfig.Request_Timeout); err != nil {
diff --git a/config/graceful_shutdown.go b/config/graceful_shutdown.go
index 89ac2e3..83204c8 100644
--- a/config/graceful_shutdown.go
+++ b/config/graceful_shutdown.go
@@ -55,7 +55,6 @@
// nolint
func GracefulShutdownInit() {
-
signals := make(chan os.Signal, 1)
signal.Notify(signals, ShutdownSignals...)
@@ -83,7 +82,6 @@
// BeforeShutdown provides processing flow before shutdown
func BeforeShutdown() {
-
destroyAllRegistries()
// waiting for a short time so that the clients have enough time to get the notification that server shutdowns
// The value of configuration depends on how long the clients will get notification.
@@ -127,7 +125,6 @@
// destroyProviderProtocols destroys the provider's protocol.
// if the protocol is consumer's protocol too, we will keep it
func destroyProviderProtocols(consumerProtocols *gxset.HashSet) {
-
logger.Info("Graceful shutdown --- Destroy provider's protocols. ")
if providerConfig == nil || providerConfig.Protocols == nil {
@@ -145,7 +142,6 @@
}
func waitAndAcceptNewRequests() {
-
logger.Info("Graceful shutdown --- Keep waiting and accept new requests for a short time. ")
if providerConfig == nil || providerConfig.ShutdownConfig == nil {
return
@@ -194,7 +190,7 @@
}
func totalTimeout() time.Duration {
- var providerShutdown = defaultShutDownTime
+ providerShutdown := defaultShutDownTime
if providerConfig != nil && providerConfig.ShutdownConfig != nil {
providerShutdown = providerConfig.ShutdownConfig.GetTimeout()
}
@@ -204,7 +200,7 @@
consumerShutdown = consumerConfig.ShutdownConfig.GetTimeout()
}
- var timeout = providerShutdown
+ timeout := providerShutdown
if consumerShutdown > providerShutdown {
timeout = consumerShutdown
}
diff --git a/config/graceful_shutdown_signal_darwin.go b/config/graceful_shutdown_signal_darwin.go
index 1a557dd..9b694b5 100644
--- a/config/graceful_shutdown_signal_darwin.go
+++ b/config/graceful_shutdown_signal_darwin.go
@@ -24,11 +24,15 @@
var (
// ShutdownSignals receives shutdown signals to process
- ShutdownSignals = []os.Signal{os.Interrupt, os.Kill, syscall.SIGKILL, syscall.SIGSTOP,
+ ShutdownSignals = []os.Signal{
+ os.Interrupt, os.Kill, syscall.SIGKILL, syscall.SIGSTOP,
syscall.SIGHUP, syscall.SIGINT, syscall.SIGQUIT, syscall.SIGILL, syscall.SIGTRAP,
- syscall.SIGABRT, syscall.SIGSYS, syscall.SIGTERM}
+ syscall.SIGABRT, syscall.SIGSYS, syscall.SIGTERM,
+ }
// DumpHeapShutdownSignals receives shutdown signals to process
- DumpHeapShutdownSignals = []os.Signal{syscall.SIGQUIT, syscall.SIGILL,
- syscall.SIGTRAP, syscall.SIGABRT, syscall.SIGSYS}
+ DumpHeapShutdownSignals = []os.Signal{
+ syscall.SIGQUIT, syscall.SIGILL,
+ syscall.SIGTRAP, syscall.SIGABRT, syscall.SIGSYS,
+ }
)
diff --git a/config/graceful_shutdown_signal_linux.go b/config/graceful_shutdown_signal_linux.go
index 1a557dd..9b694b5 100644
--- a/config/graceful_shutdown_signal_linux.go
+++ b/config/graceful_shutdown_signal_linux.go
@@ -24,11 +24,15 @@
var (
// ShutdownSignals receives shutdown signals to process
- ShutdownSignals = []os.Signal{os.Interrupt, os.Kill, syscall.SIGKILL, syscall.SIGSTOP,
+ ShutdownSignals = []os.Signal{
+ os.Interrupt, os.Kill, syscall.SIGKILL, syscall.SIGSTOP,
syscall.SIGHUP, syscall.SIGINT, syscall.SIGQUIT, syscall.SIGILL, syscall.SIGTRAP,
- syscall.SIGABRT, syscall.SIGSYS, syscall.SIGTERM}
+ syscall.SIGABRT, syscall.SIGSYS, syscall.SIGTERM,
+ }
// DumpHeapShutdownSignals receives shutdown signals to process
- DumpHeapShutdownSignals = []os.Signal{syscall.SIGQUIT, syscall.SIGILL,
- syscall.SIGTRAP, syscall.SIGABRT, syscall.SIGSYS}
+ DumpHeapShutdownSignals = []os.Signal{
+ syscall.SIGQUIT, syscall.SIGILL,
+ syscall.SIGTRAP, syscall.SIGABRT, syscall.SIGSYS,
+ }
)
diff --git a/config/graceful_shutdown_signal_windows.go b/config/graceful_shutdown_signal_windows.go
index 89edd27..17c209e 100644
--- a/config/graceful_shutdown_signal_windows.go
+++ b/config/graceful_shutdown_signal_windows.go
@@ -24,9 +24,11 @@
var (
// ShutdownSignals receives shutdown signals to process
- ShutdownSignals = []os.Signal{os.Interrupt, os.Kill, syscall.SIGKILL,
+ ShutdownSignals = []os.Signal{
+ os.Interrupt, os.Kill, syscall.SIGKILL,
syscall.SIGHUP, syscall.SIGINT, syscall.SIGQUIT, syscall.SIGILL, syscall.SIGTRAP,
- syscall.SIGABRT, syscall.SIGTERM}
+ syscall.SIGABRT, syscall.SIGTERM,
+ }
// DumpHeapShutdownSignals receives shutdown signals to process
DumpHeapShutdownSignals = []os.Signal{syscall.SIGQUIT, syscall.SIGILL, syscall.SIGTRAP, syscall.SIGABRT}
diff --git a/config/graceful_shutdown_test.go b/config/graceful_shutdown_test.go
index de20357..851ec75 100644
--- a/config/graceful_shutdown_test.go
+++ b/config/graceful_shutdown_test.go
@@ -57,7 +57,8 @@
ShutdownConfig: &ShutdownConfig{
Timeout: "1",
StepTimeout: "1s",
- }}
+ },
+ }
providerProtocols := map[string]*ProtocolConfig{}
providerProtocols[constant.DUBBO] = &ProtocolConfig{
diff --git a/config/instance/metadata_report_test.go b/config/instance/metadata_report_test.go
index 110903a..7d4a93a 100644
--- a/config/instance/metadata_report_test.go
+++ b/config/instance/metadata_report_test.go
@@ -42,15 +42,13 @@
assert.NotNil(t, rpt)
}
-type mockMetadataReportFactory struct {
-}
+type mockMetadataReportFactory struct{}
func (m *mockMetadataReportFactory) CreateMetadataReport(*common.URL) report.MetadataReport {
return &mockMetadataReport{}
}
-type mockMetadataReport struct {
-}
+type mockMetadataReport struct{}
func (m mockMetadataReport) StoreProviderMetadata(*identifier.MetadataIdentifier, string) error {
panic("implement me")
diff --git a/config/metric_config.go b/config/metric_config.go
index 73a3ca1..9af1691 100644
--- a/config/metric_config.go
+++ b/config/metric_config.go
@@ -17,9 +17,7 @@
package config
-var (
- defaultHistogramBucket = []float64{10, 50, 100, 200, 500, 1000, 10000}
-)
+var defaultHistogramBucket = []float64{10, 50, 100, 200, 500, 1000, 10000}
// This is the config struct for all metrics implementation
type MetricConfig struct {
diff --git a/config/provider_config.go b/config/provider_config.go
index 0aee560..4113aab 100644
--- a/config/provider_config.go
+++ b/config/provider_config.go
@@ -37,8 +37,8 @@
// ProviderConfig is the default configuration of service provider
type ProviderConfig struct {
- BaseConfig `yaml:",inline"`
- configCenter
+ BaseConfig `yaml:",inline"`
+ configCenter `yaml:"-"`
Filter string `yaml:"filter" json:"filter,omitempty" property:"filter"`
ProxyFactory string `yaml:"proxy_factory" default:"default" json:"proxy_factory,omitempty" property:"proxy_factory"`
Services map[string]*ServiceConfig `yaml:"services" json:"services,omitempty" property:"services"`
diff --git a/config/reference_config.go b/config/reference_config.go
index f71c7ec..a97018a 100644
--- a/config/reference_config.go
+++ b/config/reference_config.go
@@ -194,7 +194,7 @@
func (c *ReferenceConfig) getUrlMap() url.Values {
urlMap := url.Values{}
- //first set user params
+ // first set user params
for k, v := range c.Params {
urlMap.Set(k, v)
}
@@ -215,11 +215,11 @@
if len(c.RequestTimeout) != 0 {
urlMap.Set(constant.TIMEOUT_KEY, c.RequestTimeout)
}
- //getty invoke async or sync
+ // getty invoke async or sync
urlMap.Set(constant.ASYNC_KEY, strconv.FormatBool(c.Async))
urlMap.Set(constant.STICKY_KEY, strconv.FormatBool(c.Sticky))
- //application info
+ // application info
urlMap.Set(constant.APPLICATION_KEY, consumerConfig.ApplicationConfig.Name)
urlMap.Set(constant.ORGANIZATION_KEY, consumerConfig.ApplicationConfig.Organization)
urlMap.Set(constant.NAME_KEY, consumerConfig.ApplicationConfig.Name)
@@ -228,8 +228,8 @@
urlMap.Set(constant.OWNER_KEY, consumerConfig.ApplicationConfig.Owner)
urlMap.Set(constant.ENVIRONMENT_KEY, consumerConfig.ApplicationConfig.Environment)
- //filter
- var defaultReferenceFilter = constant.DEFAULT_REFERENCE_FILTERS
+ // filter
+ defaultReferenceFilter := constant.DEFAULT_REFERENCE_FILTERS
if c.Generic {
defaultReferenceFilter = constant.GENERIC_REFERENCE_FILTERS + "," + defaultReferenceFilter
}
diff --git a/config/reference_config_test.go b/config/reference_config_test.go
index 0207e1f..f47bb4b 100644
--- a/config/reference_config_test.go
+++ b/config/reference_config_test.go
@@ -46,7 +46,8 @@
Module: "module",
Version: "2.6.0",
Owner: "dubbo",
- Environment: "test"},
+ Environment: "test",
+ },
},
Registries: map[string]*RegistryConfig{
@@ -120,8 +121,7 @@
var mockProvider = new(MockProvider)
-type MockProvider struct {
-}
+type MockProvider struct{}
func (m *MockProvider) Reference() string {
return "MockProvider"
@@ -148,7 +148,8 @@
Module: "module",
Version: "2.6.0",
Owner: "dubbo",
- Environment: "test"},
+ Environment: "test",
+ },
},
Registry: &RegistryConfig{
@@ -359,6 +360,7 @@
func (*mockRegistryProtocol) Destroy() {
// Destroy is a mock function
}
+
func getRegistryUrl(invoker protocol.Invoker) *common.URL {
// here add * for return a new url
url := invoker.GetUrl()
diff --git a/config/registry_config.go b/config/registry_config.go
index ed81a07..462e3b8 100644
--- a/config/registry_config.go
+++ b/config/registry_config.go
@@ -129,7 +129,7 @@
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.ZONE_FORCE_KEY, strconv.FormatBool(c.ZoneForce))
+ // urlMap.Set(constant.REGISTRY_KEY+"."+constant.ZONE_FORCE_KEY, strconv.FormatBool(c.ZoneForce))
urlMap.Set(constant.REGISTRY_KEY+"."+constant.WEIGHT_KEY, strconv.FormatInt(c.Weight, 10))
urlMap.Set(constant.REGISTRY_TTL_KEY, c.TTL)
for k, v := range c.Params {
diff --git a/config/remote_config_test.go b/config/remote_config_test.go
index 82535fd..cd21369 100644
--- a/config/remote_config_test.go
+++ b/config/remote_config_test.go
@@ -20,6 +20,7 @@
import (
"testing"
)
+
import (
"github.com/stretchr/testify/assert"
)
diff --git a/config/router_config.go b/config/router_config.go
index ea19b46..06758b4 100644
--- a/config/router_config.go
+++ b/config/router_config.go
@@ -29,9 +29,7 @@
"github.com/apache/dubbo-go/common/yaml"
)
-var (
- routerURLSet = gxset.NewSet()
-)
+var routerURLSet = gxset.NewSet()
// LocalRouterRules defines the local router config structure
type LocalRouterRules struct {
diff --git a/config/router_config_test.go b/config/router_config_test.go
index 13af705..d2acf9d 100644
--- a/config/router_config_test.go
+++ b/config/router_config_test.go
@@ -31,12 +31,13 @@
_ "github.com/apache/dubbo-go/cluster/router/condition"
)
-const testYML = "testdata/router_config.yml"
-const testMultiRouterYML = "testdata/router_multi_config.yml"
-const errorTestYML = "testdata/router_config_error.yml"
+const (
+ testYML = "testdata/router_config.yml"
+ testMultiRouterYML = "testdata/router_multi_config.yml"
+ errorTestYML = "testdata/router_config_error.yml"
+)
func TestString(t *testing.T) {
-
s := "a1=>a2"
s1 := "=>a2"
s2 := "a1=>"
diff --git a/config/service.go b/config/service.go
index b746141..6deff3b 100644
--- a/config/service.go
+++ b/config/service.go
@@ -46,6 +46,11 @@
return proServices[name]
}
+// GetAllProviderService gets all ProviderService
+func GetAllProviderService() map[string]common.RPCService {
+ return proServices
+}
+
// GetCallback gets CallbackResponse by @name
func GetCallback(name string) func(response common.CallbackResponse) {
service := GetConsumerService(name)
diff --git a/config/service_config_test.go b/config/service_config_test.go
index aea0bde..76800d9 100644
--- a/config/service_config_test.go
+++ b/config/service_config_test.go
@@ -18,8 +18,9 @@
package config
import (
- "github.com/apache/dubbo-go/common"
"testing"
+
+ "github.com/apache/dubbo-go/common"
)
import (
@@ -195,7 +196,7 @@
protocolConfigs = append(protocolConfigs, &ProtocolConfig{
Ip: ip,
})
- //assert.NoError(t, err)
+ // assert.NoError(t, err)
ports := getRandomPort(protocolConfigs)
assert.Equal(t, ports.Len(), len(protocolConfigs))
diff --git a/config_center/apollo/factory.go b/config_center/apollo/factory.go
index c52d942..e3a8364 100644
--- a/config_center/apollo/factory.go
+++ b/config_center/apollo/factory.go
@@ -42,5 +42,4 @@
}
dynamicConfiguration.SetParser(&parser.DefaultConfigurationParser{})
return dynamicConfiguration, err
-
}
diff --git a/config_center/apollo/impl_test.go b/config_center/apollo/impl_test.go
index 3b2cb16..8f4c315 100644
--- a/config_center/apollo/impl_test.go
+++ b/config_center/apollo/impl_test.go
@@ -59,8 +59,7 @@
}]`
)
-var (
- mockConfigRes = `{
+var mockConfigRes = `{
"appId": "testApplication_yang",
"cluster": "default",
"namespaceName": "mockDubbog.properties",
@@ -116,7 +115,6 @@
},
"releaseKey": "20191104105242-0f13805d89f834a4"
}`
-)
func initApollo() *httptest.Server {
handlerMap := make(map[string]func(http.ResponseWriter, *http.Request), 1)
@@ -215,13 +213,13 @@
},
"releaseKey": "20191104105242-0f13805d89f834a4"
}`
- //test add
+ // test add
apollo.AddListener(mockNamespace, listener)
listener.wg.Wait()
assert.Equal(t, "mockDubbog.properties", listener.event)
assert.Greater(t, listener.count, 0)
- //test remove
+ // test remove
apollo.RemoveListener(mockNamespace, listener)
listenerCount := 0
apollo.listeners.Range(func(_, value interface{}) bool {
diff --git a/config_center/apollo/listener.go b/config_center/apollo/listener.go
index 44d3255..215c74d 100644
--- a/config_center/apollo/listener.go
+++ b/config_center/apollo/listener.go
@@ -42,7 +42,6 @@
// OnChange process each listener
func (a *apolloListener) OnChange(changeEvent *storage.ChangeEvent) {
-
}
// OnNewestChange process each listener by all changes
diff --git a/config_center/base_dynamic_configuration.go b/config_center/base_dynamic_configuration.go
index 3d67578..b56ada1 100644
--- a/config_center/base_dynamic_configuration.go
+++ b/config_center/base_dynamic_configuration.go
@@ -18,8 +18,7 @@
package config_center
// BaseDynamicConfiguration will default implementation DynamicConfiguration some method
-type BaseDynamicConfiguration struct {
-}
+type BaseDynamicConfiguration struct{}
// RemoveConfig
func (bdc *BaseDynamicConfiguration) RemoveConfig(string, string) error {
diff --git a/config_center/configurator/override_test.go b/config_center/configurator/override_test.go
index 4d2552d..a7fced0 100644
--- a/config_center/configurator/override_test.go
+++ b/config_center/configurator/override_test.go
@@ -71,7 +71,6 @@
assert.NoError(t, err)
configurator.Configure(providerUrl)
assert.Equal(t, failfast, providerUrl.GetParam(constant.CLUSTER_KEY, ""))
-
}
func TestConfigureVersion2p7(t *testing.T) {
@@ -83,5 +82,4 @@
assert.NoError(t, err)
configurator.Configure(providerUrl)
assert.Equal(t, failfast, providerUrl.GetParam(constant.CLUSTER_KEY, ""))
-
}
diff --git a/config_center/file/factory.go b/config_center/file/factory.go
index 2dda900..5dc8be1 100644
--- a/config_center/file/factory.go
+++ b/config_center/file/factory.go
@@ -35,8 +35,7 @@
})
}
-type fileDynamicConfigurationFactory struct {
-}
+type fileDynamicConfigurationFactory struct{}
// GetDynamicConfiguration Get Configuration with URL
func (f *fileDynamicConfigurationFactory) GetDynamicConfiguration(url *common.URL) (config_center.DynamicConfiguration,
diff --git a/config_center/file/impl.go b/config_center/file/impl.go
index 6489a07..112b0bb 100644
--- a/config_center/file/impl.go
+++ b/config_center/file/impl.go
@@ -40,9 +40,7 @@
"github.com/apache/dubbo-go/config_center/parser"
)
-var (
- osType = runtime.GOOS
-)
+var osType = runtime.GOOS
const (
windowsOS = "windows"
diff --git a/config_center/file/listener.go b/config_center/file/listener.go
index d569030..8e7aa61 100644
--- a/config_center/file/listener.go
+++ b/config_center/file/listener.go
@@ -128,7 +128,8 @@
// reference from https://stackoverflow.com/questions/34018908/golang-why-dont-we-have-a-set-datastructure
// make a map[your type]struct{} like set in java
listeners, loaded := cl.keyListeners.LoadOrStore(key, map[config_center.ConfigurationListener]struct{}{
- listener: {}})
+ listener: {},
+ })
if loaded {
listeners.(map[config_center.ConfigurationListener]struct{})[listener] = struct{}{}
cl.keyListeners.Store(key, listeners)
diff --git a/config_center/mock_dynamic_config.go b/config_center/mock_dynamic_config.go
index 9bebd60..5688499 100644
--- a/config_center/mock_dynamic_config.go
+++ b/config_center/mock_dynamic_config.go
@@ -83,7 +83,6 @@
dynamicConfiguration.content = f.Content
}
return dynamicConfiguration, err
-
}
// PublishConfig will publish the config with the (key, group, value) pair
@@ -116,7 +115,6 @@
// GetConfig returns content of MockDynamicConfiguration
func (c *MockDynamicConfiguration) GetConfig(_ string, _ ...Option) (string, error) {
-
return c.content, nil
}
@@ -158,7 +156,8 @@
Key: mockServiceName,
Enabled: true,
Configs: []parser.ConfigItem{
- {Type: parser.GeneralType,
+ {
+ Type: parser.GeneralType,
Enabled: true,
Addresses: []string{"0.0.0.0"},
Services: []string{mockServiceName},
@@ -180,7 +179,8 @@
Key: mockServiceName,
Enabled: true,
Configs: []parser.ConfigItem{
- {Type: parser.ScopeApplication,
+ {
+ Type: parser.ScopeApplication,
Enabled: true,
Addresses: []string{"0.0.0.0"},
Services: []string{mockServiceName},
diff --git a/config_center/nacos/client.go b/config_center/nacos/client.go
index 1e96b36..d6af806 100644
--- a/config_center/nacos/client.go
+++ b/config_center/nacos/client.go
@@ -65,7 +65,7 @@
type options struct {
nacosName string
- //client *NacosClient
+ // client *NacosClient
}
// WithNacosName Set nacos name
@@ -94,7 +94,7 @@
}
nacosAddresses := strings.Split(url.Location, ",")
if container.NacosClient() == nil {
- //in dubbo ,every registry only connect one node ,so this is []string{r.Address}
+ // in dubbo ,every registry only connect one node ,so this is []string{r.Address}
newClient, err := newNacosClient(os.nacosName, nacosAddresses, timeout, url)
if err != nil {
logger.Errorf("newNacosClient(name{%s}, nacos address{%v}, timeout{%d}) = error{%v}",
diff --git a/config_center/nacos/facade.go b/config_center/nacos/facade.go
index d089ed2..b81c224 100644
--- a/config_center/nacos/facade.go
+++ b/config_center/nacos/facade.go
@@ -21,6 +21,7 @@
"sync"
"time"
)
+
import (
"github.com/apache/dubbo-getty"
perrors "github.com/pkg/errors"
diff --git a/config_center/nacos/factory.go b/config_center/nacos/factory.go
index 3de91ea..da06abd 100644
--- a/config_center/nacos/factory.go
+++ b/config_center/nacos/factory.go
@@ -28,8 +28,7 @@
extension.SetConfigCenterFactory("nacos", func() config_center.DynamicConfigurationFactory { return &nacosDynamicConfigurationFactory{} })
}
-type nacosDynamicConfigurationFactory struct {
-}
+type nacosDynamicConfigurationFactory struct{}
// GetDynamicConfiguration Get Configuration with URL
func (f *nacosDynamicConfigurationFactory) GetDynamicConfiguration(url *common.URL) (config_center.DynamicConfiguration, error) {
@@ -39,5 +38,4 @@
}
dynamicConfiguration.SetParser(&parser.DefaultConfigurationParser{})
return dynamicConfiguration, err
-
}
diff --git a/config_center/nacos/impl.go b/config_center/nacos/impl.go
index 7c67930..8e56d23 100644
--- a/config_center/nacos/impl.go
+++ b/config_center/nacos/impl.go
@@ -72,7 +72,6 @@
c.wg.Add(1)
go HandleClientRestart(c)
return c, err
-
}
// AddListener Add listener
@@ -97,7 +96,6 @@
// PublishConfig will publish the config with the (key, group, value) pair
func (n *nacosDynamicConfiguration) PublishConfig(key string, group string, value string) error {
-
group = n.resolvedGroup(group)
ok, err := (*n.client.Client()).PublishConfig(vo.ConfigParam{
@@ -105,7 +103,6 @@
Group: group,
Content: value,
})
-
if err != nil {
return perrors.WithStack(err)
}
diff --git a/config_center/nacos/impl_test.go b/config_center/nacos/impl_test.go
index b7bd94b..0372a6c 100644
--- a/config_center/nacos/impl_test.go
+++ b/config_center/nacos/impl_test.go
@@ -117,7 +117,6 @@
assert.Nil(t, err)
assert.Equal(t, 1, configs.Size())
assert.True(t, configs.Contains("application"))
-
}
func TestNacosDynamicConfigurationPublishConfig(t *testing.T) {
@@ -139,7 +138,7 @@
}
func TestRemoveListener(_ *testing.T) {
- //TODO not supported in current go_nacos_sdk version
+ // TODO not supported in current go_nacos_sdk version
}
type mockDataListener struct {
diff --git a/config_center/parser/configuration_parser.go b/config_center/parser/configuration_parser.go
index b104d3d..eb811c0 100644
--- a/config_center/parser/configuration_parser.go
+++ b/config_center/parser/configuration_parser.go
@@ -112,7 +112,7 @@
// serviceItemToUrls is used to transfer item and config to urls
func serviceItemToUrls(item ConfigItem, config ConfiguratorConfig) ([]*common.URL, error) {
- var addresses = item.Addresses
+ addresses := item.Addresses
if len(addresses) == 0 {
addresses = append(addresses, constant.ANYHOST_VALUE)
}
@@ -159,7 +159,7 @@
// nolint
func appItemToUrls(item ConfigItem, config ConfiguratorConfig) ([]*common.URL, error) {
- var addresses = item.Addresses
+ addresses := item.Addresses
if len(addresses) == 0 {
addresses = append(addresses, constant.ANYHOST_VALUE)
}
diff --git a/config_center/zookeeper/factory.go b/config_center/zookeeper/factory.go
index 3f4690d..8e91972 100644
--- a/config_center/zookeeper/factory.go
+++ b/config_center/zookeeper/factory.go
@@ -28,8 +28,7 @@
extension.SetConfigCenterFactory("zookeeper", func() config_center.DynamicConfigurationFactory { return &zookeeperDynamicConfigurationFactory{} })
}
-type zookeeperDynamicConfigurationFactory struct {
-}
+type zookeeperDynamicConfigurationFactory struct{}
func (f *zookeeperDynamicConfigurationFactory) GetDynamicConfiguration(url *common.URL) (config_center.DynamicConfiguration, error) {
dynamicConfiguration, err := newZookeeperDynamicConfiguration(url)
@@ -38,5 +37,4 @@
}
dynamicConfiguration.SetParser(&parser.DefaultConfigurationParser{})
return dynamicConfiguration, err
-
}
diff --git a/config_center/zookeeper/impl.go b/config_center/zookeeper/impl.go
index f3b2235..082bfbe 100644
--- a/config_center/zookeeper/impl.go
+++ b/config_center/zookeeper/impl.go
@@ -24,6 +24,7 @@
import (
gxset "github.com/dubbogo/gost/container/set"
+ gxzookeeper "github.com/dubbogo/gost/database/kv/zk"
perrors "github.com/pkg/errors"
)
@@ -50,9 +51,9 @@
wg sync.WaitGroup
cltLock sync.Mutex
done chan struct{}
- client *zookeeper.ZookeeperClient
+ client *gxzookeeper.ZookeeperClient
- //listenerLock sync.Mutex
+ // listenerLock sync.Mutex
listener *zookeeper.ZkEventListener
cacheListener *CacheListener
parser parser.ConfigurationParser
@@ -63,7 +64,7 @@
url: url,
rootPath: "/" + url.GetParam(constant.CONFIG_NAMESPACE_KEY, config_center.DEFAULT_GROUP) + "/config",
}
- err := zookeeper.ValidateZookeeperClient(c, zookeeper.WithZkName(ZkClient))
+ err := zookeeper.ValidateZookeeperClient(c, ZkClient)
if err != nil {
logger.Errorf("zookeeper client start error ,error message is %v", err)
return nil, err
@@ -77,7 +78,6 @@
err = c.client.Create(c.rootPath)
c.listener.ListenServiceEvent(url, c.rootPath, c.cacheListener)
return c, err
-
}
func (c *zookeeperDynamicConfiguration) AddListener(key string, listener config_center.ConfigurationListener, opions ...config_center.Option) {
@@ -89,7 +89,6 @@
}
func (c *zookeeperDynamicConfiguration) GetProperties(key string, opts ...config_center.Option) (string, error) {
-
tmpOpts := &config_center.Options{}
for _, opt := range opts {
opt(tmpOpts)
@@ -163,11 +162,11 @@
c.parser = p
}
-func (c *zookeeperDynamicConfiguration) ZkClient() *zookeeper.ZookeeperClient {
+func (c *zookeeperDynamicConfiguration) ZkClient() *gxzookeeper.ZookeeperClient {
return c.client
}
-func (c *zookeeperDynamicConfiguration) SetZkClient(client *zookeeper.ZookeeperClient) {
+func (c *zookeeperDynamicConfiguration) SetZkClient(client *gxzookeeper.ZookeeperClient) {
c.client = client
}
@@ -206,10 +205,9 @@
}
func (c *zookeeperDynamicConfiguration) closeConfigs() {
+ logger.Infof("begin to close provider zk client")
c.cltLock.Lock()
defer c.cltLock.Unlock()
- logger.Infof("begin to close provider zk client")
- // Close the old client first to close the tmp node
c.client.Close()
c.client = nil
}
diff --git a/config_center/zookeeper/impl_test.go b/config_center/zookeeper/impl_test.go
index a518bb6..26d7870 100644
--- a/config_center/zookeeper/impl_test.go
+++ b/config_center/zookeeper/impl_test.go
@@ -81,10 +81,10 @@
dubbo.service.com.ikurento.user.UserProvider.cluster=failover
`
if group != "" {
- err = zreg.client.Create(path.Join(zreg.rootPath, "dubbo", dubboPropertyFileName))
+ err = zreg.client.Create(path.Join(zreg.rootPath, group, dubboPropertyFileName))
assert.NoError(t, err)
- _, err = zreg.client.Conn.Set(path.Join(zreg.rootPath, "dubbo", dubboPropertyFileName), []byte(data), 0)
+ _, err = zreg.client.Conn.Set(path.Join(zreg.rootPath, group, dubboPropertyFileName), []byte(data), 0)
assert.NoError(t, err)
} else {
err = zreg.client.Create(path.Join(zreg.rootPath, dubboPropertyFileName))
@@ -100,6 +100,7 @@
func TestGetConfig(t *testing.T) {
ts, reg := initZkData("dubbo", t)
defer func() {
+ reg.client.Close()
err := ts.Stop()
assert.NoError(t, err)
}()
@@ -122,11 +123,13 @@
func TestAddListener(t *testing.T) {
ts, reg := initZkData("", t)
defer func() {
+ reg.client.Close()
err := ts.Stop()
assert.NoError(t, err)
}()
listener := &mockDataListener{}
reg.AddListener(dubboPropertyFileName, listener)
+
listener.wg.Add(1)
data := `
dubbo.consumer.request_timeout=3s
@@ -158,6 +161,7 @@
func TestRemoveListener(t *testing.T) {
ts, reg := initZkData("", t)
defer func() {
+ reg.client.Close()
err := ts.Stop()
assert.NoError(t, err)
}()
@@ -197,23 +201,23 @@
value := "Test Data"
customGroup := "Custom Group"
key := "myKey"
- ts, zk := initZkData(config_center.DEFAULT_GROUP, t)
+ ts, reg := initZkData(config_center.DEFAULT_GROUP, t)
defer func() {
+ reg.client.Close()
err := ts.Stop()
assert.NoError(t, err)
}()
- err := zk.PublishConfig(key, customGroup, value)
+ err := reg.PublishConfig(key, customGroup, value)
assert.Nil(t, err)
- result, err := zk.GetInternalProperty("myKey", config_center.WithGroup(customGroup))
+ result, err := reg.GetInternalProperty("myKey", config_center.WithGroup(customGroup))
assert.Nil(t, err)
assert.Equal(t, value, result)
var keys *gxset.HashSet
- keys, err = zk.GetConfigKeysByGroup(customGroup)
+ keys, err = reg.GetConfigKeysByGroup(customGroup)
assert.Nil(t, err)
assert.Equal(t, 1, keys.Size())
assert.True(t, keys.Contains(key))
-
}
type mockDataListener struct {
diff --git a/config_center/zookeeper/listener.go b/config_center/zookeeper/listener.go
index bc6eb6d..d93e9d5 100644
--- a/config_center/zookeeper/listener.go
+++ b/config_center/zookeeper/listener.go
@@ -23,6 +23,7 @@
)
import (
+ "github.com/apache/dubbo-go/common/constant"
"github.com/apache/dubbo-go/config_center"
"github.com/apache/dubbo-go/remoting"
)
@@ -40,7 +41,6 @@
// AddListener will add a listener if loaded
func (l *CacheListener) AddListener(key string, listener config_center.ConfigurationListener) {
-
// reference from https://stackoverflow.com/questions/34018908/golang-why-dont-we-have-a-set-datastructure
// make a map[your type]struct{} like set in java
listeners, loaded := l.keyListeners.LoadOrStore(key, map[config_center.ConfigurationListener]struct{}{listener: {}})
@@ -61,7 +61,7 @@
// DataChange changes all listeners' event
func (l *CacheListener) DataChange(event remoting.Event) bool {
if event.Content == "" {
- //meanings new node
+ // meanings new node
return true
}
key := l.pathToKey(event.Path)
@@ -77,5 +77,12 @@
}
func (l *CacheListener) pathToKey(path string) string {
- return strings.Replace(strings.Replace(path, l.rootPath+"/", "", -1), "/", ".", -1)
+ key := strings.Replace(strings.Replace(path, l.rootPath+"/", "", -1), "/", ".", -1)
+ if strings.HasSuffix(key, constant.CONFIGURATORS_SUFFIX) ||
+ strings.HasSuffix(key, constant.TagRouterRuleSuffix) ||
+ strings.HasSuffix(key, constant.ConditionRouterRuleSuffix) {
+ // governance config, so we remove the "dubbo." prefix
+ return key[strings.Index(key, ".")+1:]
+ }
+ return key
}
diff --git a/config_center/zookeeper/listener_test.go b/config_center/zookeeper/listener_test.go
new file mode 100644
index 0000000..a8c0754
--- /dev/null
+++ b/config_center/zookeeper/listener_test.go
@@ -0,0 +1,101 @@
+/*
+ * 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 zookeeper
+
+import (
+ "path"
+ "strconv"
+ "testing"
+)
+
+import (
+ "github.com/dubbogo/go-zookeeper/zk"
+ "github.com/stretchr/testify/assert"
+)
+
+import (
+ "github.com/apache/dubbo-go/common"
+ "github.com/apache/dubbo-go/common/constant"
+ "github.com/apache/dubbo-go/config_center/parser"
+)
+
+func initZkDynamicConfiguration(t *testing.T) (*zk.TestCluster, *zookeeperDynamicConfiguration) {
+ ts, err := zk.StartTestCluster(1, nil, nil)
+ assert.NoError(t, err)
+ assert.NotNil(t, ts.Servers[0])
+ urlString := "registry://127.0.0.1:" + strconv.Itoa(ts.Servers[0].Port)
+ regurl, err := common.NewURL(urlString)
+ assert.NoError(t, err)
+ regurl.AddParam(constant.REGISTRY_TIMEOUT_KEY, "15s")
+ zkFactory := &zookeeperDynamicConfigurationFactory{}
+ reg, err := zkFactory.GetDynamicConfiguration(regurl)
+ zreg, ok := reg.(*zookeeperDynamicConfiguration)
+ assert.True(t, ok)
+ assert.NoError(t, err)
+ assert.True(t, zreg.IsAvailable())
+ assert.Equal(t, zreg.GetUrl(), regurl)
+ assert.True(t, zreg.RestartCallBack())
+ zreg.SetParser(&parser.DefaultConfigurationParser{})
+
+ data := `
+ dubbo.application.name=dubbogo
+`
+ err = zreg.client.Create(path.Join(zreg.rootPath, dubboPropertyFileName))
+ assert.NoError(t, err)
+ _, err = zreg.client.Conn.Set(path.Join(zreg.rootPath, dubboPropertyFileName), []byte(data), 0)
+ assert.NoError(t, err)
+
+ return ts, zreg
+}
+
+func TestZookeeperDynamicConfigurationPathToKey(t *testing.T) {
+ ts, reg := initZkDynamicConfiguration(t)
+ defer func() {
+ err := ts.Stop()
+ assert.NoError(t, err)
+ }()
+ listener := &mockDataListener{}
+ key := path.Join("dubbogoDemo" + constant.CONFIGURATORS_SUFFIX)
+ reg.AddListener(key, listener)
+ listener.wg.Add(1)
+
+ data := `
+scope: application
+key: dubbogoDemo
+enabled: true
+configs:
+ - addresses: [0.0.0.0:20880]
+ side: provider
+ parameters:
+ weight: 60
+ - addresses: [0.0.0.0:20881]
+ side: provider
+ parameters:
+ weight: 40
+`
+ zkPath := path.Join(reg.rootPath, "dubbo", key)
+ exists, _, err := reg.client.Conn.Exists(zkPath)
+ assert.NoError(t, err)
+ if !exists {
+ err = reg.client.Create(zkPath)
+ assert.NoError(t, err)
+ }
+ _, err = reg.client.SetContent(zkPath, []byte(data), 0)
+ assert.NoError(t, err)
+ listener.wg.Wait()
+ assert.Equal(t, key, listener.event)
+}
diff --git a/doc/pic/misc/dubbogo-wechat.png b/doc/pic/misc/dubbogo-wechat.png
new file mode 100644
index 0000000..dd34357
--- /dev/null
+++ b/doc/pic/misc/dubbogo-wechat.png
Binary files differ
diff --git a/filter/filter_impl/access_log_filter.go b/filter/filter_impl/access_log_filter.go
index 167b5ed..6aa4e65 100644
--- a/filter/filter_impl/access_log_filter.go
+++ b/filter/filter_impl/access_log_filter.go
@@ -34,7 +34,7 @@
)
const (
- //used in URL.
+ // used in URL.
// nolint
FileDateFormat = "2006-01-02"
@@ -43,7 +43,7 @@
// nolint
LogMaxBuffer = 5000
// nolint
- LogFileMode = 0600
+ LogFileMode = 0o600
// those fields are the data collected by this filter
diff --git a/filter/filter_impl/active_filter.go b/filter/filter_impl/active_filter.go
index 795de96..a391cb3 100644
--- a/filter/filter_impl/active_filter.go
+++ b/filter/filter_impl/active_filter.go
@@ -40,8 +40,7 @@
}
// ActiveFilter tracks the requests status
-type ActiveFilter struct {
-}
+type ActiveFilter struct{}
// Invoke starts to record the requests status
func (ef *ActiveFilter) Invoke(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result {
diff --git a/filter/filter_impl/active_filter_test.go b/filter/filter_impl/active_filter_test.go
index 2397503..bb1676d 100644
--- a/filter/filter_impl/active_filter_test.go
+++ b/filter/filter_impl/active_filter_test.go
@@ -47,7 +47,6 @@
invoker.EXPECT().GetUrl().Return(url).Times(1)
filter.Invoke(context.Background(), invoker, invoc)
assert.True(t, invoc.AttachmentsByKey(dubboInvokeStartTime, "") != "")
-
}
func TestActiveFilterOnResponse(t *testing.T) {
@@ -79,5 +78,4 @@
assert.True(t, urlStatus.GetFailedElapsed() >= int64(elapsed))
assert.True(t, urlStatus.GetLastRequestFailedTimestamp() != int64(0))
assert.True(t, methodStatus.GetLastRequestFailedTimestamp() != int64(0))
-
}
diff --git a/filter/filter_impl/auth/accesskey_storage.go b/filter/filter_impl/auth/accesskey_storage.go
index 90d3efb..de49bcb 100644
--- a/filter/filter_impl/auth/accesskey_storage.go
+++ b/filter/filter_impl/auth/accesskey_storage.go
@@ -26,8 +26,7 @@
)
// DefaultAccesskeyStorage is the default implementation of AccesskeyStorage
-type DefaultAccesskeyStorage struct {
-}
+type DefaultAccesskeyStorage struct{}
// GetAccessKeyPair retrieves AccessKeyPair from url by the key "accessKeyId" and "secretAccessKey"
func (storage *DefaultAccesskeyStorage) GetAccessKeyPair(invocation protocol.Invocation, url *common.URL) *filter.AccessKeyPair {
diff --git a/filter/filter_impl/auth/consumer_sign.go b/filter/filter_impl/auth/consumer_sign.go
index 823db82..3e298cd 100644
--- a/filter/filter_impl/auth/consumer_sign.go
+++ b/filter/filter_impl/auth/consumer_sign.go
@@ -21,6 +21,7 @@
"context"
"fmt"
)
+
import (
"github.com/apache/dubbo-go/common/constant"
"github.com/apache/dubbo-go/common/extension"
@@ -30,8 +31,7 @@
)
// ConsumerSignFilter signs the request on consumer side
-type ConsumerSignFilter struct {
-}
+type ConsumerSignFilter struct{}
func init() {
extension.SetFilter(constant.CONSUMER_SIGN_FILTER, getConsumerSignFilter)
@@ -47,7 +47,6 @@
})
if err != nil {
panic(fmt.Sprintf("Sign for invocation %s # %s failed", url.ServiceKey(), invocation.MethodName()))
-
}
return invoker.Invoke(ctx, invocation)
}
diff --git a/filter/filter_impl/auth/default_authenticator.go b/filter/filter_impl/auth/default_authenticator.go
index 7c7131c..5a08b54 100644
--- a/filter/filter_impl/auth/default_authenticator.go
+++ b/filter/filter_impl/auth/default_authenticator.go
@@ -20,9 +20,10 @@
import (
"errors"
"fmt"
- "github.com/apache/dubbo-go/filter"
"strconv"
"time"
+
+ "github.com/apache/dubbo-go/filter"
)
import (
@@ -38,8 +39,7 @@
}
// DefaultAuthenticator is the default implementation of Authenticator
-type DefaultAuthenticator struct {
-}
+type DefaultAuthenticator struct{}
// Sign adds the signature to the invocation
func (authenticator *DefaultAuthenticator) Sign(invocation protocol.Invocation, url *common.URL) error {
@@ -65,7 +65,6 @@
// 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,
url.ColonSeparatedKey(), invocation.MethodName(), secrectKey, currentTime)
var signature string
@@ -125,7 +124,6 @@
}
func doAuthWork(url *common.URL, do func(filter.Authenticator) error) error {
-
shouldAuth := url.GetParamBool(constant.SERVICE_AUTH_KEY, false)
if shouldAuth {
authenticator := extension.GetAuthenticator(url.GetParam(constant.AUTHENTICATOR_KEY, constant.DEFAULT_AUTHENTICATOR))
diff --git a/filter/filter_impl/auth/default_authenticator_test.go b/filter/filter_impl/auth/default_authenticator_test.go
index d915b6a..c253caf 100644
--- a/filter/filter_impl/auth/default_authenticator_test.go
+++ b/filter/filter_impl/auth/default_authenticator_test.go
@@ -50,7 +50,7 @@
requestTime := strconv.Itoa(int(time.Now().Unix() * 1000))
signature, _ := getSignature(testurl, inv, secret, requestTime)
- var authenticator = &DefaultAuthenticator{}
+ authenticator := &DefaultAuthenticator{}
invcation := invocation.NewRPCInvocation("test", parmas, map[string]interface{}{
constant.REQUEST_SIGNATURE_KEY: signature,
@@ -69,7 +69,6 @@
})
err = authenticator.Authenticate(invcation, testurl)
assert.NotNil(t, err)
-
}
func TestDefaultAuthenticator_Sign(t *testing.T) {
@@ -84,7 +83,6 @@
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")
-
}
func Test_getAccessKeyPairSuccess(t *testing.T) {
@@ -114,7 +112,6 @@
common.WithParamsValue(constant.ACCESS_KEY_ID_KEY, "akey"), common.WithParamsValue(constant.ACCESS_KEY_STORAGE_KEY, "dubbo"))
_, e = getAccessKeyPair(invcation, testurl)
assert.NoError(t, e)
-
}
func Test_getSignatureWithinParams(t *testing.T) {
diff --git a/filter/filter_impl/auth/provider_auth.go b/filter/filter_impl/auth/provider_auth.go
index 774fdb2..9a6490d 100644
--- a/filter/filter_impl/auth/provider_auth.go
+++ b/filter/filter_impl/auth/provider_auth.go
@@ -30,8 +30,7 @@
)
// ProviderAuthFilter verifies the correctness of the signature on provider side
-type ProviderAuthFilter struct {
-}
+type ProviderAuthFilter struct{}
func init() {
extension.SetFilter(constant.PROVIDER_AUTH_FILTER, getProviderAuthFilter)
diff --git a/filter/filter_impl/auth/provider_auth_test.go b/filter/filter_impl/auth/provider_auth_test.go
index dc130b5..9e68b64 100644
--- a/filter/filter_impl/auth/provider_auth_test.go
+++ b/filter/filter_impl/auth/provider_auth_test.go
@@ -70,5 +70,4 @@
assert.Equal(t, result, filter.Invoke(context.Background(), invoker, inv))
url.SetParam(constant.SERVICE_AUTH_KEY, "true")
assert.Equal(t, result, filter.Invoke(context.Background(), invoker, inv))
-
}
diff --git a/filter/filter_impl/auth/sign_util_test.go b/filter/filter_impl/auth/sign_util_test.go
index a4aaf2d..69203e6 100644
--- a/filter/filter_impl/auth/sign_util_test.go
+++ b/filter/filter_impl/auth/sign_util_test.go
@@ -56,7 +56,6 @@
key := "key"
signature := Sign(metadata, key)
assert.NotNil(t, signature)
-
}
func TestSignWithParams(t *testing.T) {
diff --git a/filter/filter_impl/execute_limit_filter.go b/filter/filter_impl/execute_limit_filter.go
index 3561161..fdd472c 100644
--- a/filter/filter_impl/execute_limit_filter.go
+++ b/filter/filter_impl/execute_limit_filter.go
@@ -134,8 +134,10 @@
atomic.AddInt64(&state.concurrentCount, -1)
}
-var executeLimitOnce sync.Once
-var executeLimitFilter *ExecuteLimitFilter
+var (
+ executeLimitOnce sync.Once
+ executeLimitFilter *ExecuteLimitFilter
+)
// GetExecuteLimitFilter returns the singleton ExecuteLimitFilter instance
func GetExecuteLimitFilter() filter.Filter {
diff --git a/filter/filter_impl/generic_filter.go b/filter/filter_impl/generic_filter.go
index cf307d0..f184bd3 100644
--- a/filter/filter_impl/generic_filter.go
+++ b/filter/filter_impl/generic_filter.go
@@ -38,7 +38,7 @@
const (
// GENERIC
- //generic module name
+ // generic module name
GENERIC = "generic"
)
@@ -115,14 +115,14 @@
return result
} else if t.Kind() == reflect.Slice {
value := reflect.ValueOf(obj)
- var newTemps = make([]interface{}, 0, value.Len())
+ newTemps := make([]interface{}, 0, value.Len())
for i := 0; i < value.Len(); i++ {
newTemp := struct2MapAll(value.Index(i).Interface())
newTemps = append(newTemps, newTemp)
}
return newTemps
} else if t.Kind() == reflect.Map {
- var newTempMap = make(map[interface{}]interface{}, v.Len())
+ newTempMap := make(map[interface{}]interface{}, v.Len())
iter := v.MapRange()
for iter.Next() {
if !iter.Value().CanInterface() {
diff --git a/filter/filter_impl/generic_service_filter_test.go b/filter/filter_impl/generic_service_filter_test.go
index c755a2d..6b80d21 100644
--- a/filter/filter_impl/generic_service_filter_test.go
+++ b/filter/filter_impl/generic_service_filter_test.go
@@ -93,7 +93,8 @@
hessian.Object(append(make([]map[string]interface{}, 1), m)),
hessian.Object("111"),
hessian.Object(append(make([]map[string]interface{}, 1), m)),
- hessian.Object("222")},
+ hessian.Object("222"),
+ },
}
s := &TestService{}
_, _ = common.ServiceMap.Register("com.test.Path", "testprotocol", "", "", s)
diff --git a/filter/filter_impl/graceful_shutdown_filter.go b/filter/filter_impl/graceful_shutdown_filter.go
index 4a4e8ce..f79123c 100644
--- a/filter/filter_impl/graceful_shutdown_filter.go
+++ b/filter/filter_impl/graceful_shutdown_filter.go
@@ -32,10 +32,10 @@
)
func init() {
- var consumerFiler = &gracefulShutdownFilter{
+ consumerFiler := &gracefulShutdownFilter{
shutdownConfig: config.GetConsumerConfig().ShutdownConfig,
}
- var providerFilter = &gracefulShutdownFilter{
+ providerFilter := &gracefulShutdownFilter{
shutdownConfig: config.GetProviderConfig().ShutdownConfig,
}
diff --git a/filter/filter_impl/graceful_shutdown_filter_test.go b/filter/filter_impl/graceful_shutdown_filter_test.go
index b16956e..870c808 100644
--- a/filter/filter_impl/graceful_shutdown_filter_test.go
+++ b/filter/filter_impl/graceful_shutdown_filter_test.go
@@ -72,5 +72,4 @@
})
assert.True(t, providerConfig.ShutdownConfig.RequestsFinished)
assert.Equal(t, rejectHandler, shutdownFilter.getRejectHandler())
-
}
diff --git a/filter/filter_impl/hystrix_filter.go b/filter/filter_impl/hystrix_filter.go
index d13e02c..3a7c0c4 100644
--- a/filter/filter_impl/hystrix_filter.go
+++ b/filter/filter_impl/hystrix_filter.go
@@ -23,11 +23,13 @@
"regexp"
"sync"
)
+
import (
"github.com/afex/hystrix-go/hystrix"
perrors "github.com/pkg/errors"
"gopkg.in/yaml.v2"
)
+
import (
"github.com/apache/dubbo-go/common/extension"
"github.com/apache/dubbo-go/common/logger"
@@ -123,7 +125,7 @@
* "GetUser1": "userp_m"
*/
type HystrixFilter struct {
- COrP bool //true for consumer
+ COrP bool // true for consumer
res map[string][]*regexp.Regexp
ifNewMap sync.Map
}
@@ -179,7 +181,7 @@
}
return err
}, func(err error) error {
- //Return error and if it is caused by hystrix logic, so that it can be handled by previous filters.
+ // Return error and if it is caused by hystrix logic, so that it can be handled by previous filters.
_, ok := err.(hystrix.CircuitError)
logger.Debugf("[Hystrix Filter]Hystrix health check counted, error is: %v, failed by hystrix: %v; %s", err, ok, cmdName)
result = &protocol.RPCResult{}
@@ -197,7 +199,7 @@
// GetHystrixFilterConsumer returns HystrixFilter instance for consumer
func GetHystrixFilterConsumer() filter.Filter {
- //When first called, load the config in
+ // When first called, load the config in
consumerConfigOnce.Do(func() {
if err := initHystrixConfigConsumer(); err != nil {
logger.Warnf("[Hystrix Filter]Config load failed for consumer, error is: %v , will use default", err)
@@ -217,7 +219,7 @@
}
func getConfig(service string, method string, cOrP bool) CommandConfigWithError {
- //Find method level config
+ // Find method level config
var conf *HystrixFilterConfig
if cOrP {
conf = confConsumer
@@ -229,13 +231,13 @@
logger.Infof("[Hystrix Filter]Found method-level config for %s - %s", service, method)
return *getConf
}
- //Find service level config
+ // Find service level config
getConf = conf.Configs[conf.Services[service].ServiceConfig]
if getConf != nil {
logger.Infof("[Hystrix Filter]Found service-level config for %s - %s", service, method)
return *getConf
}
- //Find default config
+ // Find default config
getConf = conf.Configs[conf.Default]
if getConf != nil {
logger.Infof("[Hystrix Filter]Found global default config for %s - %s", service, method)
@@ -244,7 +246,6 @@
getConf = &CommandConfigWithError{}
logger.Infof("[Hystrix Filter]No config found for %s - %s, using default", service, method)
return *getConf
-
}
func initHystrixConfigConsumer() error {
diff --git a/filter/filter_impl/hystrix_filter_test.go b/filter/filter_impl/hystrix_filter_test.go
index 4973ce7..8bf7263 100644
--- a/filter/filter_impl/hystrix_filter_test.go
+++ b/filter/filter_impl/hystrix_filter_test.go
@@ -47,7 +47,7 @@
}
func mockInitHystrixConfig() {
- //Mock config
+ // Mock config
confConsumer = &HystrixFilterConfig{
make(map[string]*CommandConfigWithError),
"Default",
@@ -85,7 +85,6 @@
"GetUser": "userp_m",
},
}
-
}
func TestGetHystrixFilter(t *testing.T) {
@@ -117,7 +116,7 @@
func TestGetConfig3(t *testing.T) {
mockInitHystrixConfig()
- //This should use default
+ // This should use default
configGot := getConfig("Mock.Service", "GetMock", true)
assert.NotNil(t, configGot)
assert.Equal(t, 1000, configGot.Timeout)
@@ -186,7 +185,7 @@
resChan <- result
}()
}
- //This can not always pass the test when on travis due to concurrency, you can uncomment the code below and test it locally
+ // This can not always pass the test when on travis due to concurrency, you can uncomment the code below and test it locally
//var lastRest bool
//for i := 0; i < 50; i++ {
@@ -195,7 +194,6 @@
//Normally the last result should be true, which means the circuit has been opened
//
//assert.True(t, lastRest)
-
}
func TestHystricFilterInvokeCircuitBreakOmitException(t *testing.T) {
@@ -215,7 +213,7 @@
resChan <- result
}()
}
- //This can not always pass the test when on travis due to concurrency, you can uncomment the code below and test it locally
+ // This can not always pass the test when on travis due to concurrency, you can uncomment the code below and test it locally
//time.Sleep(time.Second * 6)
//var lastRest bool
@@ -224,7 +222,6 @@
//}
//
//assert.False(t, lastRest)
-
}
func TestGetHystrixFilterConsumer(t *testing.T) {
diff --git a/filter/filter_impl/metrics_filter.go b/filter/filter_impl/metrics_filter.go
index f473417..27eddfd 100644
--- a/filter/filter_impl/metrics_filter.go
+++ b/filter/filter_impl/metrics_filter.go
@@ -34,9 +34,7 @@
metricFilterName = "metrics"
)
-var (
- metricFilterInstance filter.Filter
-)
+var metricFilterInstance filter.Filter
// must initialized before using the filter and after loading configuration
func init() {
diff --git a/filter/filter_impl/metrics_filter_test.go b/filter/filter_impl/metrics_filter_test.go
index ac10d52..98fe129 100644
--- a/filter/filter_impl/metrics_filter_test.go
+++ b/filter/filter_impl/metrics_filter_test.go
@@ -39,7 +39,6 @@
)
func TestMetricsFilterInvoke(t *testing.T) {
-
// prepare the mock reporter
config.GetMetricConfig().Reporters = []string{"mock"}
mk := &mockReporter{}
diff --git a/filter/filter_impl/sentinel_filter.go b/filter/filter_impl/sentinel_filter.go
index 1de27ad..cbe1c38 100644
--- a/filter/filter_impl/sentinel_filter.go
+++ b/filter/filter_impl/sentinel_filter.go
@@ -186,9 +186,11 @@
func SetDubboConsumerFallback(f DubboFallback) {
sentinelDubboConsumerFallback = f
}
+
func SetDubboProviderFallback(f DubboFallback) {
sentinelDubboProviderFallback = f
}
+
func getDefaultDubboFallback() DubboFallback {
return func(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation, blockError *base.BlockError) protocol.Result {
result := &protocol.RPCResult{}
diff --git a/filter/filter_impl/sentinel_filter_test.go b/filter/filter_impl/sentinel_filter_test.go
index c6b6d42..ee0f0be 100644
--- a/filter/filter_impl/sentinel_filter_test.go
+++ b/filter/filter_impl/sentinel_filter_test.go
@@ -51,7 +51,7 @@
_, err = flow.LoadRules([]*flow.Rule{
{
Resource: interfaceResourceName,
- //MetricType: flow.QPS,
+ // MetricType: flow.QPS,
TokenCalculateStrategy: flow.Direct,
ControlBehavior: flow.Reject,
Threshold: 100,
diff --git a/filter/filter_impl/tps/tps_limit_fix_window_strategy.go b/filter/filter_impl/tps/tps_limit_fix_window_strategy.go
index d495e03..e992ece 100644
--- a/filter/filter_impl/tps/tps_limit_fix_window_strategy.go
+++ b/filter/filter_impl/tps/tps_limit_fix_window_strategy.go
@@ -68,7 +68,6 @@
// IsAllowable determines if the requests over the TPS limit within the interval.
// It is not thread-safe.
func (impl *FixedWindowTpsLimitStrategyImpl) IsAllowable() bool {
-
current := time.Now().UnixNano()
if impl.timestamp+impl.interval < current {
// it's a new window
diff --git a/filter/filter_impl/tps/tps_limiter_method_service.go b/filter/filter_impl/tps/tps_limiter_method_service.go
index f0c2764..76d06bd 100644
--- a/filter/filter_impl/tps/tps_limiter_method_service.go
+++ b/filter/filter_impl/tps/tps_limiter_method_service.go
@@ -121,7 +121,6 @@
// This implementation use concurrent map + loadOrStore to make implementation thread-safe
// You can image that even multiple threads create limiter, but only one could store the limiter into tpsState
func (limiter MethodServiceTpsLimiterImpl) IsAllowable(url *common.URL, invocation protocol.Invocation) bool {
-
methodConfigPrefix := "methods." + invocation.MethodName() + "."
methodLimitRateConfig := url.GetParam(methodConfigPrefix+constant.TPS_LIMIT_RATE_KEY, "")
@@ -193,15 +192,16 @@
// actually there is no method-level configuration, so we use the service-level configuration
result, err := strconv.ParseInt(url.GetParam(configKey, defaultVal), 0, 0)
-
if err != nil {
panic(fmt.Sprintf("Cannot parse the configuration %s, please check your configuration!", configKey))
}
return result
}
-var methodServiceTpsLimiterInstance *MethodServiceTpsLimiterImpl
-var methodServiceTpsLimiterOnce sync.Once
+var (
+ methodServiceTpsLimiterInstance *MethodServiceTpsLimiterImpl
+ methodServiceTpsLimiterOnce sync.Once
+)
// GetMethodServiceTpsLimiter will return an MethodServiceTpsLimiterImpl instance.
func GetMethodServiceTpsLimiter() filter.TpsLimiter {
diff --git a/filter/filter_impl/tps/tps_limiter_method_service_test.go b/filter/filter_impl/tps/tps_limiter_method_service_test.go
index 5baa70a..cb9578f 100644
--- a/filter/filter_impl/tps/tps_limiter_method_service_test.go
+++ b/filter/filter_impl/tps/tps_limiter_method_service_test.go
@@ -21,6 +21,7 @@
"net/url"
"testing"
)
+
import (
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"
diff --git a/filter/filter_impl/tps_limit_filter.go b/filter/filter_impl/tps_limit_filter.go
index ea1e3bc..210e157 100644
--- a/filter/filter_impl/tps_limit_filter.go
+++ b/filter/filter_impl/tps_limit_filter.go
@@ -20,6 +20,7 @@
import (
"context"
)
+
import (
"github.com/apache/dubbo-go/common/constant"
"github.com/apache/dubbo-go/common/extension"
@@ -53,8 +54,7 @@
* tps.limit.rejected.handler: "default", # optional, or the name of the implementation
* if the value of 'tps.limiter' is nil or empty string, the tps filter will do nothing
*/
-type TpsLimitFilter struct {
-}
+type TpsLimitFilter struct{}
// Invoke gets the configured limter to impose TPS limiting
func (t TpsLimitFilter) Invoke(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result {
diff --git a/filter/filter_impl/tps_limit_filter_test.go b/filter/filter_impl/tps_limit_filter_test.go
index 55a3a55..24f9827 100644
--- a/filter/filter_impl/tps_limit_filter_test.go
+++ b/filter/filter_impl/tps_limit_filter_test.go
@@ -52,7 +52,6 @@
[]interface{}{"OK"}, attch))
assert.Nil(t, result.Error())
assert.Nil(t, result.Result())
-
}
func TestGenericFilterInvokeWithDefaultTpsLimiter(t *testing.T) {
diff --git a/filter/filter_impl/tracing_filter.go b/filter/filter_impl/tracing_filter.go
index dcdbe5b..8a30c96 100644
--- a/filter/filter_impl/tracing_filter.go
+++ b/filter/filter_impl/tracing_filter.go
@@ -50,8 +50,7 @@
// if you wish to using opentracing, please add the this filter into your filter attribute in your configure file.
// notice that this could be used in both client-side and server-side.
-type tracingFilter struct {
-}
+type tracingFilter struct{}
func (tf *tracingFilter) Invoke(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result {
var (
@@ -95,9 +94,7 @@
return result
}
-var (
- tracingFilterInstance *tracingFilter
-)
+var tracingFilterInstance *tracingFilter
func newTracingFilter() filter.Filter {
if tracingFilterInstance == nil {
diff --git a/filter/handler/rejected_execution_handler_only_log.go b/filter/handler/rejected_execution_handler_only_log.go
index 5242b5b..5277b27 100644
--- a/filter/handler/rejected_execution_handler_only_log.go
+++ b/filter/handler/rejected_execution_handler_only_log.go
@@ -18,8 +18,9 @@
package handler
import (
- "github.com/apache/dubbo-go/filter"
"sync"
+
+ "github.com/apache/dubbo-go/filter"
)
import (
@@ -41,8 +42,10 @@
extension.SetRejectedExecutionHandler(constant.DEFAULT_KEY, GetOnlyLogRejectedExecutionHandler)
}
-var onlyLogHandlerInstance *OnlyLogRejectedExecutionHandler
-var onlyLogHandlerOnce sync.Once
+var (
+ onlyLogHandlerInstance *OnlyLogRejectedExecutionHandler
+ onlyLogHandlerOnce sync.Once
+)
// OnlyLogRejectedExecutionHandler implements the RejectedExecutionHandler
/**
@@ -59,8 +62,7 @@
* - name: "GetUser"
* OnlyLogRejectedExecutionHandler is designed to be singleton
*/
-type OnlyLogRejectedExecutionHandler struct {
-}
+type OnlyLogRejectedExecutionHandler struct{}
// RejectedExecution will do nothing, it only log the invocation.
func (handler *OnlyLogRejectedExecutionHandler) RejectedExecution(url *common.URL,
diff --git a/filter/handler/rejected_execution_handler_only_log_test.go b/filter/handler/rejected_execution_handler_only_log_test.go
index 7aa4aff..acc3a19 100644
--- a/filter/handler/rejected_execution_handler_only_log_test.go
+++ b/filter/handler/rejected_execution_handler_only_log_test.go
@@ -21,6 +21,7 @@
"net/url"
"testing"
)
+
import (
"github.com/apache/dubbo-go/common"
"github.com/apache/dubbo-go/common/constant"
diff --git a/go.mod b/go.mod
index c1643ed..609f646 100644
--- a/go.mod
+++ b/go.mod
@@ -3,20 +3,18 @@
go 1.15
require (
- github.com/NYTimes/gziphandler v1.1.1 // indirect
github.com/RoaringBitmap/roaring v0.5.5
github.com/Workiva/go-datastructures v1.0.52
github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5
github.com/alibaba/sentinel-golang v1.0.2
github.com/apache/dubbo-getty v1.4.3
- github.com/apache/dubbo-go-hessian2 v1.8.2
+ github.com/apache/dubbo-go-hessian2 v1.9.1
github.com/coreos/etcd v3.3.25+incompatible
github.com/creasty/defaults v1.5.1
- github.com/dubbogo/go-zookeeper v1.0.2
- github.com/dubbogo/gost v1.11.0
+ github.com/dubbogo/go-zookeeper v1.0.3
+ github.com/dubbogo/gost v1.11.3
github.com/elazarl/go-bindata-assetfs v1.0.0 // indirect
github.com/emicklei/go-restful/v3 v3.4.0
- github.com/frankban/quicktest v1.4.1 // indirect
github.com/fsnotify/fsnotify v1.4.9
github.com/go-co-op/gocron v0.1.1
github.com/go-resty/resty/v2 v2.3.0
@@ -25,35 +23,32 @@
github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645
github.com/hashicorp/consul v1.8.0
github.com/hashicorp/consul/api v1.5.0
- github.com/hashicorp/go-raftchunking v0.6.3-0.20191002164813-7e9e8525653a // indirect
- github.com/hashicorp/vault/api v1.0.5-0.20191108163347-bdd38fca2cff // indirect
github.com/hashicorp/vault/sdk v0.1.14-0.20191112033314-390e96e22eb2
github.com/jinzhu/copier v0.0.0-20190625015134-976e0346caa8
- github.com/magiconair/properties v1.8.4
+ github.com/magiconair/properties v1.8.5
github.com/mitchellh/mapstructure v1.4.1
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd
- github.com/nacos-group/nacos-sdk-go v1.0.6
+ github.com/nacos-group/nacos-sdk-go v1.0.7
github.com/opentracing/opentracing-go v1.2.0
- github.com/pierrec/lz4 v2.2.6+incompatible // indirect
github.com/pkg/errors v0.9.1
- github.com/prometheus/client_golang v1.8.0
+ github.com/prometheus/client_golang v1.9.0
github.com/satori/go.uuid v1.2.1-0.20181028125025-b2ce2384e17b
- github.com/stretchr/objx v0.2.0 // indirect
github.com/stretchr/testify v1.7.0
github.com/zouyx/agollo/v3 v3.4.5
go.uber.org/atomic v1.7.0
go.uber.org/zap v1.16.0
golang.org/x/sys v0.0.0-20201223074533-0d417f636930 // indirect
- google.golang.org/grpc v1.26.0
+ google.golang.org/grpc v1.33.1
gopkg.in/yaml.v2 v2.4.0
k8s.io/api v0.16.9
k8s.io/apimachinery v0.16.9
k8s.io/client-go v0.16.9
- k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a // indirect
)
replace (
github.com/coreos/bbolt => go.etcd.io/bbolt v1.3.4
github.com/envoyproxy/go-control-plane => github.com/envoyproxy/go-control-plane v0.8.0
github.com/shirou/gopsutil => github.com/shirou/gopsutil v0.0.0-20181107111621-48177ef5f880
+ go.etcd.io/bbolt v1.3.4 => github.com/coreos/bbolt v1.3.3
+ google.golang.org/grpc v1.33.1 => google.golang.org/grpc v1.26.0
)
diff --git a/go.sum b/go.sum
index aee0ed6..d8f40ef 100644
--- a/go.sum
+++ b/go.sum
@@ -52,9 +52,8 @@
github.com/Microsoft/go-winio v0.4.3 h1:M3NHMuPgMSUPdE5epwNUHlRPSVzHs8HpRTrVXhR0myo=
github.com/Microsoft/go-winio v0.4.3/go.mod h1:VhR8bwka0BXejwEJY73c50VrPtXAaKcyvVC4A4RozmA=
github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ=
+github.com/NYTimes/gziphandler v1.0.1 h1:iLrQrdwjDd52kHDA5op2UBJFjmOb9g+7scBan4RN8F0=
github.com/NYTimes/gziphandler v1.0.1/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ=
-github.com/NYTimes/gziphandler v1.1.1 h1:ZUDjpQae29j0ryrS0u/B8HZfJBtBQHjqw2rQ2cqUQ3I=
-github.com/NYTimes/gziphandler v1.1.1/go.mod h1:n/CVRwUEOgIxrgPvAQhUUr9oeUtvrhMomdKFjzJNB0c=
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=
github.com/PuerkitoBio/urlesc v0.0.0-20160726150825-5bd2802263f2/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
@@ -81,10 +80,11 @@
github.com/alibaba/sentinel-golang v1.0.2/go.mod h1:QsB99f/z35D2AiMrAWwgWE85kDTkBUIkcmPrRt+61NI=
github.com/aliyun/alibaba-cloud-sdk-go v1.61.18 h1:zOVTBdCKFd9JbCKz9/nt+FovbjPFmb7mUnp8nH9fQBA=
github.com/aliyun/alibaba-cloud-sdk-go v1.61.18/go.mod h1:v8ESoHo4SyHmuB4b1tJqDHxfTGEciD+yhvOU/5s1Rfk=
+github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
github.com/apache/dubbo-getty v1.4.3 h1:PCKpryDasKOxwT5MBC6MIMO+0NLOaHF6Xco9YXQw7HI=
github.com/apache/dubbo-getty v1.4.3/go.mod h1:ansXgKxxyhCOiQL29nO5ce1MDcEKmCyZuNR9oMs3hek=
-github.com/apache/dubbo-go-hessian2 v1.8.2 h1:CQq2Mmlrk6Fqmudwl9Dqps8drTrBFnmXRlzgOjj0FqA=
-github.com/apache/dubbo-go-hessian2 v1.8.2/go.mod h1:xQUjE7F8PX49nm80kChFvepA/AvqAZ0oh/UaB6+6pBE=
+github.com/apache/dubbo-go-hessian2 v1.9.1 h1:ceSsU/9z/gv3hzUpl8GceEhQvF3i0BionfdHUGMmjHU=
+github.com/apache/dubbo-go-hessian2 v1.9.1/go.mod h1:xQUjE7F8PX49nm80kChFvepA/AvqAZ0oh/UaB6+6pBE=
github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e h1:QEF07wC0T1rKkctt1RINW/+RMTVmiwxETico2l3gxJA=
@@ -126,11 +126,14 @@
github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I=
github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec/go.mod h1:jMjuTZXRI4dUb/I5gc9Hdhagfvm9+RyrPryS/auMzxE=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
+github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ=
github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8=
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI=
github.com/coredns/coredns v1.1.2 h1:bAFHrSsBeTeRG5W3Nf2su3lUGw7Npw2UKeCJm/3A638=
github.com/coredns/coredns v1.1.2/go.mod h1:zASH/MVDgR6XZTbxvOnsZfffS+31vg6Ackf/wo1+AM0=
+github.com/coreos/bbolt v1.3.3 h1:n6AiVyVRKQFNb6mJlwESEvvLoDyiTzXX7ORAUlkeBdY=
+github.com/coreos/bbolt v1.3.3/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
github.com/coreos/etcd v3.3.25+incompatible h1:0GQEw6h3YnuOVdtwygkIfJ+Omx0tZ8/QkVyXI4LkbeY=
@@ -142,14 +145,16 @@
github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM=
github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
-github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e h1:Wf6HqHfScWJN9/ZjdUKyjop4mf3Qdd+1TvvltAvM3m8=
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
+github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf h1:iW4rZ826su+pqaw19uhpSCzhj44qo35pNgKFGqzDKkU=
+github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f h1:lBNOc5arjvs8E5mO2tbpBpLoyyu8B6e44T7hJy6potg=
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
+github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/creasty/defaults v1.5.1 h1:j8WexcS3d/t4ZmllX4GEkl4wIB/trOr035ajcLHCISM=
github.com/creasty/defaults v1.5.1/go.mod h1:FPZ+Y0WNrbqOVw+c6av63eyHUAl6pMHZwqLPvXUZGfY=
github.com/davecgh/go-spew v0.0.0-20151105211317-5215b55f46b2/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -171,12 +176,12 @@
github.com/docker/go-connections v0.3.0 h1:3lOnM9cSzgGwx8VfK/NGOW5fLQ0GjIlCkaktF+n1M6o=
github.com/docker/go-connections v0.3.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec=
github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM=
-github.com/dubbogo/go-zookeeper v1.0.2 h1:xmEnPL8SlCe3/+J5ZR9e8qE35LmFVYe8VVpDakjNM4A=
-github.com/dubbogo/go-zookeeper v1.0.2/go.mod h1:fn6n2CAEer3novYgk9ULLwAjuV8/g4DdC2ENwRb6E+c=
+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=
github.com/dubbogo/gost v1.9.0/go.mod h1:pPTjVyoJan3aPxBPNUX0ADkXjPibLo+/Ib0/fADXSG8=
github.com/dubbogo/gost v1.10.1/go.mod h1:+mQGS51XQEUWZP2JeGZTxJwipjRKtJO7Tr+FOg+72rI=
-github.com/dubbogo/gost v1.11.0 h1:9KtyWQz1gMlAfwzen5iyhMdoe08SPBBUVhco4rdgJ9I=
-github.com/dubbogo/gost v1.11.0/go.mod h1:w8Yw29eDWtRVo3tx9nPpHkNZnOi4SRx1fZf7eVlAAU4=
+github.com/dubbogo/gost v1.11.3 h1:PSP9KQyuRJugmPLqC18MFgoIL0g1G4n/9FTKgQYjjbE=
+github.com/dubbogo/gost v1.11.3/go.mod h1:3QQEj50QOhkWTERT785YZ5ZxIRGNdR11FCLP7FzHsMc=
github.com/dubbogo/jsonparser v1.0.1/go.mod h1:tYAtpctvSP/tWw4MeelsowSPgXQRVHHWbqL6ynps8jU=
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=
@@ -208,8 +213,6 @@
github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M=
github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4=
github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20=
-github.com/frankban/quicktest v1.4.1 h1:Wv2VwvNn73pAdFIVUQRXYDFp31lXKbqblIXo/Q5GPSg=
-github.com/frankban/quicktest v1.4.1/go.mod h1:36zfPVQyHxymz4cH7wlDmVwDrJuljRB60qkgn7rorfQ=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
@@ -225,6 +228,7 @@
github.com/go-errors/errors v1.0.1 h1:LUHzmkK3GUKUrL/1gfBUxAHzcev3apQlezX/+O7ma6w=
github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q=
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
+github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o=
@@ -254,15 +258,17 @@
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
-github.com/gogo/protobuf v1.2.2-0.20190723190241-65acae22fc9d h1:3PaI8p3seN09VjbTYC/QWlUZdZ1qS1zGjy7LH2Wt07I=
github.com/gogo/protobuf v1.2.2-0.20190723190241-65acae22fc9d/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
+github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
+github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
github.com/goji/httpauth v0.0.0-20160601135302-2da839ab0f4d/go.mod h1:nnjvkQ9ptGaCkuDUx6wNykzzlUixGxvkme+H/lnzb+A=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
-github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6 h1:ZgQEtGgCBiWRM39fZuwSd1LwSqqSW0hOdXCYYDX0R3I=
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
+github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e h1:1r7pUrabqp18hOBcwBwiTsbnFeTZHV9eER/QT5JVZxY=
+github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y=
@@ -272,6 +278,7 @@
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
+github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
@@ -304,8 +311,9 @@
github.com/google/tcpproxy v0.0.0-20180808230851-dfa16c61dad2 h1:AtvtonGEH/fZK0XPNNBdB6swgy7Iudfx88wzyIpwqJ8=
github.com/google/tcpproxy v0.0.0-20180808230851-dfa16c61dad2/go.mod h1:DavVbd41y+b7ukKDmlnPR4nGYmkWXR6vHUkjQNiHPBs=
github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
-github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY=
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
+github.com/google/uuid v1.2.0 h1:qJYtXnJRWmpe7m/3XlyhrsLrEURqHRM2kxzoxXqyUDs=
+github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
github.com/googleapis/gax-go/v2 v2.0.5 h1:sjZBwGj9Jlw33ImPtvFviGYvseOtDM7hkSKB7+Tv3SM=
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
@@ -326,13 +334,15 @@
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA=
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
-github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4 h1:z53tR0945TRRQO/fLEVPI6SMv7ZflF0TEaTAoU7tOzg=
github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
+github.com/grpc-ecosystem/go-grpc-middleware v1.2.2 h1:FlFbCRLd5Jr4iYXZufAvgWN6Ao0JrI5chLINnUXDDr0=
+github.com/grpc-ecosystem/go-grpc-middleware v1.2.2/go.mod h1:EaizFBKfUKtMIF5iaDEhniwNedqGo9FuLFzppDr3uwI=
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 h1:Ovs26xHkKqVztRpIrF/92BcuyuQ/YW4NSIpoGtfXNho=
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
-github.com/grpc-ecosystem/grpc-gateway v1.9.5 h1:UImYN5qQ8tuGpGE16ZmjvcTtTw24zw1QAp/SlnNrZhI=
github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
+github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo=
+github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645 h1:MJG/KsmcqMwFAkh8mTnAwhyKoB+sTAnY4CACC110tbU=
github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645/go.mod h1:6iZfnjpejD4L/4DwD7NryNaJyCQdzwWwH2MWhCA90Kw=
github.com/hashicorp/consul v1.8.0 h1:yRKMKZyPLqUxl37t4nFt5OuGmTXoFhTJrakhfnYKCYA=
@@ -360,7 +370,6 @@
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.1/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 h1:d4QkX8FRTYaKaCZBoXYY8zJX2BXjWxurN/GA2tkrmZM=
github.com/hashicorp/go-hclog v0.12.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ=
github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=
@@ -375,13 +384,11 @@
github.com/hashicorp/go-multierror v1.1.0 h1:B9UzwGQJehnUY1yNrnwREHc3fGbC2xefo8g4TbElacI=
github.com/hashicorp/go-multierror v1.1.0/go.mod h1:spPvp8C1qA32ftKqdAHm4hHTbPw+vmowP0z+KUhOZdA=
github.com/hashicorp/go-plugin v1.0.1/go.mod h1:++UyYGoz3o5w9ZzAdZxtQKrWWP+iqPBn3cQptSMzBuY=
+github.com/hashicorp/go-raftchunking v0.6.1 h1:moEnaG3gcwsWNyIBJoD5PCByE+Ewkqxh6N05CT+MbwA=
github.com/hashicorp/go-raftchunking v0.6.1/go.mod h1:cGlg3JtDy7qy6c/3Bu660Mic1JF+7lWqIwCFSb08fX0=
-github.com/hashicorp/go-raftchunking v0.6.3-0.20191002164813-7e9e8525653a h1:FmnBDwGwlTgugDGbVxwV8UavqSMACbGrUpfc98yFLR4=
-github.com/hashicorp/go-raftchunking v0.6.3-0.20191002164813-7e9e8525653a/go.mod h1:xbXnmKqX9/+RhPkJ4zrEx4738HacP72aaUPlT2RZ4sU=
github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs=
+github.com/hashicorp/go-retryablehttp v0.5.4 h1:1BZvpawXoJCWX6pNtow9+rpEj+3itIlutiqnntI6jOE=
github.com/hashicorp/go-retryablehttp v0.5.4/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs=
-github.com/hashicorp/go-retryablehttp v0.6.2 h1:bHM2aVXwBtBJWxHtkSrWuI4umABCUczs52eiUS9nSiw=
-github.com/hashicorp/go-retryablehttp v0.6.2/go.mod h1:gEx6HMUGxYYhJScX7W1Il64m6cc2C1mDaW3NQ9sY1FY=
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-rootcerts v1.0.2 h1:jzhAVGtqPKbwpyCPELlgNWhE1znq+qwJtW5Oi2viEzc=
@@ -418,7 +425,6 @@
github.com/hashicorp/net-rpc-msgpackrpc v0.0.0-20151116020338-a14192a58a69 h1:lc3c72qGlIMDqQpQH82Y4vaglRMMFdJbziYWriR4UcE=
github.com/hashicorp/net-rpc-msgpackrpc v0.0.0-20151116020338-a14192a58a69/go.mod h1:/z+jUGRBlwVpUZfjute9jWaF6/HuhjuFQuL1YXzVD1Q=
github.com/hashicorp/raft v1.1.1/go.mod h1:vPAJM8Asw6u8LxC3eJCUZmRP/E4QmUGE1R7g7k8sG/8=
-github.com/hashicorp/raft v1.1.2-0.20191002163536-9c6bd3e3eb17/go.mod h1:vPAJM8Asw6u8LxC3eJCUZmRP/E4QmUGE1R7g7k8sG/8=
github.com/hashicorp/raft v1.1.2 h1:oxEL5DDeurYxLd3UbcY/hccgSPhLLpiBZ1YxtWEq59c=
github.com/hashicorp/raft v1.1.2/go.mod h1:vPAJM8Asw6u8LxC3eJCUZmRP/E4QmUGE1R7g7k8sG/8=
github.com/hashicorp/raft-boltdb v0.0.0-20171010151810-6e5ba93211ea h1:xykPFhrBAS2J0VBzVa5e80b5ZtYuNQtgXjN40qBZlD4=
@@ -427,11 +433,9 @@
github.com/hashicorp/serf v0.9.0/go.mod h1:YL0HO+FifKOW2u1ke99DGVu1zhcpZzNwrLIqBC7vbYU=
github.com/hashicorp/serf v0.9.2 h1:yJoyfZXo4Pk2p/M/viW+YLibBFiIbKoP79gu7kDAFP0=
github.com/hashicorp/serf v0.9.2/go.mod h1:UWDWwZeL5cuWDJdl0C6wrvrUwEqtQ4ZKBKKENpqIUyk=
+github.com/hashicorp/vault/api v1.0.4 h1:j08Or/wryXT4AcHj1oCbMd7IijXcKzYUGw59LGu9onU=
github.com/hashicorp/vault/api v1.0.4/go.mod h1:gDcqh3WGcR1cpF5AJz/B1UFheUEneMoIospckxBxk6Q=
-github.com/hashicorp/vault/api v1.0.5-0.20191108163347-bdd38fca2cff h1:cl94LQIrs/mNbh3ny1R8lM1gtYcUBa7HnGtOCi35SlQ=
-github.com/hashicorp/vault/api v1.0.5-0.20191108163347-bdd38fca2cff/go.mod h1:Uf8LaHyrYsgVgHzO2tMZKhqRGlL3UJ6XaSwW2EA1Iqo=
github.com/hashicorp/vault/sdk v0.1.13/go.mod h1:B+hVj7TpuQY1Y/GPbCpffmgd+tSEwvhkWnjtSYCaS2M=
-github.com/hashicorp/vault/sdk v0.1.14-0.20191108161836-82f2b5571044/go.mod h1:PcekaFGiPJyHnFy+NZhP6ll650zEw51Ag7g/YEa+EOU=
github.com/hashicorp/vault/sdk v0.1.14-0.20191112033314-390e96e22eb2 h1:mKYi4Fm2uSfe94Ji89CoAaP7SPEEkfdtaUlgRGGb2go=
github.com/hashicorp/vault/sdk v0.1.14-0.20191112033314-390e96e22eb2/go.mod h1:PcekaFGiPJyHnFy+NZhP6ll650zEw51Ag7g/YEa+EOU=
github.com/hashicorp/vic v1.5.1-0.20190403131502-bbfe86ec9443 h1:O/pT5C1Q3mVXMyuqg7yuAWUg/jMZR1/0QTzTRdNR6Uw=
@@ -457,8 +461,9 @@
github.com/jinzhu/copier v0.0.0-20190625015134-976e0346caa8/go.mod h1:yL958EeXv8Ylng6IfnvG4oflryUi3vgA3xPs9hmII1s=
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af h1:pmfjZENx5imkbgOkpRUYLnmbU7UEFbjtDA2hxJ1ichM=
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
-github.com/jonboulle/clockwork v0.1.0 h1:VKV+ZcuP6l3yW9doeqz6ziZGgcynBVQO+obU0+0hcPo=
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
+github.com/jonboulle/clockwork v0.2.2 h1:UOGuzwb1PwsrDAObMuhUnj0p5ULPj8V/xJ7Kx9qUBdQ=
+github.com/jonboulle/clockwork v0.2.2/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8=
github.com/joyent/triton-go v0.0.0-20180628001255-830d2b111e62/go.mod h1:U+RSyWxWd04xTqnuOQxnai7XGS2PrPY2cfGoDKtMHjA=
github.com/joyent/triton-go v1.7.1-0.20200416154420-6801d15b779f h1:ENpDacvnr8faw5ugQmEF1QYk+f/Y9lXFvuYmRxykago=
github.com/joyent/triton-go v1.7.1-0.20200416154420-6801d15b779f/go.mod h1:KDSfL7qe5ZfQqvlDMkVjCztbmcpp/c8M77vhQP8ZPvk=
@@ -481,6 +486,7 @@
github.com/k0kubun/pp v3.0.1+incompatible/go.mod h1:GWse8YhT0p8pT4ir3ZgBbfZild3tgzSScAn6HmfYukg=
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
+github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
@@ -488,11 +494,11 @@
github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
-github.com/kr/pretty v0.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs=
github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
-github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
+github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
+github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/lestrrat/go-envload v0.0.0-20180220120943-6ed08b54a570 h1:0iQektZGS248WXmGIYOwRXSQhD4qn3icjMpuxwO7qlo=
github.com/lestrrat/go-envload v0.0.0-20180220120943-6ed08b54a570/go.mod h1:BLt8L9ld7wVsvEWQbuLrUZnCMnUmLZ+CGDzKtclrTlE=
github.com/lestrrat/go-file-rotatelogs v0.0.0-20180223000712-d3151e2a480f h1:sgUSP4zdTUZYZgAGGtN5Lxk92rK+JUFOwf+FT99EEI4=
@@ -507,8 +513,8 @@
github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ=
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
-github.com/magiconair/properties v1.8.4 h1:8KGKTcQQGm0Kv7vEbKFErAoAOFyyacLStRtQSeYtvkY=
-github.com/magiconair/properties v1.8.4/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60=
+github.com/magiconair/properties v1.8.5 h1:b6kJs+EmPFMYGkow9GiUyCyOvIwYetYJ3fSaWak/Gls=
+github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60=
github.com/mailru/easyjson v0.0.0-20160728113105-d5b7844b561a/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
@@ -569,8 +575,8 @@
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw=
-github.com/nacos-group/nacos-sdk-go v1.0.6 h1:0OqjS37qIKKKZKRQSJ5pNFGRrfzP7+gD4L6dvOkPFZw=
-github.com/nacos-group/nacos-sdk-go v1.0.6/go.mod h1:hlAPn3UdzlxIlSILAyOXKxjFSvDJ9oLzTJ9hLAK1KzA=
+github.com/nacos-group/nacos-sdk-go v1.0.7 h1:Am1tJFe7GUTNCREKsZ5ok0H2OspHDRmRcsxn7DiSwhA=
+github.com/nacos-group/nacos-sdk-go v1.0.7/go.mod h1:hlAPn3UdzlxIlSILAyOXKxjFSvDJ9oLzTJ9hLAK1KzA=
github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg=
github.com/nats-io/jwt v0.3.2/go.mod h1:/euKqTS1ZD+zzjYrY7pseZrTtWQSjujC7xjPc8wL6eU=
github.com/nats-io/nats-server/v2 v2.1.2/go.mod h1:Afk+wRZqkMQs/p45uXdrVLuab3gwv3Z8C4HTBu8GD/k=
@@ -580,6 +586,8 @@
github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c=
github.com/nicolai86/scaleway-sdk v1.10.2-0.20180628010248-798f60e20bb2 h1:BQ1HW7hr4IVovMwWg0E0PYcyW8CzqDcVmaew9cujU4s=
github.com/nicolai86/scaleway-sdk v1.10.2-0.20180628010248-798f60e20bb2/go.mod h1:TLb2Sg7HQcgGdloNxkrmtgDNR9uVYF3lfdFIN4Ro6Sk=
+github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
+github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs=
github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA=
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
@@ -623,9 +631,8 @@
github.com/philhofer/fwd v1.0.0 h1:UbZqGr5Y38ApvM/V/jEljVxwocdweyH+vmYvRPBnbqQ=
github.com/philhofer/fwd v1.0.0/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU=
github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc=
+github.com/pierrec/lz4 v2.0.5+incompatible h1:2xWsjqPFWcplujydGg4WmhC/6fZqK42wMM8aXeqhl0I=
github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
-github.com/pierrec/lz4 v2.2.6+incompatible h1:6aCX4/YZ9v8q69hTyiR7dNLnTA3fgtKHVVW5BCd5Znw=
-github.com/pierrec/lz4 v2.2.6+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
github.com/pkg/errors v0.8.0/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=
@@ -646,8 +653,8 @@
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og=
github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M=
-github.com/prometheus/client_golang v1.8.0 h1:zvJNkoCFAnYFNC24FV8nW4JdRJ3GIFcLbg65lL/JDcw=
-github.com/prometheus/client_golang v1.8.0/go.mod h1:O9VU6huf47PktckDQfMTX0Y8tY0/7TSWwj+ITvv0TnM=
+github.com/prometheus/client_golang v1.9.0 h1:Rrch9mh17XcxvEu9D9DEpb4isxjGBtcevQjKvxPRQIU=
+github.com/prometheus/client_golang v1.9.0/go.mod h1:FqZLKOZnGdFAhOK4nqGHa7D66IdsO+O441Eve7ptJDU=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
@@ -661,8 +668,8 @@
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt26CguLLsqA=
github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo=
-github.com/prometheus/common v0.14.0 h1:RHRyE8UocrbjU+6UvRzwi6HjiDfxrrBU91TtbKzkGp4=
-github.com/prometheus/common v0.14.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s=
+github.com/prometheus/common v0.15.0 h1:4fgOnadei3EZvgRwxJ7RMpG1k1pOZth5Pc13tyspaKM=
+github.com/prometheus/common v0.15.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s=
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=
@@ -678,6 +685,7 @@
github.com/renier/xmlrpc v0.0.0-20170708154548-ce4a1a486c03 h1:Wdi9nwnhFNAlseAOekn6B5G/+GMtks9UKbvRU/CMM/o=
github.com/renier/xmlrpc v0.0.0-20170708154548-ce4a1a486c03/go.mod h1:gRAiPF5C5Nd0eyyRdqIu9qTiFSoZzpTq727b5B8fkkU=
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
+github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rs/zerolog v1.4.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU=
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
@@ -739,9 +747,8 @@
github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
-github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48=
-github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
@@ -762,8 +769,9 @@
github.com/tinylib/msgp v1.1.0 h1:9fQd+ICuRIu/ue4vxJZu6/LzxN0HwMds2nq/0cFvxHU=
github.com/tinylib/msgp v1.1.0/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE=
github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
-github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5 h1:LnC5Kc/wtumK+WB441p7ynQJzVuNRJiqddSIE3IlSEQ=
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
+github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802 h1:uruHq4dN7GR16kFc5fp3d1RIYzJW5onx8Ybykw2YQFA=
+github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
github.com/toolkits/concurrent v0.0.0-20150624120057-a4371d70e3e3 h1:kF/7m/ZU+0D4Jj5eZ41Zm3IH/J8OElK1Qtd7tVKAwLk=
github.com/toolkits/concurrent v0.0.0-20150624120057-a4371d70e3e3/go.mod h1:QDlpd3qS71vYtakd2hmdpqhJ9nwv6mD6A30bQ1BPBFE=
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926 h1:G3dpKMzFDjgEh2q1Z7zUUtKa8ViPtH+ocF0bE0g00O8=
@@ -779,11 +787,11 @@
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 h1:eY9dn8+vbi4tKz5Qo6v2eYzo7kUS51QINcR5jNpbZS8=
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
+github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/zouyx/agollo/v3 v3.4.5 h1:7YCxzY9ZYaH9TuVUBvmI6Tk0mwMggikah+cfbYogcHQ=
github.com/zouyx/agollo/v3 v3.4.5/go.mod h1:LJr3kDmm23QSW+F1Ol4TMHDa7HvJvscMdVxJ2IpUTVc=
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
-go.etcd.io/bbolt v1.3.3 h1:MUGmc65QhB3pIlaQ5bB4LwqSj6GIonVJXpZiaKNyaKk=
go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
go.etcd.io/bbolt v1.3.4 h1:hi1bXHMVrlQh6WwxAy+qZCV/SYIlqo+Ushwdpa4tAKg=
go.etcd.io/bbolt v1.3.4/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ=
@@ -831,6 +839,7 @@
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek=
golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY=
+golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw=
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
@@ -847,6 +856,8 @@
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY=
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
+golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
+golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20170114055629-f2499483f923/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
@@ -872,22 +883,26 @@
golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20191004110552-13f9640d40b9/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20200421231249-e086a090c8fd/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-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
-golang.org/x/net v0.0.0-20200822124328-c89045814202 h1:VvcQYSHwXgi7W+TpUR6A9g6Up98WAHf3f/ulnJ62IyA=
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
+golang.org/x/net v0.0.0-20201021035429-f5854403a974 h1:IX6qOQeG5uLjB/hjjwjedwfjND0hgjPMMyO1RoIXQNI=
+golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
-golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 h1:SVwTIAaPC2U/AvvLNZ2a7OVsmBpC8L5BlwK1whH3hm0=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
+golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d h1:TzXSXBo42m9gQenoE3b9BGiEpg5IG2JkU5FkPIawgtw=
+golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
-golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208 h1:qwRHBd0NqMbJxfbotnDhm2ByMI1Shq4Y6oRJo21SGJA=
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9 h1:SQFwaSi55rU7vdNs9Yr0Z324VNlrF+0wMqRXT4St8ck=
+golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20170830134202-bb24a47a89ea/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
@@ -918,6 +933,7 @@
golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190922100055-0a153f010e69/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/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=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -928,23 +944,26 @@
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200420163511-1957bb5e6d1f/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-20201015000850-e3ed0017c211 h1:9UQO31fZ+0aKQOFldThf7BKPMJTiBfWycGh/u3UoO88=
-golang.org/x/sys v0.0.0-20201015000850-e3ed0017c211/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20201214210602-f9fddec55a1e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201223074533-0d417f636930 h1:vRgIt+nup/B/BwIS0g2oC0haq0iqbV3ZA+u6+0TlNCo=
golang.org/x/sys v0.0.0-20201223074533-0d417f636930/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
-golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
+golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
+golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
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 h1:/5xXl8Y5W96D+TtHSlonuFqGHIWVuyCkGJLwGh9JJFs=
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/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=
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
@@ -972,8 +991,11 @@
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
-golang.org/x/tools v0.0.0-20200928182047-19e03678916f h1:VwGa2Wf+rHGIxvsssCkUNIyFv8jQY0VCBCNWtikoWq0=
+golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
+golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20200928182047-19e03678916f/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU=
+golang.org/x/tools v0.0.0-20210106214847-113979e3529a h1:CB3a9Nez8M13wwlr/E2YtwoU+qYHKfC+JrDa45RXXoQ=
+golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
@@ -1003,8 +1025,10 @@
google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8=
-google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a h1:Ob5/580gVHBJZgXnff1cZDbG+xLtMVE5mDRTe+nIsX4=
google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
+google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
+google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884 h1:fiNLklpBwWK1mth30Hlwk+fcdBmIALlgF5iy77O37Ig=
+google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
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=
@@ -1017,8 +1041,11 @@
google.golang.org/grpc v1.22.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
google.golang.org/grpc v1.23.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
+google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
google.golang.org/grpc v1.26.0 h1:2dTRdpdFEEhJYQD8EMLB61nnrzSCTbG38PhqdhvOltg=
google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
+google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
+google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
@@ -1031,8 +1058,9 @@
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=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
-gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU=
+gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=
@@ -1055,6 +1083,7 @@
gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
@@ -1082,14 +1111,14 @@
k8s.io/klog v0.3.0/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk=
k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8=
k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I=
+k8s.io/kube-openapi v0.0.0-20190816220812-743ec37842bf h1:EYm5AW/UUDbnmnI+gK0TJDVK9qPLhM+sRHYanNKw0EQ=
k8s.io/kube-openapi v0.0.0-20190816220812-743ec37842bf/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E=
-k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a h1:UcxjrRMyNx/i/y8G7kPvLyy7rfbeuf1PYyBf973pgyU=
-k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E=
k8s.io/utils v0.0.0-20190801114015-581e00157fb1 h1:+ySTxfHnfzZb9ys375PXNlLhkJPLKgHajBU0N62BDvE=
k8s.io/utils v0.0.0-20190801114015-581e00157fb1/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew=
launchpad.net/gocheck v0.0.0-20140225173054-000000000087/go.mod h1:hj7XX3B/0A+80Vse0e+BUHsHMTEhd0O4cpUHr/e/BUM=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI=
-sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs=
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
+sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q=
+sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc=
sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU=
diff --git a/metadata/definition/mock.go b/metadata/definition/mock.go
index ca9e125..02f969c 100644
--- a/metadata/definition/mock.go
+++ b/metadata/definition/mock.go
@@ -29,8 +29,7 @@
Time time.Time
}
-type UserProvider struct {
-}
+type UserProvider struct{}
func (u *UserProvider) GetUser(ctx context.Context, req []interface{}) (*User, error) {
rsp := User{"A001", "Alex Stocks", 18, time.Now()}
diff --git a/metadata/identifier/base_metadata_identifier.go b/metadata/identifier/base_metadata_identifier.go
index 2371f7c..47c2e93 100644
--- a/metadata/identifier/base_metadata_identifier.go
+++ b/metadata/identifier/base_metadata_identifier.go
@@ -68,7 +68,6 @@
withPathSeparator(mdi.Group) +
withPathSeparator(mdi.Side) +
joinParams(constant.PATH_SEPARATOR, params)
-
}
// serviceToPath uss URL encode to decode the @serviceInterface
@@ -82,7 +81,6 @@
}
return string(decoded)
}
-
}
// withPathSeparator return "/" + @path
diff --git a/metadata/mapping/dynamic/service_name_mapping_test.go b/metadata/mapping/dynamic/service_name_mapping_test.go
index af21704..d98a893 100644
--- a/metadata/mapping/dynamic/service_name_mapping_test.go
+++ b/metadata/mapping/dynamic/service_name_mapping_test.go
@@ -33,7 +33,6 @@
)
func TestDynamicConfigurationServiceNameMapping(t *testing.T) {
-
// mock data
appName := "myApp"
dc, err := (&config_center.MockDynamicConfigurationFactory{
diff --git a/metadata/mapping/memory/service_name_mapping.go b/metadata/mapping/memory/service_name_mapping.go
index 0965d52..8017ec7 100644
--- a/metadata/mapping/memory/service_name_mapping.go
+++ b/metadata/mapping/memory/service_name_mapping.go
@@ -24,6 +24,7 @@
import (
gxset "github.com/dubbogo/gost/container/set"
)
+
import (
"github.com/apache/dubbo-go/common/extension"
"github.com/apache/dubbo-go/config"
@@ -44,8 +45,10 @@
return gxset.NewSet(config.GetApplicationConfig().Name), nil
}
-var serviceNameMappingInstance *InMemoryServiceNameMapping
-var serviceNameMappingOnce sync.Once
+var (
+ serviceNameMappingInstance *InMemoryServiceNameMapping
+ serviceNameMappingOnce sync.Once
+)
func GetNameMappingInstance() mapping.ServiceNameMapping {
serviceNameMappingOnce.Do(func() {
diff --git a/metadata/report/consul/report.go b/metadata/report/consul/report.go
index e211f7f..0c9f9cb 100644
--- a/metadata/report/consul/report.go
+++ b/metadata/report/consul/report.go
@@ -29,9 +29,7 @@
"github.com/apache/dubbo-go/metadata/report/factory"
)
-var (
- emptyStrSlice = make([]string, 0)
-)
+var emptyStrSlice = make([]string, 0)
func init() {
mf := &consulMetadataReportFactory{}
@@ -111,8 +109,7 @@
return string(kv.Value), nil
}
-type consulMetadataReportFactory struct {
-}
+type consulMetadataReportFactory struct{}
// nolint
func (mf *consulMetadataReportFactory) CreateMetadataReport(url *common.URL) report.MetadataReport {
diff --git a/metadata/report/delegate/delegate_report.go b/metadata/report/delegate/delegate_report.go
index 56a22de..2cd9af8 100644
--- a/metadata/report/delegate/delegate_report.go
+++ b/metadata/report/delegate/delegate_report.go
@@ -125,7 +125,6 @@
url.GetParamInt(constant.RETRY_TIMES_KEY, defaultMetadataReportRetryTimes),
bmr.retry,
)
-
if err != nil {
return nil, err
}
@@ -139,7 +138,6 @@
bmr.allMetadataReportsLock.RLock()
bmr.doHandlerMetadataCollection(bmr.allMetadataReports)
bmr.allMetadataReportsLock.RUnlock()
-
})
if err != nil {
return nil, err
diff --git a/metadata/report/delegate/delegate_report_test.go b/metadata/report/delegate/delegate_report_test.go
index f60acf6..f2c7376 100644
--- a/metadata/report/delegate/delegate_report_test.go
+++ b/metadata/report/delegate/delegate_report_test.go
@@ -87,7 +87,7 @@
func TestMetadataReport_StoreProviderMetadata(t *testing.T) {
mtr := mockNewMetadataReport(t)
- var metadataId = &identifier.MetadataIdentifier{
+ metadataId := &identifier.MetadataIdentifier{
Application: "app",
BaseMetadataIdentifier: identifier.BaseMetadataIdentifier{
ServiceInterface: "com.ikurento.user.UserProvider",
diff --git a/metadata/report/etcd/report.go b/metadata/report/etcd/report.go
index 1939b91..604e6da 100644
--- a/metadata/report/etcd/report.go
+++ b/metadata/report/etcd/report.go
@@ -23,6 +23,10 @@
)
import (
+ gxetcd "github.com/dubbogo/gost/database/kv/etcd/v3"
+)
+
+import (
"github.com/apache/dubbo-go/common"
"github.com/apache/dubbo-go/common/constant"
"github.com/apache/dubbo-go/common/extension"
@@ -30,7 +34,6 @@
"github.com/apache/dubbo-go/metadata/identifier"
"github.com/apache/dubbo-go/metadata/report"
"github.com/apache/dubbo-go/metadata/report/factory"
- "github.com/apache/dubbo-go/remoting/etcdv3"
)
const DEFAULT_ROOT = "dubbo"
@@ -43,7 +46,7 @@
// etcdMetadataReport is the implementation of MetadataReport based etcd
type etcdMetadataReport struct {
- client *etcdv3.Client
+ client *gxetcd.Client
root string
}
@@ -121,7 +124,7 @@
func (e *etcdMetadataReportFactory) CreateMetadataReport(url *common.URL) report.MetadataReport {
timeout, _ := time.ParseDuration(url.GetParam(constant.REGISTRY_TIMEOUT_KEY, constant.DEFAULT_REG_TIMEOUT))
addresses := strings.Split(url.Location, ",")
- client, err := etcdv3.NewClient(etcdv3.MetadataETCDV3Client, addresses, timeout, 1)
+ client, err := gxetcd.NewClient(gxetcd.MetadataETCDV3Client, addresses, timeout, 1)
if err != nil {
logger.Errorf("Could not create etcd metadata report. URL: %s,error:{%v}", url.String(), err)
return nil
diff --git a/metadata/report/etcd/report_test.go b/metadata/report/etcd/report_test.go
index 59d0975..5361494 100644
--- a/metadata/report/etcd/report_test.go
+++ b/metadata/report/etcd/report_test.go
@@ -105,7 +105,6 @@
Revision: "subscribe",
MetadataIdentifier: *newMetadataIdentifier("provider"),
}
-
}
func newServiceMetadataIdentifier() *identifier.ServiceMetadataIdentifier {
diff --git a/metadata/report/factory/report_factory.go b/metadata/report/factory/report_factory.go
index 9f00007..df2cf74 100644
--- a/metadata/report/factory/report_factory.go
+++ b/metadata/report/factory/report_factory.go
@@ -27,5 +27,4 @@
CreateMetadataReport(*common.URL) report.MetadataReport
}
-type BaseMetadataReportFactory struct {
-}
+type BaseMetadataReportFactory struct{}
diff --git a/metadata/report/nacos/report.go b/metadata/report/nacos/report.go
index 42e9859..f62d02f 100644
--- a/metadata/report/nacos/report.go
+++ b/metadata/report/nacos/report.go
@@ -173,8 +173,7 @@
return cfg, nil
}
-type nacosMetadataReportFactory struct {
-}
+type nacosMetadataReportFactory struct{}
// nolint
func (n *nacosMetadataReportFactory) CreateMetadataReport(url *common.URL) report.MetadataReport {
diff --git a/metadata/report/zookeeper/report.go b/metadata/report/zookeeper/report.go
index 5d5e740..580be91 100644
--- a/metadata/report/zookeeper/report.go
+++ b/metadata/report/zookeeper/report.go
@@ -23,18 +23,19 @@
)
import (
+ gxzookeeper "github.com/dubbogo/gost/database/kv/zk"
+)
+
+import (
"github.com/apache/dubbo-go/common"
"github.com/apache/dubbo-go/common/constant"
"github.com/apache/dubbo-go/common/extension"
"github.com/apache/dubbo-go/metadata/identifier"
"github.com/apache/dubbo-go/metadata/report"
"github.com/apache/dubbo-go/metadata/report/factory"
- "github.com/apache/dubbo-go/remoting/zookeeper"
)
-var (
- emptyStrSlice = make([]string, 0)
-)
+var emptyStrSlice = make([]string, 0)
func init() {
mf := &zookeeperMetadataReportFactory{}
@@ -46,7 +47,7 @@
// zookeeperMetadataReport is the implementation of
// MetadataReport based on zookeeper.
type zookeeperMetadataReport struct {
- client *zookeeper.ZookeeperClient
+ client *gxzookeeper.ZookeeperClient
rootDir string
}
@@ -107,15 +108,15 @@
return string(v), err
}
-type zookeeperMetadataReportFactory struct {
-}
+type zookeeperMetadataReportFactory struct{}
// nolint
func (mf *zookeeperMetadataReportFactory) CreateMetadataReport(url *common.URL) report.MetadataReport {
- client, err := zookeeper.NewZookeeperClient(
+ client, err := gxzookeeper.NewZookeeperClient(
"zookeeperMetadataReport",
strings.Split(url.Location, ","),
- 15*time.Second,
+ false,
+ gxzookeeper.WithZkTimeOut(15*time.Second),
)
if err != nil {
panic(err)
diff --git a/metadata/service/exporter/configurable/exporter_test.go b/metadata/service/exporter/configurable/exporter_test.go
index 7c2baa2..9b2c8e4 100644
--- a/metadata/service/exporter/configurable/exporter_test.go
+++ b/metadata/service/exporter/configurable/exporter_test.go
@@ -52,7 +52,8 @@
WaitTimeout: "1s",
MaxMsgLen: 10240000000,
SessionName: "server",
- }})
+ },
+ })
mockInitProviderWithSingleRegistry()
metadataService, _ := inmemory.NewMetadataService()
exported := NewMetadataServiceExporter(metadataService)
@@ -86,7 +87,8 @@
Module: "module",
Version: "1.0.0",
Owner: "dubbo",
- Environment: "test"},
+ Environment: "test",
+ },
},
Registry: &config.RegistryConfig{
diff --git a/metadata/service/inmemory/metadata_service_proxy_factory_test.go b/metadata/service/inmemory/metadata_service_proxy_factory_test.go
index f5e519c..5f62035 100644
--- a/metadata/service/inmemory/metadata_service_proxy_factory_test.go
+++ b/metadata/service/inmemory/metadata_service_proxy_factory_test.go
@@ -63,8 +63,7 @@
assert.NotNil(t, pxy)
}
-type mockProtocol struct {
-}
+type mockProtocol struct{}
func (m mockProtocol) Export(protocol.Invoker) protocol.Exporter {
panic("implement me")
@@ -78,8 +77,7 @@
panic("implement me")
}
-type mockInvoker struct {
-}
+type mockInvoker struct{}
func (m *mockInvoker) GetUrl() *common.URL {
panic("implement me")
diff --git a/metadata/service/inmemory/service_proxy.go b/metadata/service/inmemory/service_proxy.go
index 8b93aab..fadf998 100644
--- a/metadata/service/inmemory/service_proxy.go
+++ b/metadata/service/inmemory/service_proxy.go
@@ -40,11 +40,10 @@
// for now, only GetExportedURLs need to be implemented
type MetadataServiceProxy struct {
invkr protocol.Invoker
- //golangServer bool
+ // golangServer bool
}
func (m *MetadataServiceProxy) GetExportedURLs(serviceInterface string, group string, version string, protocol string) ([]interface{}, error) {
-
siV := reflect.ValueOf(serviceInterface)
gV := reflect.ValueOf(group)
vV := reflect.ValueOf(version)
diff --git a/metadata/service/inmemory/service_proxy_test.go b/metadata/service/inmemory/service_proxy_test.go
index 9278fd9..c697faf 100644
--- a/metadata/service/inmemory/service_proxy_test.go
+++ b/metadata/service/inmemory/service_proxy_test.go
@@ -35,13 +35,11 @@
)
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)
assert.Nil(t, err)
assert.Len(t, res, 1)
-
}
// TestNewMetadataService: those methods are not implemented
diff --git a/metadata/service/remote/service.go b/metadata/service/remote/service.go
index e2a7a64..95e5c7f 100644
--- a/metadata/service/remote/service.go
+++ b/metadata/service/remote/service.go
@@ -109,7 +109,7 @@
func (mts *MetadataService) UnsubscribeURL(url *common.URL) error {
// TODO remove call local.
return nil
- //return mts.UnsubscribeURL(url)
+ // return mts.UnsubscribeURL(url)
}
// PublishServiceDefinition will call remote metadata's StoreProviderMetadata to store url info and service definition
diff --git a/metadata/service/remote/service_proxy.go b/metadata/service/remote/service_proxy.go
index e0cd6e0..241b3fc 100644
--- a/metadata/service/remote/service_proxy.go
+++ b/metadata/service/remote/service_proxy.go
@@ -20,6 +20,7 @@
import (
"strings"
)
+
import (
"github.com/apache/dubbo-go/common"
"github.com/apache/dubbo-go/common/constant"
@@ -81,7 +82,6 @@
Revision: m.revision,
Protocol: protocol,
})
-
if err != nil {
return []interface{}{}, nil
}
diff --git a/metadata/service/remote/service_proxy_test.go b/metadata/service/remote/service_proxy_test.go
index 1899d02..6edbab5 100644
--- a/metadata/service/remote/service_proxy_test.go
+++ b/metadata/service/remote/service_proxy_test.go
@@ -20,6 +20,7 @@
import (
"testing"
)
+
import (
"github.com/stretchr/testify/assert"
)
@@ -79,7 +80,6 @@
}
func createProxy() service.MetadataService {
-
prepareTest()
ins := ®istry.DefaultServiceInstance{
@@ -102,15 +102,13 @@
instance.GetMetadataReportInstance(u)
}
-type mockMetadataReportFactory struct {
-}
+type mockMetadataReportFactory struct{}
func (m *mockMetadataReportFactory) CreateMetadataReport(*common.URL) report.MetadataReport {
return &mockMetadataReport{}
}
-type mockMetadataReport struct {
-}
+type mockMetadataReport struct{}
func (m mockMetadataReport) StoreProviderMetadata(*identifier.MetadataIdentifier, string) error {
panic("implement me")
diff --git a/metadata/service/remote/service_test.go b/metadata/service/remote/service_test.go
index d602815..d9e4d14 100644
--- a/metadata/service/remote/service_test.go
+++ b/metadata/service/remote/service_test.go
@@ -47,15 +47,13 @@
return &metadataReportFactory{}
}
-type metadataReportFactory struct {
-}
+type metadataReportFactory struct{}
func (mrf *metadataReportFactory) CreateMetadataReport(*common.URL) report.MetadataReport {
return &metadataReport{}
}
-type metadataReport struct {
-}
+type metadataReport struct{}
func (metadataReport) StoreProviderMetadata(*identifier.MetadataIdentifier, string) error {
return nil
diff --git a/protocol/dubbo/dubbo_codec.go b/protocol/dubbo/dubbo_codec.go
index 21376c3..6c367c7 100644
--- a/protocol/dubbo/dubbo_codec.go
+++ b/protocol/dubbo/dubbo_codec.go
@@ -36,7 +36,7 @@
"github.com/apache/dubbo-go/remoting"
)
-//SerialID serial ID
+// SerialID serial ID
type SerialID byte
func init() {
@@ -46,8 +46,7 @@
}
// DubboCodec. It is implements remoting.Codec
-type DubboCodec struct {
-}
+type DubboCodec struct{}
// encode request for transport
func (c *DubboCodec) EncodeRequest(request *remoting.Request) (*bytes.Buffer, error) {
@@ -129,7 +128,7 @@
// encode response
func (c *DubboCodec) EncodeResponse(response *remoting.Response) (*bytes.Buffer, error) {
- var ptype = impl.PackageResponse
+ ptype := impl.PackageResponse
if response.IsHeartbeat() {
ptype = impl.PackageHeartbeat
}
@@ -190,7 +189,7 @@
if err != nil {
originErr := perrors.Cause(err)
if originErr == hessian.ErrHeaderNotEnough || originErr == hessian.ErrBodyNotEnough {
- //FIXME
+ // FIXME
return nil, 0, originErr
}
logger.Errorf("pkg.Unmarshal(len(@data):%d) = error:%+v", buf.Len(), err)
@@ -207,19 +206,19 @@
// convert params of request
req := pkg.Body.(map[string]interface{})
- //invocation := request.Data.(*invocation.RPCInvocation)
+ // invocation := request.Data.(*invocation.RPCInvocation)
var methodName string
var args []interface{}
attachments := make(map[string]interface{})
if req[impl.DubboVersionKey] != nil {
- //dubbo version
+ // dubbo version
request.Version = req[impl.DubboVersionKey].(string)
}
- //path
+ // path
attachments[constant.PATH_KEY] = pkg.Service.Path
- //version
+ // version
attachments[constant.VERSION_KEY] = pkg.Service.Version
- //method
+ // method
methodName = pkg.Service.Method
args = req[impl.ArgsKey].([]interface{})
attachments = req[impl.AttachmentsKey].(map[string]interface{})
@@ -248,7 +247,7 @@
}
response := &remoting.Response{
ID: pkg.Header.ID,
- //Version: pkg.Header.,
+ // Version: pkg.Header.,
SerialID: pkg.Header.SerialID,
Status: pkg.Header.ResponseStatus,
Event: (pkg.Header.Type & impl.PackageHeartbeat) != 0,
@@ -264,7 +263,7 @@
} else {
logger.Debugf("get rpc heartbeat request{header: %#v, service: %#v, body: %#v}", pkg.Header, pkg.Service, pkg.Body)
response.Status = hessian.Response_OK
- //reply(session, p, hessian.PackageHeartbeat)
+ // reply(session, p, hessian.PackageHeartbeat)
}
return response, hessian.HEADER_LENGTH + pkg.Header.BodyLen, error
}
diff --git a/protocol/dubbo/dubbo_invoker.go b/protocol/dubbo/dubbo_invoker.go
index 231db38..12bab31 100644
--- a/protocol/dubbo/dubbo_invoker.go
+++ b/protocol/dubbo/dubbo_invoker.go
@@ -39,10 +39,10 @@
"github.com/apache/dubbo-go/remoting"
)
-var (
- attachmentKey = []string{constant.INTERFACE_KEY, constant.GROUP_KEY, constant.TOKEN_KEY, constant.TIMEOUT_KEY,
- constant.VERSION_KEY}
-)
+var attachmentKey = []string{
+ constant.INTERFACE_KEY, constant.GROUP_KEY, constant.TOKEN_KEY, constant.TIMEOUT_KEY,
+ constant.VERSION_KEY,
+}
// DubboInvoker is implement of protocol.Invoker. A dubboInvoker refers to one service and ip.
type DubboInvoker struct {
@@ -141,7 +141,7 @@
logger.Errorf("ParseBool - error: %v", err)
async = false
}
- //response := NewResponse(inv.Reply(), nil)
+ // response := NewResponse(inv.Reply(), nil)
rest := &protocol.RPCResult{}
timeout := di.getTimeout(inv)
if async {
@@ -168,7 +168,7 @@
// get timeout including methodConfig
func (di *DubboInvoker) getTimeout(invocation *invocation_impl.RPCInvocation) time.Duration {
- var timeout = di.GetUrl().GetParam(strings.Join([]string{constant.METHOD_KEYS, invocation.MethodName(), constant.TIMEOUT_KEY}, "."), "")
+ timeout := di.GetUrl().GetParam(strings.Join([]string{constant.METHOD_KEYS, invocation.MethodName(), constant.TIMEOUT_KEY}, "."), "")
if len(timeout) != 0 {
if t, err := time.ParseDuration(timeout); err == nil {
// config timeout into attachment
@@ -196,8 +196,12 @@
di.BaseInvoker.Destroy()
client := di.getClient()
if client != nil {
+ activeNumber := client.DecreaseActiveNumber()
di.setClient(nil)
- client.Close()
+ if activeNumber == 0 {
+ exchangeClientMap.Delete(di.GetUrl().Location)
+ client.Close()
+ }
}
})
}
diff --git a/protocol/dubbo/dubbo_invoker_test.go b/protocol/dubbo/dubbo_invoker_test.go
index fecb3b0..cfa81ca 100644
--- a/protocol/dubbo/dubbo_invoker_test.go
+++ b/protocol/dubbo/dubbo_invoker_test.go
@@ -70,7 +70,7 @@
r := response.(remoting.AsyncCallbackResponse)
rst := *r.Reply.(*remoting.Response).Result.(*protocol.RPCResult)
assert.Equal(t, User{Id: "1", Name: "username"}, *(rst.Rest.(*User)))
- //assert.Equal(t, User{ID: "1", Name: "username"}, *r.Reply.(*Response).reply.(*User))
+ // assert.Equal(t, User{ID: "1", Name: "username"}, *r.Reply.(*Response).reply.(*User))
lock.Unlock()
})
res = invoker.Invoke(context.Background(), inv)
@@ -94,7 +94,6 @@
}
func InitTest(t *testing.T) (protocol.Protocol, *common.URL) {
-
hessian.RegisterPOJO(&User{})
methods, err := common.ServiceMap.Register("com.ikurento.user.UserProvider", "dubbo", "", "", &UserProvider{})
@@ -139,7 +138,8 @@
WaitTimeout: "1s",
MaxMsgLen: 10240000000,
SessionName: "server",
- }})
+ },
+ })
// Export
proto := GetProtocol()
@@ -168,8 +168,7 @@
Name string `json:"name"`
}
- UserProvider struct {
- //user map[string]User
+ UserProvider struct { // user map[string]User
}
)
@@ -209,7 +208,6 @@
}
func (u *UserProvider) GetUser4(ctx context.Context, req []interface{}) ([]interface{}, error) {
-
return []interface{}{User{Id: req[0].([]interface{})[0].(string), Name: req[0].([]interface{})[1].(string)}}, nil
}
diff --git a/protocol/dubbo/dubbo_protocol.go b/protocol/dubbo/dubbo_protocol.go
index 1f7cd50..ce0ce47 100644
--- a/protocol/dubbo/dubbo_protocol.go
+++ b/protocol/dubbo/dubbo_protocol.go
@@ -56,9 +56,7 @@
extension.SetProtocol(DUBBO, GetProtocol)
}
-var (
- dubboProtocol *DubboProtocol
-)
+var dubboProtocol *DubboProtocol
// It support dubbo protocol. It implements Protocol interface for dubbo protocol.
type DubboProtocol struct {
@@ -152,7 +150,7 @@
err := fmt.Errorf("don't have this exporter, key: %s", rpcInvocation.ServiceKey())
logger.Errorf(err.Error())
result.Err = err
- //reply(session, p, hessian.PackageResponse)
+ // reply(session, p, hessian.PackageResponse)
return result
}
invoker := exporter.(protocol.Exporter).GetInvoker()
@@ -163,12 +161,12 @@
invokeResult := invoker.Invoke(ctx, rpcInvocation)
if err := invokeResult.Error(); err != nil {
result.Err = invokeResult.Error()
- //p.Header.ResponseStatus = hessian.Response_OK
- //p.Body = hessian.NewResponse(nil, err, result.Attachments())
+ // p.Header.ResponseStatus = hessian.Response_OK
+ // p.Body = hessian.NewResponse(nil, err, result.Attachments())
} else {
result.Rest = invokeResult.Result()
- //p.Header.ResponseStatus = hessian.Response_OK
- //p.Body = hessian.NewResponse(res, nil, result.Attachments())
+ // p.Header.ResponseStatus = hessian.Response_OK
+ // p.Body = hessian.NewResponse(res, nil, result.Attachments())
}
} else {
result.Err = fmt.Errorf("don't have the invoker, key: %s", rpcInvocation.ServiceKey())
@@ -215,7 +213,9 @@
if clientTmp == nil {
return nil
}
- return clientTmp.(*remoting.ExchangeClient)
+ exchangeClient := clientTmp.(*remoting.ExchangeClient)
+ exchangeClient.IncreaseActiveNumber()
+ return exchangeClient
}
// rebuildCtx rebuild the context by attachment.
diff --git a/protocol/dubbo/dubbo_protocol_test.go b/protocol/dubbo/dubbo_protocol_test.go
index 9eba90e..f564c6d 100644
--- a/protocol/dubbo/dubbo_protocol_test.go
+++ b/protocol/dubbo/dubbo_protocol_test.go
@@ -58,7 +58,8 @@
WaitTimeout: "1s",
MaxMsgLen: 10240000000,
SessionName: "server",
- }})
+ },
+ })
getty.SetClientConf(getty.ClientConfig{
ConnectionNum: 1,
HeartbeatPeriod: "3s",
diff --git a/protocol/dubbo/hessian2/hessian_dubbo.go b/protocol/dubbo/hessian2/hessian_dubbo.go
index 5ffebde..f61733f 100644
--- a/protocol/dubbo/hessian2/hessian_dubbo.go
+++ b/protocol/dubbo/hessian2/hessian_dubbo.go
@@ -107,7 +107,6 @@
// ReadHeader uses hessian codec to read dubbo header
func (h *HessianCodec) ReadHeader(header *DubboHeader) error {
-
var err error
if h.reader.Size() < HEADER_LENGTH {
@@ -169,12 +168,10 @@
}
return perrors.WithStack(err)
-
}
// ReadBody uses hessian codec to read response body
func (h *HessianCodec) ReadBody(rspObj interface{}) error {
-
if h.reader.Buffered() < h.bodyLen {
return ErrBodyNotEnough
}
diff --git a/protocol/dubbo/hessian2/hessian_dubbo_test.go b/protocol/dubbo/hessian2/hessian_dubbo_test.go
index eaaf500..e603b00 100644
--- a/protocol/dubbo/hessian2/hessian_dubbo_test.go
+++ b/protocol/dubbo/hessian2/hessian_dubbo_test.go
@@ -54,7 +54,7 @@
return "com.test.casea"
}
-//JavaClassName java fully qualified path
+// JavaClassName java fully qualified path
func (c Case) JavaClassName() string {
return "com.test.case"
}
diff --git a/protocol/dubbo/hessian2/hessian_request.go b/protocol/dubbo/hessian2/hessian_request.go
index 94aa34d..7c4849f 100644
--- a/protocol/dubbo/hessian2/hessian_request.go
+++ b/protocol/dubbo/hessian2/hessian_request.go
@@ -274,7 +274,6 @@
// hessian decode request body
func unpackRequestBody(decoder *hessian.Decoder, reqObj interface{}) error {
-
if decoder == nil {
return perrors.Errorf("@decoder is nil")
}
diff --git a/protocol/dubbo/hessian2/hessian_response.go b/protocol/dubbo/hessian2/hessian_response.go
index b95e1c2..bed8dad 100644
--- a/protocol/dubbo/hessian2/hessian_response.go
+++ b/protocol/dubbo/hessian2/hessian_response.go
@@ -18,11 +18,12 @@
import (
"encoding/binary"
- "github.com/apache/dubbo-go/common/logger"
"math"
"reflect"
"strconv"
"strings"
+
+ "github.com/apache/dubbo-go/common/logger"
)
import (
@@ -64,9 +65,7 @@
// https://github.com/apache/dubbo/blob/dubbo-2.7.1/dubbo-remoting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/exchange/codec/ExchangeCodec.java#L256
// hessian encode response
func packResponse(header DubboHeader, ret interface{}) ([]byte, error) {
- var (
- byteArray []byte
- )
+ var byteArray []byte
response := EnsureResponse(ret)
@@ -362,7 +361,7 @@
if !ok || len(version) == 0 {
return 0
}
- var v = 0
+ v := 0
varr := strings.Split(version, ".")
length := len(varr)
for key, value := range varr {
diff --git a/protocol/dubbo/hessian2/hessian_response_test.go b/protocol/dubbo/hessian2/hessian_response_test.go
index f5c84ba..86c2e43 100644
--- a/protocol/dubbo/hessian2/hessian_response_test.go
+++ b/protocol/dubbo/hessian2/hessian_response_test.go
@@ -93,7 +93,7 @@
var s1r []string
doTestReflectResponse(t, s1, &s1r)
- s2 := []rr{rr{"dubbo", 666}, rr{"go", 999}}
+ s2 := []rr{{"dubbo", 666}, {"go", 999}}
var s2r []rr
doTestReflectResponse(t, s2, &s2r)
@@ -221,5 +221,4 @@
v = version2Int("2.1.3.4.5")
assert.Equal(t, 201030405, v)
-
}
diff --git a/protocol/dubbo/impl/codec.go b/protocol/dubbo/impl/codec.go
index 6c9816f..d4f3804 100644
--- a/protocol/dubbo/impl/codec.go
+++ b/protocol/dubbo/impl/codec.go
@@ -238,9 +238,7 @@
}
func packResponse(p DubboPackage, serializer Serializer) ([]byte, error) {
- var (
- byteArray []byte
- )
+ var byteArray []byte
header := p.Header
hb := p.IsHeartBeat()
diff --git a/protocol/dubbo/impl/hessian.go b/protocol/dubbo/impl/hessian.go
index e355276..2f750c5 100644
--- a/protocol/dubbo/impl/hessian.go
+++ b/protocol/dubbo/impl/hessian.go
@@ -37,8 +37,7 @@
"github.com/apache/dubbo-go/common/logger"
)
-type HessianSerializer struct {
-}
+type HessianSerializer struct{}
func (h HessianSerializer) Marshal(p DubboPackage) ([]byte, error) {
encoder := hessian.NewEncoder()
@@ -178,7 +177,7 @@
}
func version2Int(version string) int {
- var v = 0
+ v := 0
varr := strings.Split(version, ".")
length := len(varr)
for key, value := range varr {
@@ -254,6 +253,10 @@
return perrors.WithStack(err)
}
+ if attachments == nil {
+ attachments = map[interface{}]interface{}{constant.INTERFACE_KEY: target}
+ }
+
if v, ok := attachments.(map[interface{}]interface{}); ok {
v[DUBBO_VERSION_KEY] = dubboVersion
req[6] = ToMapStringInterface(v)
diff --git a/protocol/dubbo/opentracing.go b/protocol/dubbo/opentracing.go
index f45e6fd..bc27050 100644
--- a/protocol/dubbo/opentracing.go
+++ b/protocol/dubbo/opentracing.go
@@ -20,6 +20,7 @@
import (
"github.com/opentracing/opentracing-go"
)
+
import (
invocation_impl "github.com/apache/dubbo-go/protocol/invocation"
)
@@ -36,7 +37,7 @@
}
func filterContext(attachments map[string]interface{}) map[string]string {
- var traceAttchment = make(map[string]string)
+ traceAttchment := make(map[string]string)
for k, v := range attachments {
if r, ok := v.(string); ok {
traceAttchment[k] = r
diff --git a/protocol/grpc/client.go b/protocol/grpc/client.go
index 24ab125..567996b 100644
--- a/protocol/grpc/client.go
+++ b/protocol/grpc/client.go
@@ -36,9 +36,7 @@
"github.com/apache/dubbo-go/config"
)
-var (
- clientConf *ClientConfig
-)
+var clientConf *ClientConfig
func init() {
// load clientconfig from consumer_config
@@ -80,7 +78,6 @@
panic(err)
}
}
-
}
// Client is gRPC client include client connection and invoker
@@ -90,20 +87,26 @@
}
// NewClient creates a new gRPC client.
-func NewClient(url *common.URL) *Client {
+func NewClient(url *common.URL) (*Client, error) {
// if global trace instance was set , it means trace function enabled. If not , will return Nooptracer
tracer := opentracing.GlobalTracer()
dialOpts := make([]grpc.DialOption, 0, 4)
maxMessageSize, _ := strconv.Atoi(url.GetParam(constant.MESSAGE_SIZE_KEY, "4"))
- dialOpts = append(dialOpts, grpc.WithInsecure(), grpc.WithBlock(), grpc.WithUnaryInterceptor(
+
+ // consumer config client connectTimeout
+ connectTimeout := config.GetConsumerConfig().ConnectTimeout
+
+ dialOpts = append(dialOpts, grpc.WithInsecure(), grpc.WithBlock(), grpc.WithTimeout(connectTimeout), grpc.WithUnaryInterceptor(
otgrpc.OpenTracingClientInterceptor(tracer, otgrpc.LogPayloads())),
grpc.WithDefaultCallOptions(
grpc.CallContentSubtype(clientConf.ContentSubType),
grpc.MaxCallRecvMsgSize(1024*1024*maxMessageSize),
grpc.MaxCallSendMsgSize(1024*1024*maxMessageSize)))
+
conn, err := grpc.Dial(url.Location, dialOpts...)
if err != nil {
- panic(err)
+ logger.Errorf("grpc dail error: %v", err)
+ return nil, err
}
key := url.GetParam(constant.BEAN_NAME_KEY, "")
@@ -113,7 +116,7 @@
return &Client{
ClientConn: conn,
invoker: reflect.ValueOf(invoker),
- }
+ }, nil
}
func getInvoker(impl interface{}, conn *grpc.ClientConn) interface{} {
diff --git a/protocol/grpc/client_test.go b/protocol/grpc/client_test.go
index 099f03e..a4630c8 100644
--- a/protocol/grpc/client_test.go
+++ b/protocol/grpc/client_test.go
@@ -29,6 +29,7 @@
import (
"github.com/apache/dubbo-go/common"
+ "github.com/apache/dubbo-go/common/logger"
"github.com/apache/dubbo-go/protocol/grpc/internal"
)
@@ -48,6 +49,9 @@
url, err := common.NewURL("grpc://127.0.0.1:30000/GrpcGreeterImpl?accesslog=&anyhost=true&app.version=0.0.1&application=BDTService&async=false&bean.name=GrpcGreeterImpl&category=providers&cluster=failover&dubbo=dubbo-provider-golang-2.6.0&environment=dev&execute.limit=&execute.limit.rejected.handler=&generic=false&group=&interface=io.grpc.examples.helloworld.GreeterGrpc%24IGreeter&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=&service.filter=echo%2Ctoken%2Caccesslog%2Ctps%2Cexecute%2Cpshutdown&side=provider×tamp=1576923740&tps.limit.interval=&tps.limit.rate=&tps.limit.rejected.handler=&tps.limit.strategy=&tps.limiter=&version=&warmup=100!")
assert.Nil(t, err)
- cli := NewClient(url)
+ cli, err := NewClient(url)
+ if err != nil {
+ logger.Errorf("grpc new client error %v", err)
+ }
assert.NotNil(t, cli)
}
diff --git a/protocol/grpc/config.go b/protocol/grpc/config.go
index e8a9baa..d0a1920 100644
--- a/protocol/grpc/config.go
+++ b/protocol/grpc/config.go
@@ -23,8 +23,7 @@
type (
// ServerConfig currently is empty struct,for future expansion
- ServerConfig struct {
- }
+ ServerConfig struct{}
// ClientConfig wrap client call parameters
ClientConfig struct {
diff --git a/protocol/grpc/grpc_invoker.go b/protocol/grpc/grpc_invoker.go
index 7b33c67..79eb3ca 100644
--- a/protocol/grpc/grpc_invoker.go
+++ b/protocol/grpc/grpc_invoker.go
@@ -35,9 +35,7 @@
"github.com/apache/dubbo-go/protocol"
)
-var (
- errNoReply = errors.New("request need @response")
-)
+var errNoReply = errors.New("request need @response")
// nolint
type GrpcInvoker struct {
@@ -72,9 +70,7 @@
// Invoke is used to call service method by invocation
func (gi *GrpcInvoker) Invoke(ctx context.Context, invocation protocol.Invocation) protocol.Result {
- var (
- result protocol.RPCResult
- )
+ var result protocol.RPCResult
if !gi.BaseInvoker.IsAvailable() {
// Generally, the case will not happen, because the invoker has been removed
diff --git a/protocol/grpc/grpc_invoker_test.go b/protocol/grpc/grpc_invoker_test.go
index d5ebbb4..c8066c7 100644
--- a/protocol/grpc/grpc_invoker_test.go
+++ b/protocol/grpc/grpc_invoker_test.go
@@ -29,6 +29,7 @@
import (
"github.com/apache/dubbo-go/common"
+ "github.com/apache/dubbo-go/common/logger"
"github.com/apache/dubbo-go/protocol/grpc/internal"
"github.com/apache/dubbo-go/protocol/invocation"
)
@@ -48,8 +49,10 @@
url, err := common.NewURL(mockGrpcCommonUrl)
assert.Nil(t, err)
- cli := NewClient(url)
-
+ cli, err := NewClient(url)
+ if err != nil {
+ logger.Errorf("grpc new client error %v", err)
+ }
invoker := NewGrpcInvoker(url, cli)
args := []reflect.Value{}
diff --git a/protocol/grpc/grpc_protocol.go b/protocol/grpc/grpc_protocol.go
index 3ad1245..ec1f5aa 100644
--- a/protocol/grpc/grpc_protocol.go
+++ b/protocol/grpc/grpc_protocol.go
@@ -68,29 +68,32 @@
}
func (gp *GrpcProtocol) openServer(url *common.URL) {
- _, ok := gp.serverMap[url.Location]
- if !ok {
- _, ok := gp.ExporterMap().Load(url.ServiceKey())
- if !ok {
- panic("[GrpcProtocol]" + url.Key() + "is not existing")
- }
+ gp.serverLock.Lock()
+ defer gp.serverLock.Unlock()
- gp.serverLock.Lock()
- _, ok = gp.serverMap[url.Location]
- if !ok {
- grpcMessageSize, _ := strconv.Atoi(url.GetParam(constant.MESSAGE_SIZE_KEY, "4"))
- srv := NewServer()
- srv.SetBufferSize(grpcMessageSize)
- gp.serverMap[url.Location] = srv
- srv.Start(url)
- }
- gp.serverLock.Unlock()
+ if _, ok := gp.serverMap[url.Location]; ok {
+ return
}
+
+ if _, ok := gp.ExporterMap().Load(url.ServiceKey()); !ok {
+ panic("[GrpcProtocol]" + url.Key() + "is not existing")
+ }
+
+ grpcMessageSize, _ := strconv.Atoi(url.GetParam(constant.MESSAGE_SIZE_KEY, "4"))
+ srv := NewServer()
+ srv.SetBufferSize(grpcMessageSize)
+ gp.serverMap[url.Location] = srv
+ srv.Start(url)
}
// Refer a remote gRPC service
func (gp *GrpcProtocol) Refer(url *common.URL) protocol.Invoker {
- invoker := NewGrpcInvoker(url, NewClient(url))
+ client, err := NewClient(url)
+ if err != nil {
+ logger.Warnf("can't dial the server: %s", url.Key())
+ return nil
+ }
+ invoker := NewGrpcInvoker(url, client)
gp.SetInvokers(invoker)
logger.Infof("Refer service: %s", url.String())
return invoker
@@ -102,6 +105,8 @@
gp.BaseProtocol.Destroy()
+ gp.serverLock.Lock()
+ defer gp.serverLock.Unlock()
for key, server := range gp.serverMap {
delete(gp.serverMap, key)
server.Stop()
diff --git a/protocol/grpc/grpc_protocol_test.go b/protocol/grpc/grpc_protocol_test.go
index 87ce714..71f05d0 100644
--- a/protocol/grpc/grpc_protocol_test.go
+++ b/protocol/grpc/grpc_protocol_test.go
@@ -28,13 +28,49 @@
import (
"github.com/apache/dubbo-go/common"
+ "github.com/apache/dubbo-go/config"
"github.com/apache/dubbo-go/protocol"
"github.com/apache/dubbo-go/protocol/grpc/internal"
)
+func doInitProvider() {
+ providerConfig := config.ProviderConfig{
+ BaseConfig: config.BaseConfig{
+ ApplicationConfig: &config.ApplicationConfig{
+ Organization: "dubbo_org",
+ Name: "BDTService",
+ Module: "module",
+ Version: "0.0.1",
+ Owner: "dubbo",
+ Environment: "test",
+ },
+ },
+ Services: map[string]*config.ServiceConfig{
+ "GrpcGreeterImpl": {
+ InterfaceName: "io.grpc.examples.helloworld.GreeterGrpc$IGreeter",
+ Protocol: "grpc",
+ Registry: "shanghai_reg1,shanghai_reg2,hangzhou_reg1,hangzhou_reg2,hangzhou_service_discovery_reg",
+ Cluster: "failover",
+ Loadbalance: "random",
+ Retries: "3",
+ Methods: []*config.MethodConfig{
+ {
+ Name: "SayHello",
+ Retries: "2",
+ LoadBalance: "random",
+ Weight: 200,
+ },
+ },
+ },
+ },
+ }
+ config.SetProviderConfig(providerConfig)
+}
+
func TestGrpcProtocolExport(t *testing.T) {
// Export
addService()
+ doInitProvider()
proto := GetProtocol()
url, err := common.NewURL(mockGrpcCommonUrl)
diff --git a/protocol/grpc/internal/client.go b/protocol/grpc/internal/client.go
index 3ce0f57..83b4586 100644
--- a/protocol/grpc/internal/client.go
+++ b/protocol/grpc/internal/client.go
@@ -34,7 +34,7 @@
}
// GrpcGreeterImpl
-//used for dubbo-grpc biz client
+// used for dubbo-grpc biz client
type GrpcGreeterImpl struct {
SayHello func(ctx context.Context, in *HelloRequest, out *HelloReply) error
}
diff --git a/protocol/grpc/internal/helloworld.pb.go b/protocol/grpc/internal/helloworld.pb.go
index 82537f5..2ea04fd 100644
--- a/protocol/grpc/internal/helloworld.pb.go
+++ b/protocol/grpc/internal/helloworld.pb.go
@@ -32,9 +32,11 @@
)
// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
+var (
+ _ = proto.Marshal
+ _ = fmt.Errorf
+ _ = 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.
@@ -60,15 +62,19 @@
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)
}
@@ -100,15 +106,19 @@
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)
}
@@ -145,8 +155,10 @@
}
// Reference imports to suppress errors if they are not otherwise used.
-var _ context.Context
-var _ grpc.ClientConn
+var (
+ _ context.Context
+ _ grpc.ClientConn
+)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
@@ -184,8 +196,7 @@
}
// UnimplementedGreeterServer can be embedded to have forward compatible implementations.
-type UnimplementedGreeterServer struct {
-}
+type UnimplementedGreeterServer struct{}
func (*UnimplementedGreeterServer) SayHello(ctx context.Context, req *HelloRequest) (*HelloReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method SayHello not implemented")
diff --git a/protocol/grpc/internal/server.go b/protocol/grpc/internal/server.go
index f7b99fa..6e17a4f 100644
--- a/protocol/grpc/internal/server.go
+++ b/protocol/grpc/internal/server.go
@@ -27,9 +27,7 @@
"google.golang.org/grpc"
)
-var (
- s *grpc.Server
-)
+var s *grpc.Server
// server is used to implement helloworld.GreeterServer.
type server struct {
diff --git a/protocol/grpc/protoc-gen-dubbo/examples/helloworld.pb.go b/protocol/grpc/protoc-gen-dubbo/examples/helloworld.pb.go
index 702391b..fe86b2b 100644
--- a/protocol/grpc/protoc-gen-dubbo/examples/helloworld.pb.go
+++ b/protocol/grpc/protoc-gen-dubbo/examples/helloworld.pb.go
@@ -38,9 +38,11 @@
)
// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
+var (
+ _ = proto.Marshal
+ _ = fmt.Errorf
+ _ = 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.
@@ -66,15 +68,19 @@
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)
}
@@ -106,15 +112,19 @@
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)
}
@@ -152,8 +162,10 @@
}
// Reference imports to suppress errors if they are not otherwise used.
-var _ context.Context
-var _ grpc.ClientConn
+var (
+ _ context.Context
+ _ grpc.ClientConn
+)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
@@ -191,8 +203,7 @@
}
// UnimplementedGreeterServer can be embedded to have forward compatible implementations.
-type UnimplementedGreeterServer struct {
-}
+type UnimplementedGreeterServer struct{}
func (*UnimplementedGreeterServer) SayHello(ctx context.Context, req *HelloRequest) (*HelloReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method SayHello not implemented")
diff --git a/protocol/grpc/server.go b/protocol/grpc/server.go
index e77e2ba..23460a0 100644
--- a/protocol/grpc/server.go
+++ b/protocol/grpc/server.go
@@ -21,6 +21,8 @@
"fmt"
"net"
"reflect"
+ "sync"
+ "time"
)
import (
@@ -31,7 +33,6 @@
import (
"github.com/apache/dubbo-go/common"
- "github.com/apache/dubbo-go/common/constant"
"github.com/apache/dubbo-go/common/logger"
"github.com/apache/dubbo-go/config"
"github.com/apache/dubbo-go/protocol"
@@ -80,42 +81,88 @@
grpc.UnaryInterceptor(otgrpc.OpenTracingServerInterceptor(tracer)),
grpc.MaxRecvMsgSize(1024*1024*s.bufferSize),
grpc.MaxSendMsgSize(1024*1024*s.bufferSize))
-
- key := url.GetParam(constant.BEAN_NAME_KEY, "")
- service := config.GetProviderService(key)
-
- ds, ok := service.(DubboGrpcService)
- if !ok {
- panic("illegal service type registered")
- }
-
- m, ok := reflect.TypeOf(service).MethodByName("SetProxyImpl")
- if !ok {
- panic("method SetProxyImpl is necessary for grpc service")
- }
-
- exporter, _ := grpcProtocol.ExporterMap().Load(url.ServiceKey())
- if exporter == nil {
- panic(fmt.Sprintf("no exporter found for servicekey: %v", url.ServiceKey()))
- }
- invoker := exporter.(protocol.Exporter).GetInvoker()
- if invoker == nil {
- panic(fmt.Sprintf("no invoker found for servicekey: %v", url.ServiceKey()))
- }
- in := []reflect.Value{reflect.ValueOf(service)}
- in = append(in, reflect.ValueOf(invoker))
- m.Func.Call(in)
-
- server.RegisterService(ds.ServiceDesc(), service)
-
s.grpcServer = server
+
go func() {
+ providerServices := config.GetProviderConfig().Services
+
+ if len(providerServices) == 0 {
+ panic("provider service map is null")
+ }
+ // wait all exporter ready , then set proxy impl and grpc registerService
+ waitGrpcExporter(providerServices)
+ registerService(providerServices, server)
+
if err = server.Serve(lis); err != nil {
logger.Errorf("server serve failed with err: %v", err)
}
}()
}
+// getSyncMapLen get sync map len
+func getSyncMapLen(m *sync.Map) int {
+ length := 0
+
+ m.Range(func(_, _ interface{}) bool {
+ length++
+ return true
+ })
+ return length
+}
+
+// waitGrpcExporter wait until len(providerServices) = len(ExporterMap)
+func waitGrpcExporter(providerServices map[string]*config.ServiceConfig) {
+ t := time.NewTicker(50 * time.Millisecond)
+ defer t.Stop()
+ pLen := len(providerServices)
+ ta := time.After(10 * time.Second)
+
+ for {
+ select {
+ case <-t.C:
+ mLen := getSyncMapLen(grpcProtocol.ExporterMap())
+ if pLen == mLen {
+ return
+ }
+ case <-ta:
+ panic("wait grpc exporter timeout when start grpc server")
+ }
+ }
+}
+
+// registerService SetProxyImpl invoker and grpc service
+func registerService(providerServices map[string]*config.ServiceConfig, server *grpc.Server) {
+ for key, providerService := range providerServices {
+ service := config.GetProviderService(key)
+
+ ds, ok := service.(DubboGrpcService)
+ if !ok {
+ panic("illegal service type registered")
+ }
+
+ m, ok := reflect.TypeOf(service).MethodByName("SetProxyImpl")
+ if !ok {
+ panic("method SetProxyImpl is necessary for grpc service")
+ }
+ serviceKey := common.ServiceKey(providerService.InterfaceName, providerService.Group, providerService.Version)
+
+ exporter, _ := grpcProtocol.ExporterMap().Load(serviceKey)
+ if exporter == nil {
+ panic(fmt.Sprintf("no exporter found for servicekey: %v", serviceKey))
+ }
+ invoker := exporter.(protocol.Exporter).GetInvoker()
+ if invoker == nil {
+ panic(fmt.Sprintf("no invoker found for servicekey: %v", serviceKey))
+ }
+ in := []reflect.Value{reflect.ValueOf(service)}
+ in = append(in, reflect.ValueOf(invoker))
+ m.Func.Call(in)
+
+ server.RegisterService(ds.ServiceDesc(), service)
+
+ }
+}
+
// Stop gRPC server
func (s *Server) Stop() {
s.grpcServer.Stop()
diff --git a/protocol/invocation/rpcinvocation.go b/protocol/invocation/rpcinvocation.go
index ec68ca3..0f879c0 100644
--- a/protocol/invocation/rpcinvocation.go
+++ b/protocol/invocation/rpcinvocation.go
@@ -19,6 +19,7 @@
import (
"reflect"
+ "strings"
"sync"
)
@@ -197,7 +198,7 @@
}
func (r *RPCInvocation) ServiceKey() string {
- return common.ServiceKey(r.AttachmentsByKey(constant.INTERFACE_KEY, ""),
+ return common.ServiceKey(strings.TrimPrefix(r.AttachmentsByKey(constant.PATH_KEY, r.AttachmentsByKey(constant.INTERFACE_KEY, "")), "/"),
r.AttachmentsByKey(constant.GROUP_KEY, ""), r.AttachmentsByKey(constant.VERSION_KEY, ""))
}
diff --git a/protocol/invocation/rpcinvocation_test.go b/protocol/invocation/rpcinvocation_test.go
new file mode 100644
index 0000000..ef70e2c
--- /dev/null
+++ b/protocol/invocation/rpcinvocation_test.go
@@ -0,0 +1,74 @@
+/*
+ * 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 invocation
+
+import (
+ "testing"
+)
+
+import (
+ "github.com/stretchr/testify/assert"
+)
+
+import (
+ "github.com/apache/dubbo-go/common"
+ "github.com/apache/dubbo-go/common/constant"
+)
+
+func TestRPCInvocation_ServiceKey(t *testing.T) {
+ providerURL := "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&" +
+ "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=1556509797245"
+
+ sameInfPathConsumerURL := "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&" +
+ "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=1556509797245"
+ diffInfPathConsumerURL := "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&" +
+ "environment=dev&interface=com.ikurento.user.UserProviderFoo&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=1556509797245"
+
+ providerUrl, err := common.NewURL(providerURL)
+ assert.NoError(t, err)
+
+ // invocation with same interface and path value
+ sameInfPathConsumerUrl, err := common.NewURL(sameInfPathConsumerURL)
+ assert.NoError(t, err)
+ invocation := NewRPCInvocationWithOptions(WithAttachments(map[string]interface{}{
+ constant.INTERFACE_KEY: sameInfPathConsumerUrl.GetParam(constant.INTERFACE_KEY, ""),
+ constant.PATH_KEY: sameInfPathConsumerUrl.Path,
+ constant.GROUP_KEY: sameInfPathConsumerUrl.GetParam(constant.GROUP_KEY, ""),
+ constant.VERSION_KEY: sameInfPathConsumerUrl.GetParam(constant.VERSION_KEY, ""),
+ }))
+ assert.Equal(t, providerUrl.ServiceKey(), invocation.ServiceKey())
+
+ // invocation with different interface and path value
+ diffInfPathConsumerUrl, err := common.NewURL(diffInfPathConsumerURL)
+ assert.NoError(t, err)
+ invocation = NewRPCInvocationWithOptions(WithAttachments(map[string]interface{}{
+ constant.INTERFACE_KEY: diffInfPathConsumerUrl.GetParam(constant.INTERFACE_KEY, ""),
+ constant.PATH_KEY: diffInfPathConsumerUrl.Path,
+ constant.GROUP_KEY: diffInfPathConsumerUrl.GetParam(constant.GROUP_KEY, ""),
+ constant.VERSION_KEY: diffInfPathConsumerUrl.GetParam(constant.VERSION_KEY, ""),
+ }))
+ assert.Equal(t, providerUrl.ServiceKey(), invocation.ServiceKey())
+}
diff --git a/protocol/jsonrpc/http.go b/protocol/jsonrpc/http.go
index 11051df..0ad76e0 100644
--- a/protocol/jsonrpc/http.go
+++ b/protocol/jsonrpc/http.go
@@ -56,7 +56,7 @@
service string
method string
args interface{}
- //contentType string
+ // contentType string
}
// ////////////////////////////////////////////
@@ -102,7 +102,6 @@
// NewRequest creates a new HTTP request with @service ,@method and @arguments.
func (c *HTTPClient) NewRequest(service *common.URL, method string, args interface{}) *Request {
-
return &Request{
ID: atomic.AddInt64(&c.ID, 1),
group: service.GetParam(constant.GROUP_KEY, ""),
diff --git a/protocol/jsonrpc/http_test.go b/protocol/jsonrpc/http_test.go
index 5ef4064..caf0d22 100644
--- a/protocol/jsonrpc/http_test.go
+++ b/protocol/jsonrpc/http_test.go
@@ -43,8 +43,7 @@
Name string `json:"name"`
}
- UserProvider struct {
- //user map[string]User
+ UserProvider struct { // user map[string]User
}
)
@@ -57,7 +56,6 @@
)
func TestHTTPClientCall(t *testing.T) {
-
methods, err := common.ServiceMap.Register("com.ikurento.user.UserProvider", "jsonrpc", "", "", &UserProvider{})
assert.NoError(t, err)
assert.Equal(t, "GetUser,GetUser0,GetUser1,GetUser2,GetUser3,GetUser4", methods)
@@ -165,7 +163,6 @@
// destroy
proto.Destroy()
-
}
func (u *UserProvider) GetUser(ctx context.Context, req []interface{}, rsp *User) error {
diff --git a/protocol/jsonrpc/json.go b/protocol/jsonrpc/json.go
index 81ca512..2383bf5 100644
--- a/protocol/jsonrpc/json.go
+++ b/protocol/jsonrpc/json.go
@@ -231,7 +231,7 @@
return perrors.New("bad request")
}
- var o = make(map[string]*json.RawMessage)
+ o := make(map[string]*json.RawMessage)
if err := json.Unmarshal(raw, &o); err != nil {
return perrors.New("bad request")
}
diff --git a/protocol/jsonrpc/json_test.go b/protocol/jsonrpc/json_test.go
index a3814e9..6d3e11b 100644
--- a/protocol/jsonrpc/json_test.go
+++ b/protocol/jsonrpc/json_test.go
@@ -54,7 +54,7 @@
assert.NoError(t, err)
assert.Equal(t, "test", rsp.Test)
- //error
+ // error
codec.pending[1] = "GetUser"
err = codec.Read([]byte("{\"jsonrpc\":\"2.0\",\"id\":1,\"error\":{\"code\":-32000,\"message\":\"error\"}}\n"), rsp)
assert.EqualError(t, err, "{\"code\":-32000,\"message\":\"error\"}")
diff --git a/protocol/jsonrpc/jsonrpc_invoker_test.go b/protocol/jsonrpc/jsonrpc_invoker_test.go
index 12a5705..c604929 100644
--- a/protocol/jsonrpc/jsonrpc_invoker_test.go
+++ b/protocol/jsonrpc/jsonrpc_invoker_test.go
@@ -35,7 +35,6 @@
)
func TestJsonrpcInvokerInvoke(t *testing.T) {
-
methods, err := common.ServiceMap.Register("com.ikurento.user.UserProvider", "jsonrpc", "", "", &UserProvider{})
assert.NoError(t, err)
assert.Equal(t, "GetUser,GetUser0,GetUser1,GetUser2,GetUser3,GetUser4", methods)
diff --git a/protocol/jsonrpc/jsonrpc_protocol.go b/protocol/jsonrpc/jsonrpc_protocol.go
index 643bcde..313d32f 100644
--- a/protocol/jsonrpc/jsonrpc_protocol.go
+++ b/protocol/jsonrpc/jsonrpc_protocol.go
@@ -34,7 +34,7 @@
const (
// JSONRPC
- //module name
+ // module name
JSONRPC = "jsonrpc"
)
@@ -76,8 +76,8 @@
// Refer a remote JSON PRC service from registry
func (jp *JsonrpcProtocol) Refer(url *common.URL) protocol.Invoker {
- //default requestTimeout
- var requestTimeout = config.GetConsumerConfig().RequestTimeout
+ // default requestTimeout
+ requestTimeout := config.GetConsumerConfig().RequestTimeout
requestTimeoutStr := url.GetParam(constant.TIMEOUT_KEY, config.GetConsumerConfig().Request_Timeout)
if t, err := time.ParseDuration(requestTimeoutStr); err == nil {
diff --git a/protocol/jsonrpc/server.go b/protocol/jsonrpc/server.go
index 76901bf..c16f656 100644
--- a/protocol/jsonrpc/server.go
+++ b/protocol/jsonrpc/server.go
@@ -43,12 +43,10 @@
"github.com/apache/dubbo-go/protocol/invocation"
)
-var (
- // A value sent as a placeholder for the server's response value when the server
- // receives an invalid request. It is never decoded by the client since the Response
- // contains an error when it is used.
- invalidRequest = struct{}{}
-)
+// A value sent as a placeholder for the server's response value when the server
+// receives an invalid request. It is never decoded by the client since the Response
+// contains an error when it is used.
+var invalidRequest = struct{}{}
const (
// DefaultMaxSleepTime max sleep interval in accept
@@ -349,7 +347,8 @@
if invoker != nil {
result := invoker.Invoke(ctx, invocation.NewRPCInvocation(methodName, args, map[string]interface{}{
constant.PATH_KEY: path,
- constant.VERSION_KEY: codec.req.Version}))
+ constant.VERSION_KEY: codec.req.Version,
+ }))
if err := result.Error(); err != nil {
rspStream, codecErr := codec.Write(err.Error(), invalidRequest)
if codecErr != nil {
diff --git a/protocol/protocol.go b/protocol/protocol.go
index d03e70f..19ec8ed 100644
--- a/protocol/protocol.go
+++ b/protocol/protocol.go
@@ -137,7 +137,6 @@
// GetInvoker gets invoker
func (de *BaseExporter) GetInvoker() Invoker {
return de.invoker
-
}
// Unexport exported service.
diff --git a/protocol/protocolwrapper/protocol_filter_wrapper_test.go b/protocol/protocolwrapper/protocol_filter_wrapper_test.go
index b37d066..d096784 100644
--- a/protocol/protocolwrapper/protocol_filter_wrapper_test.go
+++ b/protocol/protocolwrapper/protocol_filter_wrapper_test.go
@@ -60,7 +60,7 @@
assert.True(t, ok)
}
-//the same as echo filter, for test
+// the same as echo filter, for test
func init() {
extension.SetFilter("echo", GetFilter)
}
diff --git a/protocol/rest/config/reader/rest_config_reader.go b/protocol/rest/config/reader/rest_config_reader.go
index 2338790..e545d85 100644
--- a/protocol/rest/config/reader/rest_config_reader.go
+++ b/protocol/rest/config/reader/rest_config_reader.go
@@ -43,8 +43,7 @@
extension.SetDefaultConfigReader(REST, REST)
}
-type RestConfigReader struct {
-}
+type RestConfigReader struct{}
func NewRestConfigReader() interfaces.ConfigReader {
return &RestConfigReader{}
diff --git a/protocol/rest/rest_invoker_test.go b/protocol/rest/rest_invoker_test.go
index b6bc980..5a5bd2c 100644
--- a/protocol/rest/rest_invoker_test.go
+++ b/protocol/rest/rest_invoker_test.go
@@ -199,7 +199,7 @@
assert.Equal(t, "username", res.Result().(*User).Name)
// test 3
inv = invocation.NewRPCInvocationWithOptions(invocation.WithMethodName("GetUserFour"),
- invocation.WithArguments([]interface{}{[]User{User{1, nil, int32(23), "username"}}}), invocation.WithReply(user))
+ invocation.WithArguments([]interface{}{[]User{{1, nil, int32(23), "username"}}}), invocation.WithReply(user))
res = invoker.Invoke(context.Background(), inv)
assert.NoError(t, res.Error())
assert.NotNil(t, res.Result())
diff --git a/protocol/rest/rest_protocol.go b/protocol/rest/rest_protocol.go
index d19bd00..a87eb09 100644
--- a/protocol/rest/rest_protocol.go
+++ b/protocol/rest/rest_protocol.go
@@ -37,9 +37,7 @@
_ "github.com/apache/dubbo-go/protocol/rest/server/server_impl"
)
-var (
- restProtocol *RestProtocol
-)
+var restProtocol *RestProtocol
const REST = "rest"
@@ -88,7 +86,7 @@
// Refer create rest service reference
func (rp *RestProtocol) Refer(url *common.URL) protocol.Invoker {
// create rest_invoker
- var requestTimeout = config.GetConsumerConfig().RequestTimeout
+ requestTimeout := config.GetConsumerConfig().RequestTimeout
requestTimeoutStr := url.GetParam(constant.TIMEOUT_KEY, config.GetConsumerConfig().Request_Timeout)
connectTimeout := config.GetConsumerConfig().ConnectTimeout
if t, err := time.ParseDuration(requestTimeoutStr); err == nil {
diff --git a/protocol/rest/rest_protocol_test.go b/protocol/rest/rest_protocol_test.go
index 580fc61..4809564 100644
--- a/protocol/rest/rest_protocol_test.go
+++ b/protocol/rest/rest_protocol_test.go
@@ -122,8 +122,7 @@
assert.False(t, ok)
}
-type UserProvider struct {
-}
+type UserProvider struct{}
func (p *UserProvider) Reference() string {
return "com.ikurento.user.UserProvider"
diff --git a/protocol/rest/server/server_impl/go_restful_server.go b/protocol/rest/server/server_impl/go_restful_server.go
index 4481f44..b42bb6e 100644
--- a/protocol/rest/server/server_impl/go_restful_server.go
+++ b/protocol/rest/server/server_impl/go_restful_server.go
@@ -87,7 +87,6 @@
// Publish a http api in go-restful server
// The routeFunc should be invoked when the server receive a request
func (grs *GoRestfulServer) Deploy(restMethodConfig *config.RestMethodConfig, routeFunc func(request server.RestServerRequest, response server.RestServerResponse)) {
-
rf := func(req *restful.Request, resp *restful.Response) {
routeFunc(NewGoRestfulRequestAdapter(req), resp)
}
diff --git a/protocol/rpc_status.go b/protocol/rpc_status.go
index 8fc5ddd..3994f8d 100644
--- a/protocol/rpc_status.go
+++ b/protocol/rpc_status.go
@@ -263,7 +263,7 @@
wg.Add(1)
go func(ivks []Invoker, i int) {
defer wg.Done()
- for j, _ := range ivks {
+ for j := range ivks {
if j%3-i == 0 && ivks[j].(Invoker).IsAvailable() {
RemoveInvokerUnhealthyStatus(ivks[i])
}
diff --git a/protocol/rpc_status_test.go b/protocol/rpc_status_test.go
index 6fd449c..568d5c5 100644
--- a/protocol/rpc_status_test.go
+++ b/protocol/rpc_status_test.go
@@ -45,7 +45,6 @@
assert.Equal(t, int32(1), methodStatus.active)
assert.Equal(t, int32(1), urlStatus.active)
assert.Equal(t, int32(0), methodStatus1.active)
-
}
func TestEndCount(t *testing.T) {
@@ -139,7 +138,6 @@
methodStatus1 := GetMethodStatus(url, "test1")
assert.Equal(t, int32(2), methodStatus.successiveRequestFailureCount)
assert.Equal(t, int32(3), methodStatus1.successiveRequestFailureCount)
-
}
func request(url *common.URL, method string, elapsed int64, active, succeeded bool) {
diff --git a/registry/base_configuration_listener.go b/registry/base_configuration_listener.go
index 31e859e..67dee9d 100644
--- a/registry/base_configuration_listener.go
+++ b/registry/base_configuration_listener.go
@@ -48,7 +48,7 @@
bcl.dynamicConfiguration = config.GetEnvInstance().GetDynamicConfiguration()
if bcl.dynamicConfiguration == nil {
- //set configurators to empty
+ // set configurators to empty
bcl.configurators = []config_center.Configurator{}
return
}
@@ -56,7 +56,7 @@
bcl.dynamicConfiguration.AddListener(key, listener)
if rawConfig, err := bcl.dynamicConfiguration.GetInternalProperty(key,
config_center.WithGroup(constant.DUBBO)); err != nil {
- //set configurators to empty
+ // set configurators to empty
bcl.configurators = []config_center.Configurator{}
return
} else if len(rawConfig) > 0 {
diff --git a/registry/base_registry.go b/registry/base_registry.go
index df8c8a3..a16a998 100644
--- a/registry/base_registry.go
+++ b/registry/base_registry.go
@@ -92,13 +92,13 @@
// BaseRegistry is a common logic abstract for registry. It implement Registry interface.
type BaseRegistry struct {
- //context context.Context
+ // context context.Context
facadeBasedRegistry FacadeBasedRegistry
*common.URL
birth int64 // time of file birth, seconds since Epoch; 0 if unknown
wg sync.WaitGroup // wg+done for zk restart
done chan struct{}
- cltLock sync.RWMutex //ctl lock is a lock for services map
+ cltLock sync.RWMutex // ctl lock is a lock for services map
services map[string]*common.URL // service name + protocol -> service config, for store the service registered
}
@@ -119,14 +119,14 @@
// Destroy for graceful down
func (r *BaseRegistry) Destroy() {
- //first step close registry's all listeners
+ // first step close registry's all listeners
r.facadeBasedRegistry.CloseListener()
// then close r.done to notify other program who listen to it
close(r.done)
// wait waitgroup done (wait listeners outside close over)
r.wg.Wait()
- //close registry client
+ // close registry client
r.closeRegisters()
}
@@ -209,7 +209,6 @@
// RestartCallBack for reregister when reconnect
func (r *BaseRegistry) RestartCallBack() bool {
-
// copy r.services
services := make([]*common.URL, 0, len(r.services))
for _, confIf := range r.services {
@@ -251,12 +250,12 @@
}
var (
err error
- //revision string
+ // revision string
params url.Values
rawURL string
encodedURL string
dubboPath string
- //conf config.URL
+ // conf config.URL
)
params = url.Values{}
@@ -267,7 +266,7 @@
params.Add("pid", processID)
params.Add("ip", localIP)
- //params.Add("timeout", fmt.Sprintf("%d", int64(r.Timeout)/1e6))
+ // params.Add("timeout", fmt.Sprintf("%d", int64(r.Timeout)/1e6))
role, _ := strconv.Atoi(r.URL.GetParam(constant.ROLE_KEY, ""))
switch role {
@@ -335,7 +334,7 @@
}
host += ":" + c.Port
- //delete empty param key
+ // delete empty param key
for key, val := range params {
if len(val) > 0 && val[0] == "" {
params.Del(key)
@@ -426,7 +425,6 @@
logger.Infof("update begin, service event: %v", serviceEvent.String())
notifyListener.Notify(serviceEvent)
}
-
}
sleepWait(n)
}
@@ -458,7 +456,6 @@
logger.Infof("update begin, service event: %v", serviceEvent.String())
notifyListener.Notify(serviceEvent)
}
-
}
return nil
}
diff --git a/registry/consul/service_discovery.go b/registry/consul/service_discovery.go
index fba142e..da5d8d0 100644
--- a/registry/consul/service_discovery.go
+++ b/registry/consul/service_discovery.go
@@ -50,9 +50,7 @@
watch_passingonly_true = true
)
-var (
- errConsulClientClosed = perrors.New("consul client is closed")
-)
+var errConsulClientClosed = perrors.New("consul client is closed")
// init will put the service discovery into extension
func init() {
@@ -241,7 +239,7 @@
consulClient *consul.Client
services map[string][]string
)
- var res = gxset.NewSet()
+ res := gxset.NewSet()
if consulClient = csd.getConsulClient(); consulClient == nil {
logger.Warnf("consul client is closed!")
return res
@@ -256,7 +254,6 @@
res.Add(service)
}
return res
-
}
// encodeConsulMetadata because consul validate key strictly.
@@ -370,7 +367,6 @@
}
func (csd *consulServiceDiscovery) AddListener(listener *registry.ServiceInstancesChangedListener) error {
-
params := make(map[string]interface{}, 8)
params[watch_type] = watch_type_service
params[watch_service] = listener.ServiceName
diff --git a/registry/consul/service_discovery_test.go b/registry/consul/service_discovery_test.go
index 3f97d84..68e8042 100644
--- a/registry/consul/service_discovery_test.go
+++ b/registry/consul/service_discovery_test.go
@@ -90,7 +90,7 @@
}()
prepareData()
- var eventDispatcher = MockEventDispatcher{Notify: make(chan struct{}, 1)}
+ eventDispatcher := MockEventDispatcher{Notify: make(chan struct{}, 1)}
extension.SetEventDispatcher("mock", func() observer.EventDispatcher {
return &eventDispatcher
})
@@ -110,8 +110,8 @@
err = serviceDiscovery.Register(instance)
assert.Nil(t, err)
- //sometimes nacos may be failed to push update of instance,
- //so it need 10s to pull, we sleep 10 second to make sure instance has been update
+ // sometimes nacos may be failed to push update of instance,
+ // so it need 10s to pull, we sleep 10 second to make sure instance has been update
time.Sleep(3 * time.Second)
page := serviceDiscovery.GetHealthyInstancesByPage(instance.GetServiceName(), 0, 10, true)
assert.NotNil(t, page)
@@ -146,8 +146,8 @@
assert.Equal(t, "bbb", v)
// test dispatcher event
- //err = serviceDiscovery.DispatchEventByServiceName(instanceResult.GetServiceName())
- //assert.Nil(t, err)
+ // err = serviceDiscovery.DispatchEventByServiceName(instanceResult.GetServiceName())
+ // assert.Nil(t, err)
// test AddListener
err = serviceDiscovery.AddListener(®istry.ServiceInstancesChangedListener{ServiceName: instance.GetServiceName()})
diff --git a/registry/consul/utils_test.go b/registry/consul/utils_test.go
index b7e2929..3319beb 100644
--- a/registry/consul/utils_test.go
+++ b/registry/consul/utils_test.go
@@ -19,13 +19,14 @@
import (
"fmt"
- "github.com/apache/dubbo-go/common/logger"
- "github.com/stretchr/testify/assert"
"net"
"net/url"
"strconv"
"sync"
"testing"
+
+ "github.com/apache/dubbo-go/common/logger"
+ "github.com/stretchr/testify/assert"
)
import (
diff --git a/registry/directory/directory.go b/registry/directory/directory.go
index 139721e..f10f8d8 100644
--- a/registry/directory/directory.go
+++ b/registry/directory/directory.go
@@ -63,8 +63,8 @@
configurators []config_center.Configurator
consumerConfigurationListener *consumerConfigurationListener
referenceConfigurationListener *referenceConfigurationListener
- //serviceKey string
- //forbidden atomic.Bool
+ // serviceKey string
+ // forbidden atomic.Bool
registerLock sync.Mutex // this lock if for register
}
@@ -111,7 +111,7 @@
if event == nil {
return
}
- go dir.refreshInvokers(event)
+ dir.refreshInvokers(event)
}
// NotifyAll notify the events that are complete Service Event List.
@@ -370,6 +370,8 @@
newInvoker := extension.GetProtocol(protocolwrapper.FILTER).Refer(newUrl)
if newInvoker != nil {
dir.cacheInvokersMap.Store(key, newInvoker)
+ } else {
+ logger.Warnf("service will be added in cache invokers fail, result is null, invokers url is %+v", newUrl.String())
}
} else {
// if cached invoker has the same URL with the new URL, then no need to re-refer, and no need to destroy
@@ -383,6 +385,8 @@
if newInvoker != nil {
dir.cacheInvokersMap.Store(key, newInvoker)
return cacheInvoker.(protocol.Invoker), true
+ } else {
+ logger.Warnf("service will be updated in cache invokers fail, result is null, invokers url is %+v", newUrl.String())
}
}
return nil, false
diff --git a/registry/directory/directory_test.go b/registry/directory/directory_test.go
index b5d81eb..b6ee10d 100644
--- a/registry/directory/directory_test.go
+++ b/registry/directory/directory_test.go
@@ -88,18 +88,18 @@
dir, _ := NewRegistryDirectory(regurl, mockRegistry)
go dir.(*RegistryDirectory).subscribe(common.NewURLWithOptions(common.WithPath("testservice")))
- //for group1
+ // for group1
urlmap := url.Values{}
urlmap.Set(constant.GROUP_KEY, "group1")
- urlmap.Set(constant.CLUSTER_KEY, "failover") //to test merge url
+ urlmap.Set(constant.CLUSTER_KEY, "failover") // to test merge url
for i := 0; i < 3; i++ {
mockRegistry.(*registry.MockRegistry).MockEvent(®istry.ServiceEvent{Action: remoting.EventTypeAdd, Service: common.NewURLWithOptions(common.WithPath("TEST"+strconv.FormatInt(int64(i), 10)), common.WithProtocol("dubbo"),
common.WithParams(urlmap))})
}
- //for group2
+ // for group2
urlmap2 := url.Values{}
urlmap2.Set(constant.GROUP_KEY, "group2")
- urlmap2.Set(constant.CLUSTER_KEY, "failover") //to test merge url
+ urlmap2.Set(constant.CLUSTER_KEY, "failover") // to test merge url
for i := 0; i < 3; i++ {
mockRegistry.(*registry.MockRegistry).MockEvent(®istry.ServiceEvent{Action: remoting.EventTypeAdd, Service: common.NewURLWithOptions(common.WithPath("TEST"+strconv.FormatInt(int64(i), 10)), common.WithProtocol("dubbo"),
common.WithParams(urlmap2))})
@@ -127,7 +127,6 @@
time.Sleep(6e9)
assert.Len(t, registryDirectory.List(&invocation.RPCInvocation{}), 3)
assert.Equal(t, true, registryDirectory.IsAvailable())
-
}
func Test_MergeProviderUrl(t *testing.T) {
@@ -142,7 +141,6 @@
if len(registryDirectory.cacheInvokers) > 0 {
assert.Equal(t, "mock", registryDirectory.cacheInvokers[0].GetUrl().GetParam(constant.CLUSTER_KEY, ""))
}
-
}
func Test_MergeOverrideUrl(t *testing.T) {
@@ -207,11 +205,13 @@
mockRegistry.MockEvent(®istry.ServiceEvent{Action: remoting.EventTypeAdd, Service: providerUrl})
time.Sleep(1e9)
assert.Len(t, registryDirectory.cacheInvokers, 4)
- mockRegistry.MockEvents([]*registry.ServiceEvent{®istry.ServiceEvent{Action: remoting.EventTypeUpdate, Service: providerUrl}})
+ mockRegistry.MockEvents([]*registry.ServiceEvent{{Action: remoting.EventTypeUpdate, Service: providerUrl}})
time.Sleep(1e9)
assert.Len(t, registryDirectory.cacheInvokers, 1)
- mockRegistry.MockEvents([]*registry.ServiceEvent{®istry.ServiceEvent{Action: remoting.EventTypeUpdate, Service: providerUrl},
- ®istry.ServiceEvent{Action: remoting.EventTypeUpdate, Service: providerUrl2}})
+ mockRegistry.MockEvents([]*registry.ServiceEvent{
+ {Action: remoting.EventTypeUpdate, Service: providerUrl},
+ {Action: remoting.EventTypeUpdate, Service: providerUrl2},
+ })
time.Sleep(1e9)
assert.Len(t, registryDirectory.cacheInvokers, 2)
// clear all address
diff --git a/registry/etcdv3/listener.go b/registry/etcdv3/listener.go
index f900495..6d72899 100644
--- a/registry/etcdv3/listener.go
+++ b/registry/etcdv3/listener.go
@@ -51,7 +51,6 @@
// DataChange processes the data change event from registry center of etcd
func (l *dataListener) DataChange(eventType remoting.Event) bool {
-
index := strings.Index(eventType.Path, "/providers/")
if index == -1 {
logger.Warnf("Listen with no url, event.path={%v}", eventType.Path)
diff --git a/registry/etcdv3/listener_test.go b/registry/etcdv3/listener_test.go
index ff7f63f..0028938 100644
--- a/registry/etcdv3/listener_test.go
+++ b/registry/etcdv3/listener_test.go
@@ -44,7 +44,6 @@
// start etcd server
func (suite *RegistryTestSuite) SetupSuite() {
-
t := suite.T()
cfg := embed.NewConfig()
@@ -75,7 +74,6 @@
}
func (suite *RegistryTestSuite) TestDataChange() {
-
t := suite.T()
listener := NewRegistryDataListener(&MockDataListener{})
diff --git a/registry/etcdv3/registry.go b/registry/etcdv3/registry.go
index 7ccf326..c51d1fc 100644
--- a/registry/etcdv3/registry.go
+++ b/registry/etcdv3/registry.go
@@ -26,6 +26,7 @@
)
import (
+ gxetcd "github.com/dubbogo/gost/database/kv/etcd/v3"
perrors "github.com/pkg/errors"
)
@@ -50,7 +51,7 @@
type etcdV3Registry struct {
registry.BaseRegistry
cltLock sync.Mutex
- client *etcdv3.Client
+ client *gxetcd.Client
listenerLock sync.RWMutex
listener *etcdv3.EventListener
dataListener *dataListener
@@ -58,12 +59,12 @@
}
// Client gets the etcdv3 client
-func (r *etcdV3Registry) Client() *etcdv3.Client {
+func (r *etcdV3Registry) Client() *gxetcd.Client {
return r.client
}
// SetClient sets the etcdv3 client
-func (r *etcdV3Registry) SetClient(client *etcdv3.Client) {
+func (r *etcdV3Registry) SetClient(client *gxetcd.Client) {
r.client = client
}
@@ -73,7 +74,6 @@
}
func newETCDV3Registry(url *common.URL) (registry.Registry, error) {
-
timeout, err := time.ParseDuration(url.GetParam(constant.REGISTRY_TIMEOUT_KEY, constant.DEFAULT_REG_TIMEOUT))
if err != nil {
logger.Errorf("timeout config %v is invalid ,err is %v",
@@ -89,13 +89,13 @@
if err := etcdv3.ValidateClient(
r,
- etcdv3.WithName(etcdv3.RegistryETCDV3Client),
- etcdv3.WithTimeout(timeout),
- etcdv3.WithEndpoints(strings.Split(url.Location, ",")...),
+ gxetcd.WithName(gxetcd.RegistryETCDV3Client),
+ gxetcd.WithTimeout(timeout),
+ gxetcd.WithEndpoints(strings.Split(url.Location, ",")...),
); err != nil {
return nil, err
}
- r.WaitGroup().Add(1) //etcdv3 client start successful, then wg +1
+ r.WaitGroup().Add(1) // etcdv3 client start successful, then wg +1
go etcdv3.HandleClientRestart(r)
@@ -165,7 +165,7 @@
r.listenerLock.Unlock()
}
- //register the svc to dataListener
+ // register the svc to dataListener
r.dataListener.AddInterestedURL(svc)
go r.listener.ListenServiceEvent(fmt.Sprintf("/dubbo/%s/"+constant.DEFAULT_CATEGORY, svc.Service()), r.dataListener)
diff --git a/registry/etcdv3/registry_test.go b/registry/etcdv3/registry_test.go
index d94eff6..dbbb7af 100644
--- a/registry/etcdv3/registry_test.go
+++ b/registry/etcdv3/registry_test.go
@@ -33,7 +33,6 @@
)
func initRegistry(t *testing.T) *etcdV3Registry {
-
regurl, err := common.NewURL("registry://127.0.0.1:2379", common.WithParamsValue(constant.ROLE_KEY, strconv.Itoa(common.PROVIDER)))
if err != nil {
t.Fatal(err)
@@ -51,7 +50,6 @@
}
func (suite *RegistryTestSuite) TestRegister() {
-
t := suite.T()
url, _ := common.NewURL("dubbo://127.0.0.1:20000/com.ikurento.user.UserProvider", common.WithParamsValue(constant.CLUSTER_KEY, "mock"), common.WithMethods([]string{"GetUser", "AddUser"}))
@@ -68,19 +66,18 @@
}
func (suite *RegistryTestSuite) TestSubscribe() {
-
t := suite.T()
regurl, _ := common.NewURL("registry://127.0.0.1:1111", common.WithParamsValue(constant.ROLE_KEY, strconv.Itoa(common.PROVIDER)))
url, _ := common.NewURL("dubbo://127.0.0.1:20000/com.ikurento.user.UserProvider", common.WithParamsValue(constant.CLUSTER_KEY, "mock"), common.WithMethods([]string{"GetUser", "AddUser"}))
reg := initRegistry(t)
- //provider register
+ // provider register
err := reg.Register(url)
if err != nil {
t.Fatal(err)
}
- //consumer register
+ // consumer register
regurl.SetParam(constant.ROLE_KEY, strconv.Itoa(common.CONSUMER))
reg2 := initRegistry(t)
@@ -99,7 +96,6 @@
}
func (suite *RegistryTestSuite) TestConsumerDestroy() {
-
t := suite.T()
url, _ := common.NewURL("dubbo://127.0.0.1:20000/com.ikurento.user.UserProvider", common.WithParamsValue(constant.CLUSTER_KEY, "mock"), common.WithMethods([]string{"GetUser", "AddUser"}))
@@ -109,23 +105,21 @@
t.Fatal(err)
}
- //listener.Close()
+ // listener.Close()
time.Sleep(1e9)
reg.Destroy()
assert.Equal(t, false, reg.IsAvailable())
-
}
func (suite *RegistryTestSuite) TestProviderDestroy() {
-
t := suite.T()
reg := initRegistry(t)
url, _ := common.NewURL("dubbo://127.0.0.1:20000/com.ikurento.user.UserProvider", common.WithParamsValue(constant.CLUSTER_KEY, "mock"), common.WithMethods([]string{"GetUser", "AddUser"}))
err := reg.Register(url)
assert.NoError(t, err)
- //listener.Close()
+ // listener.Close()
time.Sleep(1e9)
reg.Destroy()
assert.Equal(t, false, reg.IsAvailable())
diff --git a/registry/etcdv3/service_discovery.go b/registry/etcdv3/service_discovery.go
index ca6016e..5e3e98f 100644
--- a/registry/etcdv3/service_discovery.go
+++ b/registry/etcdv3/service_discovery.go
@@ -26,6 +26,7 @@
import (
gxset "github.com/dubbogo/gost/container/set"
+ gxetcd "github.com/dubbogo/gost/database/kv/etcd/v3"
gxpage "github.com/dubbogo/gost/hash/page"
"github.com/hashicorp/vault/sdk/helper/jsonutil"
perrors "github.com/pkg/errors"
@@ -45,9 +46,7 @@
ROOT = "/services"
)
-var (
- initLock sync.Mutex
-)
+var initLock sync.Mutex
func init() {
extension.SetServiceDiscovery(constant.ETCDV3_KEY, newEtcdV3ServiceDiscovery)
@@ -58,7 +57,7 @@
// descriptor is a short string about the basic information of this instance
descriptor string
// client is current Etcdv3 client
- client *etcdv3.Client
+ client *gxetcd.Client
// serviceInstance is current serviceInstance
serviceInstance *registry.ServiceInstance
// services is when register or update will add service name
@@ -82,7 +81,6 @@
// Register will register an instance of ServiceInstance to registry
func (e *etcdV3ServiceDiscovery) Register(instance registry.ServiceInstance) error {
-
e.serviceInstance = &instance
path := toPath(instance)
@@ -147,7 +145,6 @@
// GetInstances will return all service instances with serviceName
func (e *etcdV3ServiceDiscovery) GetInstances(serviceName string) []registry.ServiceInstance {
-
if nil != e.client {
// get keys and values
_, vList, err := e.client.GetChildrenKVList(toParentPath(serviceName))
@@ -171,7 +168,6 @@
// GetInstancesByPage will return a page containing instances of ServiceInstance with the serviceName
// the page will start at offset
func (e *etcdV3ServiceDiscovery) GetInstancesByPage(serviceName string, offset int, pageSize int) gxpage.Pager {
-
all := e.GetInstances(serviceName)
res := make([]interface{}, 0, pageSize)
@@ -253,7 +249,6 @@
// register service watcher
func (e *etcdV3ServiceDiscovery) registerSreviceWatcher(serviceName string) error {
-
initLock.Lock()
defer initLock.Unlock()
@@ -273,7 +268,6 @@
// when child data change should DispatchEventByServiceName
func (e *etcdV3ServiceDiscovery) DataChange(eventType remoting.Event) bool {
-
if eventType.Action == remoting.EventTypeUpdate {
instance := ®istry.DefaultServiceInstance{}
err := jsonutil.DecodeJSON([]byte(eventType.Content), &instance)
@@ -291,7 +285,6 @@
// netEcdv3ServiceDiscovery
func newEtcdV3ServiceDiscovery(name string) (registry.ServiceDiscovery, error) {
-
initLock.Lock()
defer initLock.Unlock()
@@ -315,9 +308,9 @@
logger.Infof("etcd address is: %v,timeout is:%s", remoteConfig.Address, timeout.String())
client := etcdv3.NewServiceDiscoveryClient(
- etcdv3.WithName(etcdv3.RegistryETCDV3Client),
- etcdv3.WithTimeout(timeout),
- etcdv3.WithEndpoints(strings.Split(remoteConfig.Address, ",")...),
+ gxetcd.WithName(gxetcd.RegistryETCDV3Client),
+ gxetcd.WithTimeout(timeout),
+ gxetcd.WithEndpoints(strings.Split(remoteConfig.Address, ",")...),
)
descriptor := fmt.Sprintf("etcd-service-discovery[%s]", remoteConfig.Address)
diff --git a/registry/event/customizable_service_instance_listener.go b/registry/event/customizable_service_instance_listener.go
index 07e84c1..65e56e6 100644
--- a/registry/event/customizable_service_instance_listener.go
+++ b/registry/event/customizable_service_instance_listener.go
@@ -32,8 +32,7 @@
}
// customizableServiceInstanceListener is singleton
-type customizableServiceInstanceListener struct {
-}
+type customizableServiceInstanceListener struct{}
// GetPriority return priority 9999,
// 9999 is big enough to make sure it will be last invoked
diff --git a/registry/event/customizable_service_instance_listener_test.go b/registry/event/customizable_service_instance_listener_test.go
index 1c81ece..b2dcd93 100644
--- a/registry/event/customizable_service_instance_listener_test.go
+++ b/registry/event/customizable_service_instance_listener_test.go
@@ -32,7 +32,6 @@
)
func TestGetCustomizableServiceInstanceListener(t *testing.T) {
-
prepareMetadataServiceForTest()
cus := GetCustomizableServiceInstanceListener()
@@ -50,8 +49,7 @@
assert.NotNil(t, tp)
}
-type mockEvent struct {
-}
+type mockEvent struct{}
func (m *mockEvent) String() string {
panic("implement me")
@@ -65,8 +63,7 @@
panic("implement me")
}
-type mockCustomizer struct {
-}
+type mockCustomizer struct{}
func (m *mockCustomizer) GetPriority() int {
return 0
diff --git a/registry/event/event_publishing_service_deiscovery_test.go b/registry/event/event_publishing_service_deiscovery_test.go
index 504f7b5..4979f1d 100644
--- a/registry/event/event_publishing_service_deiscovery_test.go
+++ b/registry/event/event_publishing_service_deiscovery_test.go
@@ -40,7 +40,6 @@
)
func TestEventPublishingServiceDiscovery_DispatchEvent(t *testing.T) {
-
// extension.SetMetadataService("local", inmemory.NewMetadataService)
config.GetApplicationConfig().MetadataType = "local"
@@ -69,7 +68,6 @@
si := ®istry.DefaultServiceInstance{Id: "testServiceInstance"}
err = dc.Register(si)
assert.Nil(t, err)
-
}
type TestServiceDiscoveryDestroyingEventListener struct {
@@ -113,8 +111,7 @@
return reflect.TypeOf(ServiceInstancePreRegisteredEvent{})
}
-type ServiceDiscoveryA struct {
-}
+type ServiceDiscoveryA struct{}
// String return mockServiceDiscovery
func (msd *ServiceDiscoveryA) String() string {
@@ -178,8 +175,7 @@
return nil
}
-type mockServiceNameMapping struct {
-}
+type mockServiceNameMapping struct{}
func (m *mockServiceNameMapping) Map(serviceInterface string, group string, version string, protocol string) error {
return nil
diff --git a/registry/event/event_publishing_service_discovery.go b/registry/event/event_publishing_service_discovery.go
index 773eee6..6c418c1 100644
--- a/registry/event/event_publishing_service_discovery.go
+++ b/registry/event/event_publishing_service_discovery.go
@@ -64,7 +64,6 @@
}
return epsd.executeWithEvents(NewServiceInstancePreRegisteredEvent(epsd.serviceDiscovery, instance),
f, NewServiceInstanceRegisteredEvent(epsd.serviceDiscovery, instance))
-
}
// Update returns the result of serviceDiscovery.Update
diff --git a/registry/event/log_event_listener.go b/registry/event/log_event_listener.go
index 0781a6d..c73ff29 100644
--- a/registry/event/log_event_listener.go
+++ b/registry/event/log_event_listener.go
@@ -33,8 +33,7 @@
}
// logEventListener is singleton
-type logEventListener struct {
-}
+type logEventListener struct{}
func (l *logEventListener) GetPriority() int {
return 0
@@ -49,8 +48,10 @@
return reflect.TypeOf(&observer.BaseEvent{})
}
-var logEventListenerInstance *logEventListener
-var logEventListenerOnce sync.Once
+var (
+ logEventListenerInstance *logEventListener
+ logEventListenerOnce sync.Once
+)
func GetLogEventListener() observer.EventListener {
logEventListenerOnce.Do(func() {
diff --git a/registry/event/metadata_service_url_params_customizer.go b/registry/event/metadata_service_url_params_customizer.go
index 6d8f99b..2274cac 100644
--- a/registry/event/metadata_service_url_params_customizer.go
+++ b/registry/event/metadata_service_url_params_customizer.go
@@ -42,7 +42,6 @@
// remove TIMESTAMP_KEY because it's nonsense
constant.TIMESTAMP_KEY)
extension.AddCustomizers(&metadataServiceURLParamsMetadataCustomizer{exceptKeys: exceptKeys})
-
}
type metadataServiceURLParamsMetadataCustomizer struct {
@@ -79,7 +78,6 @@
}
func (m *metadataServiceURLParamsMetadataCustomizer) convertToParams(urls []interface{}) map[string]map[string]string {
-
// usually there will be only one protocol
res := make(map[string]map[string]string, 1)
// those keys are useless
diff --git a/registry/event/metadata_service_url_params_customizer_test.go b/registry/event/metadata_service_url_params_customizer_test.go
index c041232..690c95d 100644
--- a/registry/event/metadata_service_url_params_customizer_test.go
+++ b/registry/event/metadata_service_url_params_customizer_test.go
@@ -44,7 +44,6 @@
}
func TestMetadataServiceURLParamsMetadataCustomizer(t *testing.T) {
-
prepareMetadataServiceForTest()
msup := &metadataServiceURLParamsMetadataCustomizer{exceptKeys: gxset.NewSet()}
diff --git a/registry/event/protocol_ports_metadata_customizer.go b/registry/event/protocol_ports_metadata_customizer.go
index a58471c..8f40149 100644
--- a/registry/event/protocol_ports_metadata_customizer.go
+++ b/registry/event/protocol_ports_metadata_customizer.go
@@ -35,8 +35,7 @@
}
// ProtocolPortsMetadataCustomizer will update the endpoints
-type ProtocolPortsMetadataCustomizer struct {
-}
+type ProtocolPortsMetadataCustomizer struct{}
// GetPriority will return 0, which means it will be invoked at the beginning
func (p *ProtocolPortsMetadataCustomizer) GetPriority() int {
diff --git a/registry/event/service_revision_customizer.go b/registry/event/service_revision_customizer.go
index 4793e91..5d9668c 100644
--- a/registry/event/service_revision_customizer.go
+++ b/registry/event/service_revision_customizer.go
@@ -39,8 +39,7 @@
extension.AddCustomizers(&subscribedServicesRevisionMetadataCustomizer{})
}
-type exportedServicesRevisionMetadataCustomizer struct {
-}
+type exportedServicesRevisionMetadataCustomizer struct{}
// GetPriority will return 1 so that it will be invoked in front of user defining Customizer
func (e *exportedServicesRevisionMetadataCustomizer) GetPriority() int {
@@ -56,7 +55,6 @@
}
urls, err := ms.GetExportedURLs(constant.ANY_VALUE, constant.ANY_VALUE, constant.ANY_VALUE, constant.ANY_VALUE)
-
if err != nil {
logger.Errorf("could not find the exported url", err)
}
@@ -68,8 +66,7 @@
instance.GetMetadata()[constant.EXPORTED_SERVICES_REVISION_PROPERTY_NAME] = revision
}
-type subscribedServicesRevisionMetadataCustomizer struct {
-}
+type subscribedServicesRevisionMetadataCustomizer struct{}
// GetPriority will return 2 so that it will be invoked in front of user defining Customizer
func (e *subscribedServicesRevisionMetadataCustomizer) GetPriority() int {
@@ -85,7 +82,6 @@
}
urls, err := ms.GetSubscribedURLs()
-
if err != nil {
logger.Errorf("could not find the subscribed url", err)
}
diff --git a/registry/file/listener.go b/registry/file/listener.go
index 3fe7400..5d2193a 100644
--- a/registry/file/listener.go
+++ b/registry/file/listener.go
@@ -20,10 +20,8 @@
import "github.com/apache/dubbo-go/config_center"
// RegistryConfigurationListener represent the processor of flie watcher
-type RegistryConfigurationListener struct {
-}
+type RegistryConfigurationListener struct{}
// Process submit the ConfigChangeEvent to the event chan to notify all observer
func (l *RegistryConfigurationListener) Process(configType *config_center.ConfigChangeEvent) {
-
}
diff --git a/registry/file/service_discovery.go b/registry/file/service_discovery.go
index 768a1c2..f68498d 100644
--- a/registry/file/service_discovery.go
+++ b/registry/file/service_discovery.go
@@ -265,7 +265,7 @@
// AddListener adds a new ServiceInstancesChangedListener
// client
func (fssd *fileSystemServiceDiscovery) AddListener(listener *registry.ServiceInstancesChangedListener) error {
- //fssd.dynamicConfiguration.AddListener(listener.ServiceName)
+ // fssd.dynamicConfiguration.AddListener(listener.ServiceName)
return nil
}
diff --git a/registry/file/service_discovery_test.go b/registry/file/service_discovery_test.go
index 0062eae..ee2ad27 100644
--- a/registry/file/service_discovery_test.go
+++ b/registry/file/service_discovery_test.go
@@ -35,9 +35,7 @@
"github.com/apache/dubbo-go/registry"
)
-var (
- testName = "test"
-)
+var testName = "test"
func TestNewFileSystemServiceDiscoveryAndDestroy(t *testing.T) {
prepareData()
diff --git a/registry/kubernetes/listener.go b/registry/kubernetes/listener.go
index e20b7c7..9b8075c 100644
--- a/registry/kubernetes/listener.go
+++ b/registry/kubernetes/listener.go
@@ -51,7 +51,6 @@
// DataChange
// notify listen, when interest event
func (l *dataListener) DataChange(eventType remoting.Event) bool {
-
index := strings.Index(eventType.Path, "/providers/")
if index == -1 {
logger.Warnf("Listen with no url, event.path={%v}", eventType.Path)
diff --git a/registry/kubernetes/listener_test.go b/registry/kubernetes/listener_test.go
index ef6e8fb..e70c15d 100644
--- a/registry/kubernetes/listener_test.go
+++ b/registry/kubernetes/listener_test.go
@@ -44,7 +44,6 @@
func (*MockDataListener) Process(configType *config_center.ConfigChangeEvent) {}
func TestDataChange(t *testing.T) {
-
listener := NewRegistryDataListener(&MockDataListener{})
url, _ := common.NewURL("jsonrpc%3A%2F%2F127.0.0.1%3A20001%2Fcom.ikurento.user.UserProvider%3Fanyhost%3Dtrue%26app.version%3D0.0.1%26application%3DBDTService%26category%3Dproviders%26cluster%3Dfailover%26dubbo%3Ddubbo-provider-golang-2.6.0%26environment%3Ddev%26group%3D%26interface%3Dcom.ikurento.user.UserProvider%26ip%3D10.32.20.124%26loadbalance%3Drandom%26methods.GetUser.loadbalance%3Drandom%26methods.GetUser.retries%3D1%26methods.GetUser.weight%3D0%26module%3Ddubbogo%2Buser-info%2Bserver%26name%3DBDTService%26organization%3Dikurento.com%26owner%3DZX%26pid%3D74500%26retries%3D0%26service.filter%3Decho%26side%3Dprovider%26timestamp%3D1560155407%26version%3D%26warmup%3D100")
listener.AddInterestedURL(url)
diff --git a/registry/kubernetes/registry.go b/registry/kubernetes/registry.go
index c4a0352..9be6387 100644
--- a/registry/kubernetes/registry.go
+++ b/registry/kubernetes/registry.go
@@ -25,7 +25,7 @@
)
import (
- "github.com/apache/dubbo-getty"
+ getty "github.com/apache/dubbo-getty"
perrors "github.com/pkg/errors"
v1 "k8s.io/api/core/v1"
)
@@ -46,8 +46,8 @@
)
func init() {
- //processID = fmt.Sprintf("%d", os.Getpid())
- //localIP = common.GetLocalIp()
+ // processID = fmt.Sprintf("%d", os.Getpid())
+ // localIP = common.GetLocalIp()
extension.SetRegistry(Name, newKubernetesRegistry)
}
@@ -84,7 +84,6 @@
// CloseListener closes listeners
func (r *kubernetesRegistry) CloseListener() {
-
r.cltLock.Lock()
l := r.configListener
r.cltLock.Unlock()
@@ -113,10 +112,7 @@
// DoSubscribe actually subscribe the provider URL
func (r *kubernetesRegistry) DoSubscribe(svc *common.URL) (registry.Listener, error) {
-
- var (
- configListener *configurationListener
- )
+ var configListener *configurationListener
r.listenerLock.Lock()
configListener = r.configListener
@@ -137,7 +133,7 @@
r.listenerLock.Unlock()
}
- //register the svc to dataListener
+ // register the svc to dataListener
r.dataListener.AddInterestedURL(svc)
go r.listener.ListenServiceEvent(fmt.Sprintf("/dubbo/%s/"+constant.DEFAULT_CATEGORY, svc.Service()), r.dataListener)
@@ -157,7 +153,6 @@
}
func newKubernetesRegistry(url *common.URL) (registry.Registry, error) {
-
// actually, kubernetes use in-cluster config,
r := &kubernetesRegistry{}
@@ -196,13 +191,12 @@
// HandleClientRestart will reconnect to kubernetes registry center
func (r *kubernetesRegistry) HandleClientRestart() {
-
var (
err error
failTimes int
)
- defer r.WaitGroup()
+ defer r.WaitGroup().Done()
LOOP:
for {
select {
diff --git a/registry/kubernetes/registry_test.go b/registry/kubernetes/registry_test.go
index a816b03..7200dd5 100644
--- a/registry/kubernetes/registry_test.go
+++ b/registry/kubernetes/registry_test.go
@@ -202,7 +202,6 @@
`
func getTestRegistry(t *testing.T) *kubernetesRegistry {
-
const (
podNameKey = "HOSTNAME"
nameSpaceKey = "NAMESPACE"
@@ -240,7 +239,6 @@
}
func TestRegister(t *testing.T) {
-
r := getTestRegistry(t)
defer r.Destroy()
@@ -259,7 +257,6 @@
}
func TestSubscribe(t *testing.T) {
-
r := getTestRegistry(t)
defer r.Destroy()
@@ -276,7 +273,6 @@
wg := sync.WaitGroup{}
wg.Add(1)
go func() {
-
defer wg.Done()
registerErr := r.Register(url)
if registerErr != nil {
@@ -294,7 +290,6 @@
}
func TestConsumerDestroy(t *testing.T) {
-
r := getTestRegistry(t)
url, _ := common.NewURL("dubbo://127.0.0.1:20000/com.ikurento.user.UserProvider",
@@ -306,16 +301,14 @@
t.Fatal(err)
}
- //listener.Close()
+ // listener.Close()
time.Sleep(1e9)
r.Destroy()
assert.Equal(t, false, r.IsAvailable())
-
}
func TestProviderDestroy(t *testing.T) {
-
r := getTestRegistry(t)
url, _ := common.NewURL("dubbo://127.0.0.1:20000/com.ikurento.user.UserProvider",
@@ -330,7 +323,6 @@
}
func TestNewRegistry(t *testing.T) {
-
regUrl, err := common.NewURL("registry://127.0.0.1:443",
common.WithParamsValue(constant.ROLE_KEY, strconv.Itoa(common.PROVIDER)))
if err != nil {
@@ -343,7 +335,6 @@
}
func TestHandleClientRestart(t *testing.T) {
-
r := getTestRegistry(t)
r.WaitGroup().Add(1)
go r.HandleClientRestart()
diff --git a/registry/mock_registry.go b/registry/mock_registry.go
index 6287bb0..953f428 100644
--- a/registry/mock_registry.go
+++ b/registry/mock_registry.go
@@ -141,7 +141,6 @@
}
func (*listener) Close() {
-
}
// nolint
diff --git a/registry/nacos/listener.go b/registry/nacos/listener.go
index d2b5746..5958df4 100644
--- a/registry/nacos/listener.go
+++ b/registry/nacos/listener.go
@@ -124,7 +124,7 @@
nl.cacheLock.Lock()
defer nl.cacheLock.Unlock()
for i := range services {
- if !services[i].Enable || !services[i].Valid {
+ if !services[i].Enable {
// instance is not available,so ignore it
continue
}
diff --git a/registry/nacos/registry.go b/registry/nacos/registry.go
index e9a4bd3..4bc88d7 100644
--- a/registry/nacos/registry.go
+++ b/registry/nacos/registry.go
@@ -41,9 +41,7 @@
"github.com/apache/dubbo-go/registry"
)
-var (
- localIP = ""
-)
+var localIP = ""
const (
// RegistryConnDelay registry connection delay
@@ -293,7 +291,7 @@
clientConfig.Endpoint = url.GetParam(constant.NACOS_ENDPOINT, "")
clientConfig.NamespaceId = url.GetParam(constant.NACOS_NAMESPACE_ID, "")
- //enable local cache when nacos can not connect.
+ // enable local cache when nacos can not connect.
notLoadCache, err := strconv.ParseBool(url.GetParam(constant.NACOS_NOT_LOAD_LOCAL_CACHE, "false"))
if err != nil {
logger.Errorf("ParseBool - error: %v", err)
diff --git a/registry/nacos/registry_test.go b/registry/nacos/registry_test.go
index b828205..ab770fb 100644
--- a/registry/nacos/registry_test.go
+++ b/registry/nacos/registry_test.go
@@ -114,7 +114,6 @@
}
t.Logf("serviceEvent:%+v \n", serviceEvent)
assert.Regexp(t, ".*ServiceEvent{Action{add}.*", serviceEvent.String())
-
}
func TestNacosRegistry_Subscribe_del(t *testing.T) {
@@ -178,9 +177,11 @@
assert.Regexp(t, ".*ServiceEvent{Action{add}.*", serviceEvent2.String())
nacosReg := reg.(*nacosRegistry)
- //deregister instance to mock instance offline
- _, err = nacosReg.namingClient.DeregisterInstance(vo.DeregisterInstanceParam{Ip: "127.0.0.2", Port: 20000,
- ServiceName: "providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc"})
+ // deregister instance to mock instance offline
+ _, err = nacosReg.namingClient.DeregisterInstance(vo.DeregisterInstanceParam{
+ Ip: "127.0.0.2", Port: 20000,
+ ServiceName: "providers:com.ikurento.user.UserProvider:2.0.0:guangzhou-idc",
+ })
assert.NoError(t, err)
serviceEvent3, _ := listener.Next()
diff --git a/registry/nacos/service_discovery.go b/registry/nacos/service_discovery.go
index 4533e7b..785e395 100644
--- a/registry/nacos/service_discovery.go
+++ b/registry/nacos/service_discovery.go
@@ -308,7 +308,6 @@
// newNacosServiceDiscovery will create new service discovery instance
// use double-check pattern to reduce race condition
func newNacosServiceDiscovery(name string) (registry.ServiceDiscovery, error) {
-
instance, ok := instanceMap[name]
if ok {
return instance, nil
diff --git a/registry/nacos/service_discovery_test.go b/registry/nacos/service_discovery_test.go
index aa044ad..a9bc27b 100644
--- a/registry/nacos/service_discovery_test.go
+++ b/registry/nacos/service_discovery_test.go
@@ -37,9 +37,7 @@
"github.com/apache/dubbo-go/registry"
)
-var (
- testName = "test"
-)
+var testName = "test"
func Test_newNacosServiceDiscovery(t *testing.T) {
name := "nacos1"
@@ -67,7 +65,6 @@
res, err := newNacosServiceDiscovery(name)
assert.Nil(t, err)
assert.NotNil(t, res)
-
}
func TestNacosServiceDiscovery_Destroy(t *testing.T) {
@@ -121,8 +118,8 @@
err = serviceDiscovery.Register(instance)
assert.Nil(t, err)
- //sometimes nacos may be failed to push update of instance,
- //so it need 10s to pull, we sleep 10 second to make sure instance has been update
+ // sometimes nacos may be failed to push update of instance,
+ // so it need 10s to pull, we sleep 10 second to make sure instance has been update
time.Sleep(11 * time.Second)
page := serviceDiscovery.GetHealthyInstancesByPage(serviceName, 0, 10, true)
assert.NotNil(t, page)
@@ -135,7 +132,8 @@
assert.Equal(t, id, instance.GetId())
assert.Equal(t, host, instance.GetHost())
assert.Equal(t, port, instance.GetPort())
- assert.Equal(t, serviceName, instance.GetServiceName())
+ // TODO: console.nacos.io has updated to nacos 2.0 and serviceName has changed in 2.0, so ignore temporarily.
+ // assert.Equal(t, serviceName, instance.GetServiceName())
assert.Equal(t, 0, len(instance.GetMetadata()))
instance.Metadata["a"] = "b"
diff --git a/registry/protocol/protocol.go b/registry/protocol/protocol.go
index 51339c6..0282e42 100644
--- a/registry/protocol/protocol.go
+++ b/registry/protocol/protocol.go
@@ -131,8 +131,8 @@
// Refer provider service from registry center
func (proto *registryProtocol) Refer(url *common.URL) protocol.Invoker {
- var registryUrl = url
- var serviceUrl = registryUrl.SubURL
+ registryUrl := url
+ serviceUrl := registryUrl.SubURL
if registryUrl.Protocol == constant.REGISTRY_PROTOCOL {
registryUrl.Protocol = registryUrl.GetParam(constant.REGISTRY_KEY, "")
}
diff --git a/registry/protocol/protocol_test.go b/registry/protocol/protocol_test.go
index 0fca552..c425905 100644
--- a/registry/protocol/protocol_test.go
+++ b/registry/protocol/protocol_test.go
@@ -138,7 +138,6 @@
}
func TestExporter(t *testing.T) {
-
regProtocol := newRegistryProtocol()
exporterNormal(t, regProtocol)
}
@@ -295,5 +294,4 @@
assert.NotContains(t, providerUrl.GetParams(), ".c")
assert.NotContains(t, providerUrl.GetParams(), ".d")
assert.Contains(t, providerUrl.GetParams(), "a")
-
}
diff --git a/registry/servicediscovery/instance/random/random_service_instance_selector.go b/registry/servicediscovery/instance/random/random_service_instance_selector.go
index 7e4e0ee..95ca185 100644
--- a/registry/servicediscovery/instance/random/random_service_instance_selector.go
+++ b/registry/servicediscovery/instance/random/random_service_instance_selector.go
@@ -33,9 +33,8 @@
extension.SetServiceInstanceSelector("random", NewRandomServiceInstanceSelector)
}
-//the ServiceInstanceSelector implementation based on Random algorithm
-type RandomServiceInstanceSelector struct {
-}
+// the ServiceInstanceSelector implementation based on Random algorithm
+type RandomServiceInstanceSelector struct{}
func NewRandomServiceInstanceSelector() instance.ServiceInstanceSelector {
return &RandomServiceInstanceSelector{}
@@ -51,5 +50,4 @@
rand.Seed(time.Now().UnixNano())
index := rand.Intn(len(serviceInstances))
return serviceInstances[index]
-
}
diff --git a/registry/servicediscovery/instance/service_instance_selector.go b/registry/servicediscovery/instance/service_instance_selector.go
index 5690ab6..a5ad3db 100644
--- a/registry/servicediscovery/instance/service_instance_selector.go
+++ b/registry/servicediscovery/instance/service_instance_selector.go
@@ -23,6 +23,6 @@
)
type ServiceInstanceSelector interface {
- //Select an instance of ServiceInstance by the specified ServiceInstance service instances
+ // Select an instance of ServiceInstance by the specified ServiceInstance service instances
Select(url *common.URL, serviceInstances []registry.ServiceInstance) registry.ServiceInstance
}
diff --git a/registry/servicediscovery/service_discovery_registry.go b/registry/servicediscovery/service_discovery_registry.go
index c97a7f7..e3f2af3 100644
--- a/registry/servicediscovery/service_discovery_registry.go
+++ b/registry/servicediscovery/service_discovery_registry.go
@@ -73,7 +73,6 @@
}
func newServiceDiscoveryRegistry(url *common.URL) (registry.Registry, error) {
-
tryInitMetadataService(url)
serviceDiscovery, err := creatServiceDiscovery(url)
@@ -131,7 +130,7 @@
if len(literalServices) == 0 {
return set
}
- var splitServices = strings.Split(literalServices, ",")
+ splitServices := strings.Split(literalServices, ",")
for _, s := range splitServices {
if len(s) != 0 {
set.Add(s)
@@ -165,7 +164,6 @@
return nil
}
ok, err := s.metaDataService.ExportURL(url)
-
if err != nil {
logger.Errorf("The URL[%s] registry catch error:%s!", url.String(), err.Error())
return err
@@ -226,7 +224,6 @@
logger.Errorf("add listener[%s] catch error,url:%s err:%s", listenerId, url.String(), err.Error())
}
}
-
}
func getUrlKey(url *common.URL) string {
@@ -274,7 +271,6 @@
Service: url,
})
}
-
}
func (s *serviceDiscoveryRegistry) synthesizeSubscribedURLs(subscribedURL *common.URL, serviceInstances []registry.ServiceInstance) []*common.URL {
@@ -363,7 +359,6 @@
for _, ui := range result {
u, err := common.NewURL(ui.(string))
-
if err != nil {
logger.Errorf("could not parse the url string to URL structure: %s", ui.(string), err)
continue
@@ -522,7 +517,6 @@
}
}
return clonedExportedURLs
-
}
type endpoint struct {
@@ -549,6 +543,7 @@
}
return -1
}
+
func (s *serviceDiscoveryRegistry) getTemplateExportedURLs(url *common.URL, serviceInstance registry.ServiceInstance) []*common.URL {
exportedURLs := s.getRevisionExportedURLs(serviceInstance)
if len(exportedURLs) == 0 {
@@ -607,21 +602,17 @@
}
func (icn *InstanceChangeNotify) Notify(event observer.Event) {
-
if se, ok := event.(*registry.ServiceInstancesChangedEvent); ok {
sdr := icn.serviceDiscoveryRegistry
sdr.subscribe(sdr.url.SubURL, icn.notify, se.ServiceName, se.Instances)
}
}
-var (
- exporting = &atomic.Bool{}
-)
+var exporting = &atomic.Bool{}
// tryInitMetadataService will try to initialize metadata service
// TODO (move to somewhere)
func tryInitMetadataService(url *common.URL) {
-
ms, err := extension.GetMetadataService(config.GetApplicationConfig().MetadataType)
if err != nil {
logger.Errorf("could not init metadata service", err)
diff --git a/registry/servicediscovery/service_discovery_registry_test.go b/registry/servicediscovery/service_discovery_registry_test.go
index 391d92c..6e1f228 100644
--- a/registry/servicediscovery/service_discovery_registry_test.go
+++ b/registry/servicediscovery/service_discovery_registry_test.go
@@ -26,6 +26,7 @@
"github.com/dubbogo/gost/hash/page"
"github.com/stretchr/testify/assert"
)
+
import (
"github.com/apache/dubbo-go/common"
"github.com/apache/dubbo-go/common/extension"
@@ -83,8 +84,7 @@
assert.NoError(t, err)
}
-type mockEventDispatcher struct {
-}
+type mockEventDispatcher struct{}
func (m *mockEventDispatcher) AddEventListener(observer.EventListener) {
}
@@ -111,8 +111,7 @@
func (m *mockEventDispatcher) Dispatch(observer.Event) {
}
-type mockServiceNameMapping struct {
-}
+type mockServiceNameMapping struct{}
func (m *mockServiceNameMapping) Map(string, string, string, string) error {
return nil
@@ -122,8 +121,7 @@
panic("implement me")
}
-type mockServiceDiscovery struct {
-}
+type mockServiceDiscovery struct{}
func (m *mockServiceDiscovery) String() string {
panic("implement me")
@@ -185,8 +183,7 @@
panic("implement me")
}
-type mockMetadataService struct {
-}
+type mockMetadataService struct{}
func (m *mockMetadataService) Reference() string {
panic("implement me")
diff --git a/registry/servicediscovery/synthesizer/rest/rest_subscribed_urls_synthesizer.go b/registry/servicediscovery/synthesizer/rest/rest_subscribed_urls_synthesizer.go
index c6b3aea..a002aad 100644
--- a/registry/servicediscovery/synthesizer/rest/rest_subscribed_urls_synthesizer.go
+++ b/registry/servicediscovery/synthesizer/rest/rest_subscribed_urls_synthesizer.go
@@ -33,9 +33,8 @@
synthesizer.AddSynthesizer(NewRestSubscribedURLsSynthesizer())
}
-//SubscribedURLsSynthesizer implementation for rest protocol
-type RestSubscribedURLsSynthesizer struct {
-}
+// SubscribedURLsSynthesizer implementation for rest protocol
+type RestSubscribedURLsSynthesizer struct{}
func (r RestSubscribedURLsSynthesizer) Support(subscribedURL *common.URL) bool {
return "rest" == subscribedURL.Protocol
diff --git a/registry/zookeeper/listener.go b/registry/zookeeper/listener.go
index 88109fc..d8e7629 100644
--- a/registry/zookeeper/listener.go
+++ b/registry/zookeeper/listener.go
@@ -20,6 +20,8 @@
import (
"strings"
"sync"
+
+ gxzookeeper "github.com/dubbogo/gost/database/kv/zk"
)
import (
@@ -32,7 +34,6 @@
"github.com/apache/dubbo-go/config_center"
"github.com/apache/dubbo-go/registry"
"github.com/apache/dubbo-go/remoting"
- zk "github.com/apache/dubbo-go/remoting/zookeeper"
)
// RegistryDataListener contains all URL information subscribed by zookeeper registry
@@ -45,7 +46,8 @@
// NewRegistryDataListener constructs a new RegistryDataListener
func NewRegistryDataListener() *RegistryDataListener {
return &RegistryDataListener{
- subscribed: make(map[string]config_center.ConfigurationListener)}
+ subscribed: make(map[string]config_center.ConfigurationListener),
+ }
}
// SubscribeURL is used to set a watch listener for url
@@ -56,12 +58,13 @@
l.subscribed[url.ServiceKey()] = listener
}
-// UnSubscribeURL is used to set a watch listener for url
+// UnSubscribeURL is used to unset a watch listener for url
func (l *RegistryDataListener) UnSubscribeURL(url *common.URL) config_center.ConfigurationListener {
if l.closed {
return nil
}
listener := l.subscribed[url.ServiceKey()]
+ listener.(*RegistryConfigurationListener).Close()
delete(l.subscribed, url.ServiceKey())
return listener
}
@@ -112,7 +115,7 @@
// RegistryConfigurationListener represent the processor of zookeeper watcher
type RegistryConfigurationListener struct {
- client *zk.ZookeeperClient
+ client *gxzookeeper.ZookeeperClient
registry *zkRegistry
events chan *config_center.ConfigChangeEvent
isClosed bool
@@ -122,7 +125,7 @@
}
// NewRegistryConfigurationListener for listening the event of zk.
-func NewRegistryConfigurationListener(client *zk.ZookeeperClient, reg *zkRegistry, conf *common.URL) *RegistryConfigurationListener {
+func NewRegistryConfigurationListener(client *gxzookeeper.ZookeeperClient, reg *zkRegistry, conf *common.URL) *RegistryConfigurationListener {
reg.WaitGroup().Add(1)
return &RegistryConfigurationListener{
client: client,
@@ -130,7 +133,8 @@
events: make(chan *config_center.ConfigChangeEvent, 32),
isClosed: false,
close: make(chan struct{}, 1),
- subscribeURL: conf}
+ subscribeURL: conf,
+ }
}
// Process submit the ConfigChangeEvent to the event chan to notify all observer
@@ -142,9 +146,6 @@
func (l *RegistryConfigurationListener) Next() (*registry.ServiceEvent, error) {
for {
select {
- case <-l.client.Done():
- logger.Warnf("listener's zk client connection (address {%s}) is broken, so zk event listener exit now.", l.client.ZkAddrs)
- return nil, perrors.New("zookeeper client stopped")
case <-l.close:
return nil, perrors.New("listener have been closed")
case <-l.registry.Done():
@@ -156,9 +157,6 @@
logger.Warnf("update @result{%s}. But its connection to registry is invalid", e.Value)
continue
}
- //r.update(e.res)
- //write to invoker
- //r.outerEventCh <- e.res
return ®istry.ServiceEvent{Action: e.ConfigType, Service: e.Value.(*common.URL)}, nil
}
}
diff --git a/registry/zookeeper/listener_test.go b/registry/zookeeper/listener_test.go
index 20ec1cf..c41c831 100644
--- a/registry/zookeeper/listener_test.go
+++ b/registry/zookeeper/listener_test.go
@@ -39,8 +39,7 @@
assert.Equal(t, true, int)
}
-type MockConfigurationListener struct {
-}
+type MockConfigurationListener struct{}
func (*MockConfigurationListener) Process(configType *config_center.ConfigChangeEvent) {
}
diff --git a/registry/zookeeper/registry.go b/registry/zookeeper/registry.go
index 55b0df7..12c78d9 100644
--- a/registry/zookeeper/registry.go
+++ b/registry/zookeeper/registry.go
@@ -27,6 +27,7 @@
import (
"github.com/dubbogo/go-zookeeper/zk"
+ gxzookeeper "github.com/dubbogo/gost/database/kv/zk"
perrors "github.com/pkg/errors"
)
@@ -54,12 +55,12 @@
type zkRegistry struct {
registry.BaseRegistry
- client *zookeeper.ZookeeperClient
+ client *gxzookeeper.ZookeeperClient
listenerLock sync.Mutex
listener *zookeeper.ZkEventListener
dataListener *RegistryDataListener
cltLock sync.Mutex
- //for provider
+ // for provider
zkPath map[string]int // key = protocol://ip:port/interface
}
@@ -73,11 +74,12 @@
}
r.InitBaseRegistry(url, r)
- err = zookeeper.ValidateZookeeperClient(r, zookeeper.WithZkName(RegistryZkClient))
+ err = zookeeper.ValidateZookeeperClient(r, RegistryZkClient)
if err != nil {
return nil, err
}
+ r.WaitGroup().Add(1) //zk client start successful, then wg +1
go zookeeper.HandleClientRestart(r)
r.listener = zookeeper.NewZkEventListener(r.client)
@@ -89,29 +91,29 @@
// nolint
type Options struct {
- client *zookeeper.ZookeeperClient
+ client *gxzookeeper.ZookeeperClient
}
// nolint
type Option func(*Options)
-func newMockZkRegistry(url *common.URL, opts ...zookeeper.Option) (*zk.TestCluster, *zkRegistry, error) {
+func newMockZkRegistry(url *common.URL, opts ...gxzookeeper.Option) (*zk.TestCluster, *zkRegistry, error) {
var (
err error
r *zkRegistry
c *zk.TestCluster
- //event <-chan zk.Event
+ // event <-chan zk.Event
)
r = &zkRegistry{
zkPath: make(map[string]int),
}
r.InitBaseRegistry(url, r)
- c, r.client, _, err = zookeeper.NewMockZookeeperClient("test", 15*time.Second, opts...)
+ c, r.client, _, err = gxzookeeper.NewMockZookeeperClient("test", 15*time.Second, opts...)
if err != nil {
return nil, nil, err
}
- r.WaitGroup().Add(1) //zk client start successful, then wg +1
+ r.WaitGroup().Add(1) // zk client start successful, then wg +1
go zookeeper.HandleClientRestart(r)
r.InitListeners()
return c, r, nil
@@ -183,12 +185,12 @@
}
// nolint
-func (r *zkRegistry) ZkClient() *zookeeper.ZookeeperClient {
+func (r *zkRegistry) ZkClient() *gxzookeeper.ZookeeperClient {
return r.client
}
// nolint
-func (r *zkRegistry) SetZkClient(client *zookeeper.ZookeeperClient) {
+func (r *zkRegistry) SetZkClient(client *gxzookeeper.ZookeeperClient) {
r.client = client
}
@@ -242,7 +244,6 @@
}
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)
@@ -279,30 +280,23 @@
r.listenerLock.Unlock()
}
- //Interested register to dataconfig.
+ // 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.DEFAULT_CATEGORY, url.QueryEscape(conf.Service())), r.dataListener)
return zkListener, nil
}
func (r *zkRegistry) getCloseListener(conf *common.URL) (*RegistryConfigurationListener, error) {
-
var zkListener *RegistryConfigurationListener
r.dataListener.mutex.Lock()
configurationListener := r.dataListener.subscribed[conf.ServiceKey()]
if configurationListener != nil {
- rcListener, _ := configurationListener.(*RegistryConfigurationListener)
- if rcListener != nil {
- if rcListener.isClosed {
- r.dataListener.mutex.Unlock()
- return nil, perrors.New("configListener already been closed")
- }
+ zkListener, _ = configurationListener.(*RegistryConfigurationListener)
+ if zkListener != nil && zkListener.isClosed {
+ r.dataListener.mutex.Unlock()
+ return nil, perrors.New("configListener already been closed")
}
}
@@ -313,7 +307,7 @@
return nil, perrors.New("listener is null can not close.")
}
- //Interested register to dataconfig.
+ // Interested register to dataconfig.
r.listenerLock.Lock()
listener := r.listener
r.listener = nil
diff --git a/registry/zookeeper/registry_test.go b/registry/zookeeper/registry_test.go
index 5959a90..172ffec 100644
--- a/registry/zookeeper/registry_test.go
+++ b/registry/zookeeper/registry_test.go
@@ -24,24 +24,25 @@
)
import (
+ gxzookeeper "github.com/dubbogo/gost/database/kv/zk"
"github.com/stretchr/testify/assert"
)
import (
"github.com/apache/dubbo-go/common"
"github.com/apache/dubbo-go/common/constant"
- "github.com/apache/dubbo-go/remoting/zookeeper"
)
func Test_Register(t *testing.T) {
regURL, _ := common.NewURL("registry://127.0.0.1:1111", common.WithParamsValue(constant.ROLE_KEY, strconv.Itoa(common.PROVIDER)))
url, _ := common.NewURL("dubbo://127.0.0.1:20000/com.ikurento.user.UserProvider", common.WithParamsValue(constant.CLUSTER_KEY, "mock"), common.WithParamsValue("serviceid", "soa.mock"), common.WithMethods([]string{"GetUser", "AddUser"}))
- ts, reg, _ := newMockZkRegistry(regURL)
+ ts, reg, err := newMockZkRegistry(regURL)
+ assert.NoError(t, err)
defer func() {
_ = ts.Stop()
}()
- err := reg.Register(url)
+ err = reg.Register(url)
children, _ := reg.client.GetChildren("/dubbo/com.ikurento.user.UserProvider/providers")
assert.Regexp(t, ".*dubbo%3A%2F%2F127.0.0.1%3A20000%2Fcom.ikurento.user.UserProvider%3Fanyhost%3Dtrue%26cluster%3Dmock%26.*.serviceid%3Dsoa.mock", children)
assert.NoError(t, err)
@@ -80,7 +81,7 @@
url, _ := common.NewURL("dubbo://127.0.0.1:20000/com.ikurento.user.UserProvider", common.WithParamsValue(constant.CLUSTER_KEY, "mock"), common.WithMethods([]string{"GetUser", "AddUser"}))
ts, reg, _ := newMockZkRegistry(regURL)
- //provider register
+ // provider register
err := reg.Register(url)
assert.NoError(t, err)
@@ -88,9 +89,9 @@
return
}
- //consumer register
+ // consumer register
regURL.SetParam(constant.ROLE_KEY, strconv.Itoa(common.CONSUMER))
- _, reg2, _ := newMockZkRegistry(regURL, zookeeper.WithTestCluster(ts))
+ _, reg2, _ := newMockZkRegistry(regURL, gxzookeeper.WithTestCluster(ts))
err = reg2.Register(url)
assert.Nil(t, err)
@@ -112,7 +113,7 @@
url, _ := common.NewURL("dubbo://127.0.0.1:20000/com.ikurento.user.UserProvider", common.WithParamsValue(constant.CLUSTER_KEY, "mock"), common.WithMethods([]string{"GetUser", "AddUser"}))
ts, reg, _ := newMockZkRegistry(regURL)
- //provider register
+ // provider register
err := reg.Register(url)
assert.NoError(t, err)
@@ -120,9 +121,9 @@
return
}
- //consumer register
+ // consumer register
regURL.SetParam(constant.ROLE_KEY, strconv.Itoa(common.CONSUMER))
- _, reg2, _ := newMockZkRegistry(regURL, zookeeper.WithTestCluster(ts))
+ _, reg2, _ := newMockZkRegistry(regURL, gxzookeeper.WithTestCluster(ts))
err = reg2.Register(url)
assert.Nil(t, err)
@@ -158,7 +159,7 @@
_, err = reg.DoSubscribe(url)
assert.NoError(t, err)
- //listener.Close()
+ // listener.Close()
time.Sleep(1e9)
reg.Destroy()
assert.Equal(t, false, reg.IsAvailable())
@@ -177,7 +178,7 @@
err = reg.Register(url)
assert.Nil(t, err)
- //listener.Close()
+ // listener.Close()
time.Sleep(1e9)
reg.Destroy()
assert.Equal(t, false, reg.IsAvailable())
diff --git a/registry/zookeeper/service_discovery.go b/registry/zookeeper/service_discovery.go
index 095a78d..67c89a0 100644
--- a/registry/zookeeper/service_discovery.go
+++ b/registry/zookeeper/service_discovery.go
@@ -26,8 +26,9 @@
)
import (
- "github.com/dubbogo/gost/container/set"
- "github.com/dubbogo/gost/hash/page"
+ gxset "github.com/dubbogo/gost/container/set"
+ gxzookeeper "github.com/dubbogo/gost/database/kv/zk"
+ gxpage "github.com/dubbogo/gost/hash/page"
perrors "github.com/pkg/errors"
)
@@ -60,9 +61,9 @@
}
type zookeeperServiceDiscovery struct {
- client *zookeeper.ZookeeperClient
+ client *gxzookeeper.ZookeeperClient
csd *curator_discovery.ServiceDiscovery
- //listener *zookeeper.ZkEventListener
+ // listener *zookeeper.ZkEventListener
url *common.URL
wg sync.WaitGroup
cltLock sync.Mutex
@@ -107,22 +108,23 @@
url: url,
rootPath: rootPath,
}
- err := zookeeper.ValidateZookeeperClient(zksd, zookeeper.WithZkName(ServiceDiscoveryZkClient))
+ err := zookeeper.ValidateZookeeperClient(zksd, ServiceDiscoveryZkClient)
if err != nil {
return nil, err
}
+ zksd.WaitGroup().Add(1) // zk client start successful, then wg +1
go zookeeper.HandleClientRestart(zksd)
zksd.csd = curator_discovery.NewServiceDiscovery(zksd.client, rootPath)
return zksd, nil
}
// nolint
-func (zksd *zookeeperServiceDiscovery) ZkClient() *zookeeper.ZookeeperClient {
+func (zksd *zookeeperServiceDiscovery) ZkClient() *gxzookeeper.ZookeeperClient {
return zksd.client
}
// nolint
-func (zksd *zookeeperServiceDiscovery) SetZkClient(client *zookeeper.ZookeeperClient) {
+func (zksd *zookeeperServiceDiscovery) SetZkClient(client *gxzookeeper.ZookeeperClient) {
zksd.client = client
}
diff --git a/registry/zookeeper/service_discovery_test.go b/registry/zookeeper/service_discovery_test.go
index c9e14af..a73ecc9 100644
--- a/registry/zookeeper/service_discovery_test.go
+++ b/registry/zookeeper/service_discovery_test.go
@@ -37,11 +37,14 @@
var testName = "test"
+var tc *zk.TestCluster
+
func prepareData(t *testing.T) *zk.TestCluster {
- ts, err := zk.StartTestCluster(1, nil, nil)
+ var err error
+ tc, err = zk.StartTestCluster(1, nil, nil)
assert.NoError(t, err)
- assert.NotNil(t, ts.Servers[0])
- address := "127.0.0.1:" + strconv.Itoa(ts.Servers[0].Port)
+ assert.NotNil(t, tc.Servers[0])
+ address := "127.0.0.1:" + strconv.Itoa(tc.Servers[0].Port)
config.GetBaseConfig().ServiceDiscoveries[testName] = &config.ServiceDiscoveryConfig{
Protocol: "zookeeper",
@@ -52,7 +55,7 @@
Address: address,
TimeoutStr: "10s",
}
- return ts
+ return tc
}
func TestNewZookeeperServiceDiscovery(t *testing.T) {
@@ -74,10 +77,7 @@
}
func TestCURDZookeeperServiceDiscovery(t *testing.T) {
- ts := prepareData(t)
- defer func() {
- _ = ts.Stop()
- }()
+ prepareData(t)
sd, err := newZookeeperServiceDiscovery(testName)
assert.Nil(t, err)
defer func() {
@@ -143,9 +143,8 @@
}
func TestAddListenerZookeeperServiceDiscovery(t *testing.T) {
- ts := prepareData(t)
defer func() {
- _ = ts.Stop()
+ _ = tc.Stop()
}()
sd, err := newZookeeperServiceDiscovery(testName)
assert.Nil(t, err)
diff --git a/remoting/codec.go b/remoting/codec.go
index 607d164..30e6309 100644
--- a/remoting/codec.go
+++ b/remoting/codec.go
@@ -32,9 +32,7 @@
Result interface{}
}
-var (
- codec = make(map[string]Codec, 2)
-)
+var codec = make(map[string]Codec, 2)
func RegistryCodec(protocol string, codecTmp Codec) {
codec[protocol] = codecTmp
diff --git a/remoting/etcdv3/client.go b/remoting/etcdv3/client.go
index 34ee31b..3acdbc4 100644
--- a/remoting/etcdv3/client.go
+++ b/remoting/etcdv3/client.go
@@ -18,110 +18,42 @@
package etcdv3
import (
- "context"
- "sync"
- "time"
-)
-
-import (
- "github.com/coreos/etcd/clientv3"
- "github.com/coreos/etcd/clientv3/concurrency"
+ gxetcd "github.com/dubbogo/gost/database/kv/etcd/v3"
perrors "github.com/pkg/errors"
- "google.golang.org/grpc"
)
import (
"github.com/apache/dubbo-go/common/logger"
)
-const (
- // ConnDelay connection delay
- ConnDelay = 3
- // MaxFailTimes max failure times
- MaxFailTimes = 15
- // RegistryETCDV3Client client name
- RegistryETCDV3Client = "etcd registry"
- // metadataETCDV3Client client name
- MetadataETCDV3Client = "etcd metadata"
-)
-
-var (
- // Defines related errors
- ErrNilETCDV3Client = perrors.New("etcd raw client is nil") // full describe the ERR
- ErrKVPairNotFound = perrors.New("k/v pair not found")
-)
-
-// nolint
-type Options struct {
- name string
- endpoints []string
- client *Client
- timeout time.Duration
- heartbeat int // heartbeat second
-}
-
-// Option will define a function of handling Options
-type Option func(*Options)
-
-// WithEndpoints sets etcd client endpoints
-func WithEndpoints(endpoints ...string) Option {
- return func(opt *Options) {
- opt.endpoints = endpoints
- }
-}
-
-// WithName sets etcd client name
-func WithName(name string) Option {
- return func(opt *Options) {
- opt.name = name
- }
-}
-
-// WithTimeout sets etcd client timeout
-func WithTimeout(timeout time.Duration) Option {
- return func(opt *Options) {
- opt.timeout = timeout
- }
-}
-
-// WithHeartbeat sets etcd client heartbeat
-func WithHeartbeat(heartbeat int) Option {
- return func(opt *Options) {
- opt.heartbeat = heartbeat
- }
-}
-
// ValidateClient validates client and sets options
-func ValidateClient(container clientFacade, opts ...Option) error {
- options := &Options{
- heartbeat: 1, // default heartbeat
- }
+func ValidateClient(container clientFacade, opts ...gxetcd.Option) error {
+ options := &gxetcd.Options{}
for _, opt := range opts {
opt(options)
}
-
lock := container.ClientLock()
lock.Lock()
defer lock.Unlock()
// new Client
if container.Client() == nil {
- newClient, err := NewClient(options.name, options.endpoints, options.timeout, options.heartbeat)
+ newClient, err := gxetcd.NewClient(options.Name, options.Endpoints, options.Timeout, options.Heartbeat)
if err != nil {
logger.Warnf("new etcd client (name{%s}, etcd addresses{%v}, timeout{%d}) = error{%v}",
- options.name, options.endpoints, options.timeout, err)
- return perrors.WithMessagef(err, "new client (address:%+v)", options.endpoints)
+ options.Name, options.Endpoints, options.Timeout, err)
+ return perrors.WithMessagef(err, "new client (address:%+v)", options.Endpoints)
}
container.SetClient(newClient)
}
// Client lose connection with etcd server
- if container.Client().rawClient == nil {
- newClient, err := NewClient(options.name, options.endpoints, options.timeout, options.heartbeat)
+ if container.Client().GetRawClient() == nil {
+ newClient, err := gxetcd.NewClient(options.Name, options.Endpoints, options.Timeout, options.Heartbeat)
if err != nil {
logger.Warnf("new etcd client (name{%s}, etcd addresses{%v}, timeout{%d}) = error{%v}",
- options.name, options.endpoints, options.timeout, err)
- return perrors.WithMessagef(err, "new client (address:%+v)", options.endpoints)
+ options.Name, options.Endpoints, options.Timeout, err)
+ return perrors.WithMessagef(err, "new client (address:%+v)", options.Endpoints)
}
container.SetClient(newClient)
}
@@ -130,368 +62,18 @@
}
// nolint
-func NewServiceDiscoveryClient(opts ...Option) *Client {
- options := &Options{
- heartbeat: 1, // default heartbeat
+func NewServiceDiscoveryClient(opts ...gxetcd.Option) *gxetcd.Client {
+ options := &gxetcd.Options{
+ Heartbeat: 1, // default heartbeat
}
for _, opt := range opts {
opt(options)
}
- newClient, err := NewClient(options.name, options.endpoints, options.timeout, options.heartbeat)
+ newClient, err := gxetcd.NewClient(options.Name, options.Endpoints, options.Timeout, options.Heartbeat)
if err != nil {
logger.Errorf("new etcd client (name{%s}, etcd addresses{%v}, timeout{%d}) = error{%v}",
- options.name, options.endpoints, options.timeout, err)
+ options.Name, options.Endpoints, options.Timeout, err)
}
return newClient
}
-
-// Client represents etcd client Configuration
-type Client struct {
- lock sync.RWMutex
-
- // these properties are only set once when they are started.
- name string
- endpoints []string
- timeout time.Duration
- heartbeat int
-
- ctx context.Context // if etcd server connection lose, the ctx.Done will be sent msg
- cancel context.CancelFunc // cancel the ctx, all watcher will stopped
- rawClient *clientv3.Client
-
- exit chan struct{}
- Wait sync.WaitGroup
-}
-
-// nolint
-func NewClient(name string, endpoints []string, timeout time.Duration, heartbeat int) (*Client, error) {
- ctx, cancel := context.WithCancel(context.Background())
- rawClient, err := clientv3.New(clientv3.Config{
- Context: ctx,
- Endpoints: endpoints,
- DialTimeout: timeout,
- DialOptions: []grpc.DialOption{grpc.WithBlock()},
- })
- if err != nil {
- return nil, perrors.WithMessage(err, "new raw client block connect to server")
- }
-
- c := &Client{
- name: name,
- timeout: timeout,
- endpoints: endpoints,
- heartbeat: heartbeat,
-
- ctx: ctx,
- cancel: cancel,
- rawClient: rawClient,
-
- exit: make(chan struct{}),
- }
-
- if err := c.maintenanceStatus(); err != nil {
- return nil, perrors.WithMessage(err, "client maintenance status")
- }
- return c, nil
-}
-
-// NOTICE: need to get the lock before calling this method
-func (c *Client) clean() {
- // close raw client
- c.rawClient.Close()
-
- // cancel ctx for raw client
- c.cancel()
-
- // clean raw client
- c.rawClient = nil
-}
-
-func (c *Client) stop() bool {
- select {
- case <-c.exit:
- return true
- default:
- close(c.exit)
- }
- return false
-}
-
-// nolint
-func (c *Client) Close() {
- if c == nil {
- return
- }
-
- // stop the client
- c.stop()
-
- // wait client maintenance status stop
- c.Wait.Wait()
-
- c.lock.Lock()
- defer c.lock.Unlock()
- if c.rawClient != nil {
- c.clean()
- }
- logger.Warnf("etcd client{name:%s, endpoints:%s} exit now.", c.name, c.endpoints)
-}
-
-func (c *Client) maintenanceStatus() error {
- s, err := concurrency.NewSession(c.rawClient, concurrency.WithTTL(c.heartbeat))
- if err != nil {
- return perrors.WithMessage(err, "new session with server")
- }
-
- // must add wg before go maintenance status goroutine
- c.Wait.Add(1)
- go c.maintenanceStatusLoop(s)
- return nil
-}
-
-func (c *Client) maintenanceStatusLoop(s *concurrency.Session) {
- defer func() {
- c.Wait.Done()
- logger.Infof("etcd client {endpoints:%v, name:%s} maintenance goroutine game over.", c.endpoints, c.name)
- }()
-
- for {
- select {
- case <-c.Done():
- // Client be stopped, will clean the client hold resources
- return
- case <-s.Done():
- logger.Warn("etcd server stopped")
- c.lock.Lock()
- // when etcd server stopped, cancel ctx, stop all watchers
- c.clean()
- // when connection lose, stop client, trigger reconnect to etcd
- c.stop()
- c.lock.Unlock()
- return
- }
- }
-}
-
-// if k not exist will put k/v in etcd, otherwise return nil
-func (c *Client) put(k string, v string, opts ...clientv3.OpOption) error {
- c.lock.RLock()
- defer c.lock.RUnlock()
-
- if c.rawClient == nil {
- return ErrNilETCDV3Client
- }
-
- _, err := c.rawClient.Txn(c.ctx).
- If(clientv3.Compare(clientv3.Version(k), "<", 1)).
- Then(clientv3.OpPut(k, v, opts...)).
- Commit()
- return err
-}
-
-// if k not exist will put k/v in etcd
-// if k is already exist in etcd, replace it
-func (c *Client) update(k string, v string, opts ...clientv3.OpOption) error {
- c.lock.RLock()
- defer c.lock.RUnlock()
-
- if c.rawClient == nil {
- return ErrNilETCDV3Client
- }
-
- _, err := c.rawClient.Txn(c.ctx).
- If(clientv3.Compare(clientv3.Version(k), "!=", -1)).
- Then(clientv3.OpPut(k, v, opts...)).
- Commit()
- return err
-}
-
-func (c *Client) delete(k string) error {
- c.lock.RLock()
- defer c.lock.RUnlock()
-
- if c.rawClient == nil {
- return ErrNilETCDV3Client
- }
-
- _, err := c.rawClient.Delete(c.ctx, k)
- return err
-}
-
-func (c *Client) get(k string) (string, error) {
- c.lock.RLock()
- defer c.lock.RUnlock()
-
- if c.rawClient == nil {
- return "", ErrNilETCDV3Client
- }
-
- resp, err := c.rawClient.Get(c.ctx, k)
- if err != nil {
- return "", err
- }
-
- if len(resp.Kvs) == 0 {
- return "", ErrKVPairNotFound
- }
-
- return string(resp.Kvs[0].Value), nil
-}
-
-// nolint
-func (c *Client) CleanKV() error {
- c.lock.RLock()
- defer c.lock.RUnlock()
-
- if c.rawClient == nil {
- return ErrNilETCDV3Client
- }
-
- _, err := c.rawClient.Delete(c.ctx, "", clientv3.WithPrefix())
- return err
-}
-
-func (c *Client) getChildren(k string) ([]string, []string, error) {
- c.lock.RLock()
- defer c.lock.RUnlock()
-
- if c.rawClient == nil {
- return nil, nil, ErrNilETCDV3Client
- }
-
- resp, err := c.rawClient.Get(c.ctx, k, clientv3.WithPrefix())
- if err != nil {
- return nil, nil, err
- }
-
- if len(resp.Kvs) == 0 {
- return nil, nil, ErrKVPairNotFound
- }
-
- kList := make([]string, 0, len(resp.Kvs))
- vList := make([]string, 0, len(resp.Kvs))
- for _, kv := range resp.Kvs {
- kList = append(kList, string(kv.Key))
- vList = append(vList, string(kv.Value))
- }
- return kList, vList, nil
-}
-
-func (c *Client) watchWithPrefix(prefix string) (clientv3.WatchChan, error) {
- c.lock.RLock()
- defer c.lock.RUnlock()
-
- if c.rawClient == nil {
- return nil, ErrNilETCDV3Client
- }
-
- return c.rawClient.Watch(c.ctx, prefix, clientv3.WithPrefix()), nil
-}
-
-func (c *Client) watch(k string) (clientv3.WatchChan, error) {
- c.lock.RLock()
- defer c.lock.RUnlock()
-
- if c.rawClient == nil {
- return nil, ErrNilETCDV3Client
- }
-
- return c.rawClient.Watch(c.ctx, k), nil
-}
-
-func (c *Client) keepAliveKV(k string, v string) error {
- c.lock.RLock()
- defer c.lock.RUnlock()
-
- if c.rawClient == nil {
- return ErrNilETCDV3Client
- }
-
- // make lease time longer, since 1 second is too short
- lease, err := c.rawClient.Grant(c.ctx, int64(30*time.Second.Seconds()))
- if err != nil {
- return perrors.WithMessage(err, "grant lease")
- }
-
- keepAlive, err := c.rawClient.KeepAlive(c.ctx, lease.ID)
- if err != nil || keepAlive == nil {
- if _, revokeErr := c.rawClient.Revoke(c.ctx, lease.ID); revokeErr != nil {
- logger.Warnf("rawClient.Revoke() = error:%v", revokeErr)
- }
- if err != nil {
- return perrors.WithMessage(err, "keep alive lease")
- } else {
- return perrors.New("keep alive lease")
- }
- }
-
- _, err = c.rawClient.Put(c.ctx, k, v, clientv3.WithLease(lease.ID))
- return perrors.WithMessage(err, "put k/v with lease")
-}
-
-// nolint
-func (c *Client) Done() <-chan struct{} {
- return c.exit
-}
-
-// nolint
-func (c *Client) Valid() bool {
- select {
- case <-c.exit:
- return false
- default:
- }
-
- c.lock.RLock()
- defer c.lock.RUnlock()
- return c.rawClient != nil
-}
-
-// nolint
-func (c *Client) Create(k string, v string) error {
- err := c.put(k, v)
- return perrors.WithMessagef(err, "put k/v (key: %s value %s)", k, v)
-}
-
-// Update key value ...
-func (c *Client) Update(k, v string) error {
- err := c.update(k, v)
- return perrors.WithMessagef(err, "Update k/v (key: %s value %s)", k, v)
-}
-
-// nolint
-func (c *Client) Delete(k string) error {
- err := c.delete(k)
- return perrors.WithMessagef(err, "delete k/v (key %s)", k)
-}
-
-// RegisterTemp registers a temporary node
-func (c *Client) RegisterTemp(k, v string) error {
- err := c.keepAliveKV(k, v)
- return perrors.WithMessagef(err, "keepalive kv (key %s)", k)
-}
-
-// GetChildrenKVList gets children kv list by @k
-func (c *Client) GetChildrenKVList(k string) ([]string, []string, error) {
- kList, vList, err := c.getChildren(k)
- return kList, vList, perrors.WithMessagef(err, "get key children (key %s)", k)
-}
-
-// Get gets value by @k
-func (c *Client) Get(k string) (string, error) {
- v, err := c.get(k)
- return v, perrors.WithMessagef(err, "get key value (key %s)", k)
-}
-
-// Watch watches on spec key
-func (c *Client) Watch(k string) (clientv3.WatchChan, error) {
- wc, err := c.watch(k)
- return wc, perrors.WithMessagef(err, "watch prefix (key %s)", k)
-}
-
-// WatchWithPrefix watches on spec prefix
-func (c *Client) WatchWithPrefix(prefix string) (clientv3.WatchChan, error) {
- wc, err := c.watchWithPrefix(prefix)
- return wc, perrors.WithMessagef(err, "watch prefix (key %s)", prefix)
-}
diff --git a/remoting/etcdv3/client_test.go b/remoting/etcdv3/client_test.go
deleted file mode 100644
index 787c24d..0000000
--- a/remoting/etcdv3/client_test.go
+++ /dev/null
@@ -1,411 +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 etcdv3
-
-import (
- "net/url"
- "os"
- "path"
- "reflect"
- "strings"
- "sync"
- "testing"
- "time"
-)
-
-import (
- "github.com/coreos/etcd/embed"
- "github.com/coreos/etcd/mvcc/mvccpb"
- perrors "github.com/pkg/errors"
- "github.com/stretchr/testify/assert"
- "github.com/stretchr/testify/suite"
- "google.golang.org/grpc/connectivity"
-)
-
-const defaultEtcdV3WorkDir = "/tmp/default-dubbo-go-remote.etcd"
-
-// tests dataset
-var tests = []struct {
- input struct {
- k string
- v string
- }
-}{
- {input: struct {
- k string
- v string
- }{k: "name", v: "scott.wang"}},
- {input: struct {
- k string
- v string
- }{k: "namePrefix", v: "prefix.scott.wang"}},
- {input: struct {
- k string
- v string
- }{k: "namePrefix1", v: "prefix1.scott.wang"}},
- {input: struct {
- k string
- v string
- }{k: "age", v: "27"}},
-}
-
-// test dataset prefix
-const prefix = "name"
-
-type ClientTestSuite struct {
- suite.Suite
-
- etcdConfig struct {
- name string
- endpoints []string
- timeout time.Duration
- heartbeat int
- }
-
- etcd *embed.Etcd
-
- client *Client
-}
-
-// start etcd server
-func (suite *ClientTestSuite) SetupSuite() {
-
- t := suite.T()
-
- DefaultListenPeerURLs := "http://localhost:2382"
- DefaultListenClientURLs := "http://localhost:2381"
- lpurl, _ := url.Parse(DefaultListenPeerURLs)
- lcurl, _ := url.Parse(DefaultListenClientURLs)
- cfg := embed.NewConfig()
- cfg.LPUrls = []url.URL{*lpurl}
- cfg.LCUrls = []url.URL{*lcurl}
- cfg.Dir = defaultEtcdV3WorkDir
- e, err := embed.StartEtcd(cfg)
- if err != nil {
- t.Fatal(err)
- }
- select {
- case <-e.Server.ReadyNotify():
- t.Log("Server is ready!")
- case <-time.After(60 * time.Second):
- e.Server.Stop() // trigger a shutdown
- t.Logf("Server took too long to start!")
- }
-
- suite.etcd = e
-}
-
-// stop etcd server
-func (suite *ClientTestSuite) TearDownSuite() {
- suite.etcd.Close()
- if err := os.RemoveAll(defaultEtcdV3WorkDir); err != nil {
- suite.FailNow(err.Error())
- }
-}
-
-func (suite *ClientTestSuite) setUpClient() *Client {
- c, err := NewClient(suite.etcdConfig.name,
- suite.etcdConfig.endpoints,
- suite.etcdConfig.timeout,
- suite.etcdConfig.heartbeat)
- if err != nil {
- suite.T().Fatal(err)
- }
- return c
-}
-
-// set up a client for suite
-func (suite *ClientTestSuite) SetupTest() {
- c := suite.setUpClient()
- err := c.CleanKV()
- suite.Nil(err)
- suite.client = c
-}
-
-func (suite *ClientTestSuite) TestClientClose() {
-
- c := suite.client
- t := suite.T()
-
- defer c.Close()
- if c.rawClient.ActiveConnection().GetState() != connectivity.Ready {
- t.Fatal(suite.client.rawClient.ActiveConnection().GetState())
- }
-}
-
-func (suite *ClientTestSuite) TestClientValid() {
-
- c := suite.client
- t := suite.T()
-
- if !c.Valid() {
- t.Fatal("client is not valid")
- }
- c.Close()
- if suite.client.Valid() != false {
- t.Fatal("client is valid")
- }
-}
-
-func (suite *ClientTestSuite) TestClientDone() {
-
- c := suite.client
-
- go func() {
- time.Sleep(2 * time.Second)
- c.Close()
- }()
-
- c.Wait.Wait()
-
- if c.Valid() {
- suite.T().Fatal("client should be invalid then")
- }
-}
-
-func (suite *ClientTestSuite) TestClientCreateKV() {
-
- tests := tests
-
- c := suite.client
- t := suite.T()
-
- defer suite.client.Close()
-
- for _, tc := range tests {
-
- k := tc.input.k
- v := tc.input.v
- expect := tc.input.v
-
- if err := c.Create(k, v); err != nil {
- t.Fatal(err)
- }
-
- value, err := c.Get(k)
- if err != nil {
- t.Fatal(err)
- }
-
- if value != expect {
- t.Fatalf("expect %v but get %v", expect, value)
- }
-
- }
-}
-
-func (suite *ClientTestSuite) TestClientDeleteKV() {
-
- tests := tests
- c := suite.client
- t := suite.T()
-
- defer c.Close()
-
- for _, tc := range tests {
-
- k := tc.input.k
- v := tc.input.v
- expect := ErrKVPairNotFound
-
- if err := c.Create(k, v); err != nil {
- t.Fatal(err)
- }
-
- if err := c.Delete(k); err != nil {
- t.Fatal(err)
- }
-
- _, err := c.Get(k)
- if perrors.Cause(err) == expect {
- continue
- }
-
- if err != nil {
- t.Fatal(err)
- }
- }
-
-}
-
-func (suite *ClientTestSuite) TestClientGetChildrenKVList() {
-
- tests := tests
-
- c := suite.client
- t := suite.T()
-
- var expectKList []string
- var expectVList []string
-
- for _, tc := range tests {
-
- k := tc.input.k
- v := tc.input.v
-
- if strings.Contains(k, prefix) {
- expectKList = append(expectKList, k)
- expectVList = append(expectVList, v)
- }
-
- if err := c.Create(k, v); err != nil {
- t.Fatal(err)
- }
- }
-
- kList, vList, err := c.GetChildrenKVList(prefix)
- if err != nil {
- t.Fatal(err)
- }
-
- if reflect.DeepEqual(expectKList, kList) && reflect.DeepEqual(expectVList, vList) {
- return
- }
-
- t.Fatalf("expect keylist %v but got %v expect valueList %v but got %v ", expectKList, kList, expectVList, vList)
-
-}
-
-func (suite *ClientTestSuite) TestClientWatch() {
-
- tests := tests
-
- c := suite.client
- t := suite.T()
-
- wg := sync.WaitGroup{}
- wg.Add(1)
-
- go func() {
-
- defer wg.Done()
-
- wc, err := c.watch(prefix)
- if err != nil {
- t.Error(err)
- }
-
- events := make([]mvccpb.Event, 0)
- var eCreate, eDelete mvccpb.Event
-
- for e := range wc {
-
- for _, event := range e.Events {
- events = append(events, (mvccpb.Event)(*event))
- if event.Type == mvccpb.PUT {
- eCreate = (mvccpb.Event)(*event)
- }
- if event.Type == mvccpb.DELETE {
- eDelete = (mvccpb.Event)(*event)
- }
- t.Logf("type IsCreate %v k %s v %s", event.IsCreate(), event.Kv.Key, event.Kv.Value)
- }
- }
-
- assert.Equal(t, 2, len(events))
- assert.Contains(t, events, eCreate)
- assert.Contains(t, events, eDelete)
- }()
-
- for _, tc := range tests {
-
- k := tc.input.k
- v := tc.input.v
-
- if err := c.Create(k, v); err != nil {
- t.Fatal(err)
- }
-
- if err := c.delete(k); err != nil {
- t.Fatal(err)
- }
- }
-
- c.Close()
-
- wg.Wait()
-
-}
-
-func (suite *ClientTestSuite) TestClientRegisterTemp() {
-
- c := suite.client
- observeC := suite.setUpClient()
- t := suite.T()
-
- wg := sync.WaitGroup{}
- wg.Add(1)
-
- go func() {
- defer wg.Done()
-
- completePath := path.Join("scott", "wang")
- wc, err := observeC.watch(completePath)
- if err != nil {
- t.Error(err)
- }
-
- events := make([]mvccpb.Event, 0)
- var eCreate, eDelete mvccpb.Event
-
- for e := range wc {
-
- for _, event := range e.Events {
- events = append(events, (mvccpb.Event)(*event))
- if event.Type == mvccpb.DELETE {
- eDelete = (mvccpb.Event)(*event)
- t.Logf("complete key (%s) is delete", completePath)
- observeC.Close()
- break
- }
- eCreate = (mvccpb.Event)(*event)
- t.Logf("type IsCreate %v k %s v %s", event.IsCreate(), event.Kv.Key, event.Kv.Value)
- }
- }
-
- assert.Equal(t, 2, len(events))
- assert.Contains(t, events, eCreate)
- assert.Contains(t, events, eDelete)
- }()
-
- err := c.RegisterTemp("scott/wang", "test")
- if err != nil {
- t.Fatal(err)
- }
-
- time.Sleep(2 * time.Second)
- c.Close()
-
- wg.Wait()
-}
-
-func TestClientSuite(t *testing.T) {
- suite.Run(t, &ClientTestSuite{
- etcdConfig: struct {
- name string
- endpoints []string
- timeout time.Duration
- heartbeat int
- }{
- name: "test",
- endpoints: []string{"localhost:2381"},
- timeout: time.Second,
- heartbeat: 1,
- },
- })
-}
diff --git a/remoting/etcdv3/facade.go b/remoting/etcdv3/facade.go
index 614ba9a..8bd1e3a 100644
--- a/remoting/etcdv3/facade.go
+++ b/remoting/etcdv3/facade.go
@@ -24,6 +24,7 @@
import (
"github.com/apache/dubbo-getty"
+ gxetcd "github.com/dubbogo/gost/database/kv/etcd/v3"
perrors "github.com/pkg/errors"
)
@@ -34,18 +35,17 @@
)
type clientFacade interface {
- Client() *Client
- SetClient(*Client)
+ Client() *gxetcd.Client
+ SetClient(client *gxetcd.Client)
ClientLock() *sync.Mutex
- WaitGroup() *sync.WaitGroup //for wait group control, etcd client listener & etcd client container
- Done() chan struct{} //for etcd client control
+ WaitGroup() *sync.WaitGroup // for wait group control, etcd client listener & etcd client container
+ Done() chan struct{} // for etcd client control
RestartCallBack() bool
common.Node
}
// HandleClientRestart keeps the connection between client and server
func HandleClientRestart(r clientFacade) {
-
var (
err error
failTimes int
@@ -61,9 +61,9 @@
// re-register all services
case <-r.Client().Done():
r.ClientLock().Lock()
- clientName := RegistryETCDV3Client
+ clientName := gxetcd.RegistryETCDV3Client
timeout, _ := time.ParseDuration(r.GetUrl().GetParam(constant.REGISTRY_TIMEOUT_KEY, constant.DEFAULT_REG_TIMEOUT))
- endpoints := r.Client().endpoints
+ endpoints := r.Client().GetEndPoints()
r.Client().Close()
r.SetClient(nil)
r.ClientLock().Unlock()
@@ -75,13 +75,14 @@
case <-r.Done():
logger.Warnf("(ETCDV3ProviderRegistry)reconnectETCDRegistry goroutine exit now...")
break LOOP
- case <-getty.GetTimeWheel().After(timeSecondDuration(failTimes * ConnDelay)): // avoid connect frequent
+ case <-getty.GetTimeWheel().After(timeSecondDuration(failTimes * gxetcd.ConnDelay)): // avoid connect frequent
}
err = ValidateClient(
r,
- WithName(clientName),
- WithEndpoints(endpoints...),
- WithTimeout(timeout),
+ gxetcd.WithName(clientName),
+ gxetcd.WithEndpoints(endpoints...),
+ gxetcd.WithTimeout(timeout),
+ gxetcd.WithHeartbeat(1),
)
logger.Infof("ETCDV3ProviderRegistry.validateETCDV3Client(etcd Addr{%s}) = error{%#v}",
endpoints, perrors.WithStack(err))
@@ -89,8 +90,8 @@
break
}
failTimes++
- if MaxFailTimes <= failTimes {
- failTimes = MaxFailTimes
+ if gxetcd.MaxFailTimes <= failTimes {
+ failTimes = gxetcd.MaxFailTimes
}
}
}
diff --git a/remoting/etcdv3/listener.go b/remoting/etcdv3/listener.go
index fd6f958..e4ae694 100644
--- a/remoting/etcdv3/listener.go
+++ b/remoting/etcdv3/listener.go
@@ -25,6 +25,7 @@
import (
"github.com/coreos/etcd/clientv3"
"github.com/coreos/etcd/mvcc/mvccpb"
+ gxetcd "github.com/dubbogo/gost/database/kv/etcd/v3"
perrors "github.com/pkg/errors"
)
@@ -35,14 +36,14 @@
// nolint
type EventListener struct {
- client *Client
+ client *gxetcd.Client
keyMapLock sync.RWMutex
keyMap map[string]struct{}
wg sync.WaitGroup
}
// NewEventListener returns a EventListener instance
-func NewEventListener(client *Client) *EventListener {
+func NewEventListener(client *gxetcd.Client) *EventListener {
return &EventListener{
client: client,
keyMap: make(map[string]struct{}),
@@ -69,7 +70,7 @@
return false
// client ctx stop
- case <-l.client.ctx.Done():
+ case <-l.client.GetCtx().Done():
logger.Warnf("etcd client ctx cancel")
return false
@@ -97,7 +98,6 @@
// return true means the event type is DELETE
// return false means the event type is CREATE || UPDATE
func (l *EventListener) handleEvents(event *clientv3.Event, listeners ...remoting.DataListener) bool {
-
logger.Infof("got a etcd event {type: %s, key: %s}", event.Type, event.Kv.Key)
switch event.Type {
@@ -148,7 +148,7 @@
return
// client ctx stop
- case <-l.client.ctx.Done():
+ case <-l.client.GetCtx().Done():
logger.Warnf("etcd client ctx cancel")
return
@@ -180,7 +180,6 @@
// |
// --------> listenServiceNodeEvent
func (l *EventListener) ListenServiceEvent(key string, listener remoting.DataListener) {
-
l.keyMapLock.RLock()
_, ok := l.keyMap[key]
l.keyMapLock.RUnlock()
@@ -193,7 +192,7 @@
l.keyMap[key] = struct{}{}
l.keyMapLock.Unlock()
- keyList, valueList, err := l.client.getChildren(key)
+ keyList, valueList, err := l.client.GetChildren(key)
if err != nil {
logger.Warnf("Get new node path {%v} 's content error,message is {%v}", key, perrors.WithMessage(err, "get children"))
}
diff --git a/remoting/etcdv3/listener_test.go b/remoting/etcdv3/listener_test.go
index 7da8581..6117123 100644
--- a/remoting/etcdv3/listener_test.go
+++ b/remoting/etcdv3/listener_test.go
@@ -18,10 +18,15 @@
package etcdv3
import (
+ "net/url"
+ "os"
+ "testing"
"time"
)
import (
+ "github.com/coreos/etcd/embed"
+ gxetcd "github.com/dubbogo/gost/database/kv/etcd/v3"
"github.com/stretchr/testify/assert"
)
@@ -29,6 +34,8 @@
"github.com/apache/dubbo-go/remoting"
)
+const defaultEtcdV3WorkDir = "/tmp/default-dubbo-go-remote.etcd"
+
var changedData = `
dubbo.consumer.request_timeout=3s
dubbo.consumer.connect_timeout=5s
@@ -51,9 +58,41 @@
dubbo.service.com.ikurento.user.UserProvider.cluster=failover
`
-func (suite *ClientTestSuite) TestListener() {
+var etcd *embed.Etcd
- var tests = []struct {
+func SetUpEtcdServer(t *testing.T) {
+ var err error
+ DefaultListenPeerURLs := "http://localhost:2382"
+ DefaultListenClientURLs := "http://localhost:2381"
+ lpurl, _ := url.Parse(DefaultListenPeerURLs)
+ lcurl, _ := url.Parse(DefaultListenClientURLs)
+ cfg := embed.NewConfig()
+ cfg.LPUrls = []url.URL{*lpurl}
+ cfg.LCUrls = []url.URL{*lcurl}
+ cfg.Dir = defaultEtcdV3WorkDir
+ etcd, err = embed.StartEtcd(cfg)
+ if err != nil {
+ t.Fatal(err)
+ }
+ select {
+ case <-etcd.Server.ReadyNotify():
+ t.Log("Server is ready!")
+ case <-time.After(60 * time.Second):
+ etcd.Server.Stop() // trigger a shutdown
+ t.Logf("Server took too long to start!")
+ }
+}
+
+func ClearEtcdServer(t *testing.T) {
+ etcd.Close()
+ if err := os.RemoveAll(defaultEtcdV3WorkDir); err != nil {
+ t.Fail()
+ }
+}
+
+func TestListener(t *testing.T) {
+
+ tests := []struct {
input struct {
k string
v string
@@ -64,9 +103,9 @@
v string
}{k: "/dubbo", v: changedData}},
}
-
- c := suite.client
- t := suite.T()
+ SetUpEtcdServer(t)
+ c, err := gxetcd.NewClient("test", []string{"localhost:2381"}, time.Second, 1)
+ assert.NoError(t, err)
listener := NewEventListener(c)
dataListener := &mockDataListener{client: c, changedData: changedData, rc: make(chan remoting.Event)}
@@ -85,11 +124,12 @@
}
msg := <-dataListener.rc
assert.Equal(t, changedData, msg.Content)
+ ClearEtcdServer(t)
}
type mockDataListener struct {
eventList []remoting.Event
- client *Client
+ client *gxetcd.Client
changedData string
rc chan remoting.Event
diff --git a/remoting/exchange.go b/remoting/exchange.go
index ad136a7..07dc549 100644
--- a/remoting/exchange.go
+++ b/remoting/exchange.go
@@ -119,7 +119,7 @@
ConnectTimeout time.Duration
}
-//AsyncCallbackResponse async response for dubbo
+// AsyncCallbackResponse async response for dubbo
type AsyncCallbackResponse struct {
common.CallbackResponse
Opts Options
diff --git a/remoting/exchange_client.go b/remoting/exchange_client.go
index d653820..4770285 100644
--- a/remoting/exchange_client.go
+++ b/remoting/exchange_client.go
@@ -22,6 +22,10 @@
)
import (
+ uatomic "go.uber.org/atomic"
+)
+
+import (
"github.com/apache/dubbo-go/common"
"github.com/apache/dubbo-go/common/logger"
"github.com/apache/dubbo-go/protocol"
@@ -51,6 +55,8 @@
client Client
// the tag for init.
init bool
+ // the number of service using the exchangeClient
+ activeNum uatomic.Uint32
}
// create ExchangeClient
@@ -66,7 +72,7 @@
return nil
}
}
-
+ exchangeClient.IncreaseActiveNumber()
return exchangeClient
}
@@ -75,18 +81,33 @@
return nil
}
if cl.client.Connect(url) != nil {
- //retry for a while
+ // retry for a while
time.Sleep(100 * time.Millisecond)
if cl.client.Connect(url) != nil {
logger.Errorf("Failed to connect server %+v " + url.Location)
return errors.New("Failed to connect server " + url.Location)
}
}
- //FIXME atomic operation
+ // FIXME atomic operation
cl.init = true
return nil
}
+// increase number of service using client
+func (client *ExchangeClient) IncreaseActiveNumber() uint32 {
+ return client.activeNum.Add(1)
+}
+
+// decrease number of service using client
+func (client *ExchangeClient) DecreaseActiveNumber() uint32 {
+ return client.activeNum.Sub(1)
+}
+
+// get number of service using client
+func (client *ExchangeClient) GetActiveNumber() uint32 {
+ return client.activeNum.Load()
+}
+
// two way request
func (client *ExchangeClient) Request(invocation *protocol.Invocation, url *common.URL, timeout time.Duration,
result *protocol.RPCResult) error {
diff --git a/remoting/exchange_server.go b/remoting/exchange_server.go
index a8d7c73..41abe21 100644
--- a/remoting/exchange_server.go
+++ b/remoting/exchange_server.go
@@ -23,9 +23,9 @@
// It is interface of server for network communication.
// If you use getty as network communication, you should define GettyServer that implements this interface.
type Server interface {
- //invoke once for connection
+ // invoke once for connection
Start()
- //it is for destroy
+ // it is for destroy
Stop()
}
diff --git a/remoting/getty/config.go b/remoting/getty/config.go
index b6aa082..725aa94 100644
--- a/remoting/getty/config.go
+++ b/remoting/getty/config.go
@@ -134,7 +134,8 @@
WaitTimeout: "1s",
MaxMsgLen: 102400,
SessionName: "client",
- }}
+ },
+ }
}
// GetDefaultServerConfig gets server default configuration
diff --git a/remoting/getty/dubbo_codec_for_test.go b/remoting/getty/dubbo_codec_for_test.go
index 9afc18a..d227eca 100644
--- a/remoting/getty/dubbo_codec_for_test.go
+++ b/remoting/getty/dubbo_codec_for_test.go
@@ -42,8 +42,7 @@
remoting.RegistryCodec("dubbo", codec)
}
-type DubboTestCodec struct {
-}
+type DubboTestCodec struct{}
// encode request for transport
func (c *DubboTestCodec) EncodeRequest(request *remoting.Request) (*bytes.Buffer, error) {
@@ -123,7 +122,7 @@
// encode response
func (c *DubboTestCodec) EncodeResponse(response *remoting.Response) (*bytes.Buffer, error) {
- var ptype = impl.PackageResponse
+ ptype := impl.PackageResponse
if response.IsHeartbeat() {
ptype = impl.PackageHeartbeat
}
@@ -184,7 +183,7 @@
if err != nil {
originErr := perrors.Cause(err)
if originErr == hessian.ErrHeaderNotEnough || originErr == hessian.ErrBodyNotEnough {
- //FIXME
+ // FIXME
return nil, 0, originErr
}
return request, 0, perrors.WithStack(err)
@@ -199,19 +198,19 @@
// convert params of request
req := pkg.Body.(map[string]interface{})
- //invocation := request.Data.(*invocation.RPCInvocation)
+ // invocation := request.Data.(*invocation.RPCInvocation)
var methodName string
var args []interface{}
attachments := make(map[string]interface{})
if req[impl.DubboVersionKey] != nil {
- //dubbo version
+ // dubbo version
request.Version = req[impl.DubboVersionKey].(string)
}
- //path
+ // path
attachments[constant.PATH_KEY] = pkg.Service.Path
- //version
+ // version
attachments[constant.VERSION_KEY] = pkg.Service.Version
- //method
+ // method
methodName = pkg.Service.Method
args = req[impl.ArgsKey].([]interface{})
attachments = req[impl.AttachmentsKey].(map[string]interface{})
@@ -238,7 +237,7 @@
}
response := &remoting.Response{
ID: pkg.Header.ID,
- //Version: pkg.Header.,
+ // Version: pkg.Header.,
SerialID: pkg.Header.SerialID,
Status: pkg.Header.ResponseStatus,
Event: (pkg.Header.Type & impl.PackageHeartbeat) != 0,
@@ -251,7 +250,7 @@
}
} else {
response.Status = hessian.Response_OK
- //reply(session, p, hessian.PackageHeartbeat)
+ // reply(session, p, hessian.PackageHeartbeat)
}
return response, hessian.HEADER_LENGTH + pkg.Header.BodyLen, error
}
diff --git a/remoting/getty/getty_client_test.go b/remoting/getty/getty_client_test.go
index c32e0c2..3b59e9c 100644
--- a/remoting/getty/getty_client_test.go
+++ b/remoting/getty/getty_client_test.go
@@ -52,7 +52,6 @@
}
func testRequestOneWay(t *testing.T, svr *Server, url *common.URL, client *Client) {
-
request := remoting.NewRequest("2.0.2")
up := &UserProvider{}
invocation := createInvocation("GetUser", nil, nil, []interface{}{[]interface{}{"1", "username"}, up},
@@ -62,7 +61,7 @@
request.Data = invocation
request.Event = false
request.TwoWay = false
- //user := &User{}
+ // user := &User{}
err := client.Request(request, 3*time.Second, nil)
assert.NoError(t, err)
}
@@ -169,9 +168,7 @@
}
func testGetUser1(t *testing.T, c *Client) {
- var (
- err error
- )
+ var err error
request := remoting.NewRequest("2.0.2")
invocation := createInvocation("GetUser1", nil, nil, []interface{}{},
[]reflect.Value{})
@@ -189,9 +186,7 @@
}
func testGetUser2(t *testing.T, c *Client) {
- var (
- err error
- )
+ var err error
request := remoting.NewRequest("2.0.2")
invocation := createInvocation("GetUser2", nil, nil, []interface{}{},
[]reflect.Value{})
@@ -207,9 +202,7 @@
}
func testGetUser3(t *testing.T, c *Client) {
- var (
- err error
- )
+ var err error
request := remoting.NewRequest("2.0.2")
invocation := createInvocation("GetUser3", nil, nil, []interface{}{},
[]reflect.Value{})
@@ -230,9 +223,7 @@
}
func testGetUser4(t *testing.T, c *Client) {
- var (
- err error
- )
+ var err error
request := remoting.NewRequest("2.0.2")
invocation := invocation.NewRPCInvocation("GetUser4", []interface{}{[]interface{}{"1", "username"}}, nil)
attachment := map[string]string{INTERFACE_KEY: "com.ikurento.user.UserProvider"}
@@ -250,9 +241,7 @@
}
func testGetUser5(t *testing.T, c *Client) {
- var (
- err error
- )
+ var err error
request := remoting.NewRequest("2.0.2")
invocation := invocation.NewRPCInvocation("GetUser5", []interface{}{map[interface{}]interface{}{"id": "1", "name": "username"}}, nil)
attachment := map[string]string{INTERFACE_KEY: "com.ikurento.user.UserProvider"}
@@ -341,7 +330,6 @@
}
func InitTest(t *testing.T) (*Server, *common.URL) {
-
hessian.RegisterPOJO(&User{})
remoting.RegistryCodec("dubbo", &DubboTestCodec{})
@@ -388,7 +376,8 @@
WaitTimeout: "1s",
MaxMsgLen: 10240000000,
SessionName: "server",
- }})
+ },
+ })
assert.NoError(t, srvConf.CheckValidity())
url, err := common.NewURL("dubbo://127.0.0.1:20060/com.ikurento.user.UserProvider?anyhost=true&" +
@@ -405,7 +394,7 @@
BaseInvoker: *protocol.NewBaseInvoker(url),
}
handler := func(invocation *invocation.RPCInvocation) protocol.RPCResult {
- //result := protocol.RPCResult{}
+ // result := protocol.RPCResult{}
r := invoker.Invoke(context.Background(), invocation)
result := protocol.RPCResult{
Err: r.Error(),
@@ -432,8 +421,7 @@
Name string `json:"name"`
}
- UserProvider struct {
- //user map[string]User
+ UserProvider struct { // user map[string]User
}
)
@@ -473,7 +461,6 @@
}
func (u *UserProvider) GetUser4(ctx context.Context, req []interface{}) ([]interface{}, error) {
-
return []interface{}{User{Id: req[0].([]interface{})[0].(string), Name: req[0].([]interface{})[1].(string)}}, nil
}
diff --git a/remoting/getty/getty_server.go b/remoting/getty/getty_server.go
index 4930a6a..76eb478 100644
--- a/remoting/getty/getty_server.go
+++ b/remoting/getty/getty_server.go
@@ -40,9 +40,7 @@
"github.com/apache/dubbo-go/remoting"
)
-var (
- srvConf *ServerConfig
-)
+var srvConf *ServerConfig
func initServer(protocol string) {
// load clientconfig from provider_config
@@ -104,7 +102,7 @@
// NewServer create a new Server
func NewServer(url *common.URL, handlers func(*invocation.RPCInvocation) protocol.RPCResult) *Server {
- //init
+ // init
initServer(url.Protocol)
srvConf.SSLEnabled = url.GetParamBool(constant.SSL_ENABLED_KEY, false)
diff --git a/remoting/getty/listener.go b/remoting/getty/listener.go
index 5443d37..96df02b 100644
--- a/remoting/getty/listener.go
+++ b/remoting/getty/listener.go
@@ -289,7 +289,6 @@
}
reply(session, resp)
}
-
}()
invoc, ok := req.Data.(*invocation.RPCInvocation)
diff --git a/remoting/getty/opentracing.go b/remoting/getty/opentracing.go
index 4ba4fde..ab74c85 100644
--- a/remoting/getty/opentracing.go
+++ b/remoting/getty/opentracing.go
@@ -20,6 +20,7 @@
import (
"github.com/opentracing/opentracing-go"
)
+
import (
invocation_impl "github.com/apache/dubbo-go/protocol/invocation"
)
@@ -36,7 +37,7 @@
}
func filterContext(attachments map[string]interface{}) map[string]string {
- var traceAttchment = make(map[string]string)
+ traceAttchment := make(map[string]string)
for k, v := range attachments {
if r, ok := v.(string); ok {
traceAttchment[k] = r
diff --git a/remoting/getty/pool.go b/remoting/getty/pool.go
index 2b1cdfe..7e8cb13 100644
--- a/remoting/getty/pool.go
+++ b/remoting/getty/pool.go
@@ -39,7 +39,7 @@
type gettyRPCClient struct {
once sync.Once
- //protocol string
+ // protocol string
addr string
active int64 // zero, not create or be destroyed
@@ -50,9 +50,7 @@
sessions []*rpcSession
}
-var (
- errClientPoolClosed = perrors.New("client pool closed")
-)
+var errClientPoolClosed = perrors.New("client pool closed")
func newGettyRPCClientConn(pool *gettyRPCClientPool, addr string) (*gettyRPCClient, error) {
var (
@@ -384,7 +382,7 @@
conn = p.conns[0]
}
// This will recreate gettyRpcClient for remove last position
- //p.conns = p.conns[:len(p.conns)-1]
+ // p.conns = p.conns[:len(p.conns)-1]
if d := now - conn.getActive(); d > p.ttl {
p.remove(conn)
@@ -392,7 +390,7 @@
num = len(p.conns)
continue
}
- conn.updateActive(now) //update active time
+ conn.updateActive(now) // update active time
return conn, nil
}
return nil, nil
diff --git a/remoting/getty/readwriter.go b/remoting/getty/readwriter.go
index 072eb3e..c04437a 100644
--- a/remoting/getty/readwriter.go
+++ b/remoting/getty/readwriter.go
@@ -18,6 +18,7 @@
package getty
import (
+ "errors"
"reflect"
)
@@ -50,10 +51,9 @@
// and send to client each time. the Read can assemble it.
func (p *RpcClientPackageHandler) Read(ss getty.Session, data []byte) (interface{}, int, error) {
resp, length, err := (p.client.codec).Decode(data)
- //err := pkg.Unmarshal(buf, p.client)
+ // err := pkg.Unmarshal(buf, p.client)
if err != nil {
- err = perrors.Cause(err)
- if err == hessian.ErrHeaderNotEnough || err == hessian.ErrBodyNotEnough {
+ if errors.Is(err, hessian.ErrHeaderNotEnough) || errors.Is(err, hessian.ErrBodyNotEnough) {
return nil, 0, nil
}
@@ -112,9 +112,9 @@
// and send to client each time. the Read can assemble it.
func (p *RpcServerPackageHandler) Read(ss getty.Session, data []byte) (interface{}, int, error) {
req, length, err := (p.server.codec).Decode(data)
- //resp,len, err := (*p.).DecodeResponse(buf)
+ // resp,len, err := (*p.).DecodeResponse(buf)
if err != nil {
- if err == hessian.ErrHeaderNotEnough || err == hessian.ErrBodyNotEnough {
+ if errors.Is(err, hessian.ErrHeaderNotEnough) || errors.Is(err, hessian.ErrBodyNotEnough) {
return nil, 0, nil
}
@@ -150,5 +150,4 @@
logger.Errorf("illegal pkg:%+v\n, it is %+v", pkg, reflect.TypeOf(pkg))
return nil, perrors.New("invalid rpc response")
-
}
diff --git a/remoting/getty/readwriter_test.go b/remoting/getty/readwriter_test.go
new file mode 100644
index 0000000..db6dd8e
--- /dev/null
+++ b/remoting/getty/readwriter_test.go
@@ -0,0 +1,173 @@
+/*
+ * 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 getty
+
+import (
+ "context"
+ "reflect"
+ "testing"
+ "time"
+)
+
+import (
+ hessian "github.com/apache/dubbo-go-hessian2"
+ "github.com/stretchr/testify/assert"
+)
+
+import (
+ "github.com/apache/dubbo-go/common"
+ "github.com/apache/dubbo-go/common/constant"
+ "github.com/apache/dubbo-go/common/proxy/proxy_factory"
+ "github.com/apache/dubbo-go/protocol"
+ "github.com/apache/dubbo-go/protocol/dubbo/impl"
+ "github.com/apache/dubbo-go/protocol/invocation"
+ "github.com/apache/dubbo-go/remoting"
+)
+
+func TestTCPPackageHandle(t *testing.T) {
+ svr, url := getServer(t)
+ client := getClient(url)
+ testDecodeTCPPackage(t, svr, client)
+ svr.Stop()
+}
+
+func testDecodeTCPPackage(t *testing.T, svr *Server, client *Client) {
+ request := remoting.NewRequest("2.0.2")
+ ap := &AdminProvider{}
+ rpcInvocation := createInvocation("GetAdmin", nil, nil, []interface{}{[]interface{}{"1", "username"}},
+ []reflect.Value{reflect.ValueOf([]interface{}{"1", "username"}), reflect.ValueOf(ap)})
+ attachment := map[string]string{
+ constant.INTERFACE_KEY: "com.ikurento.user.AdminProvider",
+ constant.PATH_KEY: "AdminProvider",
+ constant.VERSION_KEY: "1.0.0",
+ }
+ setAttachment(rpcInvocation, attachment)
+ request.Data = rpcInvocation
+ request.Event = false
+ request.TwoWay = false
+
+ pkgWriteHandler := NewRpcClientPackageHandler(client)
+ pkgBytes, err := pkgWriteHandler.Write(nil, request)
+ assert.NoError(t, err)
+ pkgReadHandler := NewRpcServerPackageHandler(svr)
+ _, pkgLen, err := pkgReadHandler.Read(nil, pkgBytes)
+ assert.NoError(t, err)
+ assert.Equal(t, pkgLen, len(pkgBytes))
+
+ // simulate incomplete tcp package
+ incompletePkgLen := len(pkgBytes) - 10
+ assert.True(t, incompletePkgLen >= impl.HEADER_LENGTH, "header buffer too short")
+ incompletePkg := pkgBytes[0 : incompletePkgLen-1]
+ pkg, pkgLen, err := pkgReadHandler.Read(nil, incompletePkg)
+ assert.NoError(t, err)
+ assert.Equal(t, pkg, nil)
+ assert.Equal(t, pkgLen, 0)
+}
+
+func getServer(t *testing.T) (*Server, *common.URL) {
+ hessian.RegisterPOJO(&User{})
+ remoting.RegistryCodec("dubbo", &DubboTestCodec{})
+
+ methods, err := common.ServiceMap.Register("com.ikurento.user.AdminProvider", "dubbo", "", "", &AdminProvider{})
+ assert.NoError(t, err)
+ assert.Equal(t, "GetAdmin", methods)
+
+ // config
+ SetClientConf(ClientConfig{
+ ConnectionNum: 2,
+ HeartbeatPeriod: "5s",
+ SessionTimeout: "20s",
+ PoolTTL: 600,
+ PoolSize: 64,
+ GettySessionParam: GettySessionParam{
+ CompressEncoding: false,
+ TcpNoDelay: true,
+ TcpKeepAlive: true,
+ KeepAlivePeriod: "120s",
+ TcpRBufSize: 262144,
+ TcpWBufSize: 65536,
+ PkgWQSize: 512,
+ TcpReadTimeout: "4s",
+ TcpWriteTimeout: "5s",
+ WaitTimeout: "1s",
+ MaxMsgLen: 10240000000,
+ SessionName: "client",
+ },
+ })
+ assert.NoError(t, clientConf.CheckValidity())
+ SetServerConfig(ServerConfig{
+ SessionNumber: 700,
+ SessionTimeout: "20s",
+ GettySessionParam: GettySessionParam{
+ CompressEncoding: false,
+ TcpNoDelay: true,
+ TcpKeepAlive: true,
+ KeepAlivePeriod: "120s",
+ TcpRBufSize: 262144,
+ TcpWBufSize: 65536,
+ PkgWQSize: 512,
+ TcpReadTimeout: "1s",
+ TcpWriteTimeout: "5s",
+ WaitTimeout: "1s",
+ MaxMsgLen: 10240000000,
+ SessionName: "server",
+ },
+ })
+ assert.NoError(t, srvConf.CheckValidity())
+
+ url, err := common.NewURL("dubbo://127.0.0.1:20061/com.ikurento.user.AdminProvider?anyhost=true&" +
+ "application=BDTService&category=providers&default.timeout=10000&dubbo=dubbo-provider-golang-1.0.0&" +
+ "environment=dev&interface=com.ikurento.user.AdminProvider&ip=127.0.0.1&methods=GetAdmin%2C&" +
+ "module=dubbogo+user-info+server&org=ikurento.com&owner=ZX&pid=1447&revision=0.0.1&" +
+ "side=provider&timeout=3000×tamp=1556509797245&bean.name=AdminProvider")
+ assert.NoError(t, err)
+ // init server
+ adminProvider := &AdminProvider{}
+ _, err = common.ServiceMap.Register("com.ikurento.user.AdminProvider", url.Protocol, "", "0.0.1", adminProvider)
+ assert.NoError(t, err)
+ invoker := &proxy_factory.ProxyInvoker{
+ BaseInvoker: *protocol.NewBaseInvoker(url),
+ }
+ handler := func(invocation *invocation.RPCInvocation) protocol.RPCResult {
+ // result := protocol.RPCResult{}
+ r := invoker.Invoke(context.Background(), invocation)
+ result := protocol.RPCResult{
+ Err: r.Error(),
+ Rest: r.Result(),
+ Attrs: r.Attachments(),
+ }
+ return result
+ }
+ server := NewServer(url, handler)
+ server.Start()
+
+ time.Sleep(time.Second * 2)
+
+ return server, url
+}
+
+type AdminProvider struct{}
+
+func (a *AdminProvider) GetAdmin(ctx context.Context, req []interface{}, rsp *User) error {
+ rsp.Id = req[0].(string)
+ rsp.Name = req[1].(string)
+ return nil
+}
+
+func (a *AdminProvider) Reference() string {
+ return "AdminProvider"
+}
diff --git a/remoting/kubernetes/client.go b/remoting/kubernetes/client.go
index ce6bccc..aabbc00 100644
--- a/remoting/kubernetes/client.go
+++ b/remoting/kubernetes/client.go
@@ -76,7 +76,6 @@
// Create creates k/v pair in watcher-set
func (c *Client) Create(k, v string) error {
-
// the read current pod must be lock, protect every
// create operation can be atomic
c.lock.Lock()
@@ -92,7 +91,6 @@
// GetChildren gets k children list from kubernetes-watcherSet
func (c *Client) GetChildren(k string) ([]string, []string, error) {
-
objectList, err := c.controller.watcherSet.Get(k, true)
if err != nil {
return nil, nil, perrors.WithMessagef(err, "get children from watcherSet on (%s)", k)
@@ -111,7 +109,6 @@
// Watch watches on spec key
func (c *Client) Watch(k string) (<-chan *WatcherEvent, <-chan struct{}, error) {
-
w, err := c.controller.watcherSet.Watch(k, false)
if err != nil {
return nil, nil, perrors.WithMessagef(err, "watch on (%s)", k)
@@ -122,7 +119,6 @@
// WatchWithPrefix watches on spec prefix
func (c *Client) WatchWithPrefix(prefix string) (<-chan *WatcherEvent, <-chan struct{}, error) {
-
w, err := c.controller.watcherSet.Watch(prefix, true)
if err != nil {
return nil, nil, perrors.WithMessagef(err, "watch on prefix (%s)", prefix)
@@ -133,7 +129,6 @@
// if returns false, the client is die
func (c *Client) Valid() bool {
-
select {
case <-c.Done():
return false
@@ -151,10 +146,9 @@
// nolint
func (c *Client) Close() {
-
select {
case <-c.ctx.Done():
- //already stopped
+ // already stopped
return
default:
}
@@ -167,7 +161,6 @@
// ValidateClient validates the kubernetes client
func ValidateClient(container clientFacade) error {
-
client := container.Client()
// new Client
diff --git a/remoting/kubernetes/client_test.go b/remoting/kubernetes/client_test.go
index 9cc4212..be72561 100644
--- a/remoting/kubernetes/client_test.go
+++ b/remoting/kubernetes/client_test.go
@@ -59,9 +59,8 @@
// test dataset prefix
const prefix = "name"
-var (
- watcherStopLog = "the watcherSet watcher was stopped"
-)
+var watcherStopLog = "the watcherSet watcher was stopped"
+
var clientPodListJsonData = `{
"apiVersion": "v1",
"items": [
@@ -228,7 +227,6 @@
`
func getTestClient(t *testing.T) *Client {
-
pl := &v1.PodList{}
// 1. install test data
if err := json.Unmarshal([]byte(clientPodListJsonData), &pl); err != nil {
@@ -257,7 +255,6 @@
}
func TestClientValid(t *testing.T) {
-
client := getTestClient(t)
defer client.Close()
@@ -272,7 +269,6 @@
}
func TestClientDone(t *testing.T) {
-
client := getTestClient(t)
go func() {
@@ -287,7 +283,6 @@
}
func TestClientCreateKV(t *testing.T) {
-
client := getTestClient(t)
defer client.Close()
@@ -304,7 +299,6 @@
}
func TestClientGetChildrenKVList(t *testing.T) {
-
client := getTestClient(t)
defer client.Close()
@@ -314,7 +308,6 @@
syncDataComplete := make(chan struct{})
go func() {
-
wc, done, err := client.WatchWithPrefix(prefix)
if err != nil {
t.Error(err)
@@ -374,23 +367,19 @@
}
for expectK, expectV := range expect {
-
if got[expectK] != expectV {
t.Fatalf("expect {%s: %s} but got {%s: %v}", expectK, expectV, expectK, got[expectK])
}
}
-
}
func TestClientWatchPrefix(t *testing.T) {
-
client := getTestClient(t)
wg := sync.WaitGroup{}
wg.Add(1)
go func() {
-
wc, done, err := client.WatchWithPrefix(prefix)
if err != nil {
t.Error(err)
@@ -426,14 +415,12 @@
}
func TestClientWatch(t *testing.T) {
-
client := getTestClient(t)
wg := sync.WaitGroup{}
wg.Add(1)
go func() {
-
wc, done, err := client.Watch(prefix)
if err != nil {
t.Error(err)
@@ -449,7 +436,6 @@
return
}
}
-
}()
// must wait the watch goroutine already start the watch goroutine
diff --git a/remoting/kubernetes/facade_test.go b/remoting/kubernetes/facade_test.go
index a6c6c02..d0d710c 100644
--- a/remoting/kubernetes/facade_test.go
+++ b/remoting/kubernetes/facade_test.go
@@ -30,8 +30,8 @@
type mockFacade struct {
*common.URL
client *Client
- //cltLock sync.Mutex
- //done chan struct{}
+ // cltLock sync.Mutex
+ // done chan struct{}
}
func (r *mockFacade) Client() *Client {
@@ -57,8 +57,8 @@
func (r *mockFacade) IsAvailable() bool {
return true
}
-func Test_Facade(t *testing.T) {
+func Test_Facade(t *testing.T) {
regUrl, err := common.NewURL("registry://127.0.0.1:443",
common.WithParamsValue(constant.ROLE_KEY, strconv.Itoa(common.CONSUMER)))
if err != nil {
diff --git a/remoting/kubernetes/listener.go b/remoting/kubernetes/listener.go
index a737f4e..2c4149b 100644
--- a/remoting/kubernetes/listener.go
+++ b/remoting/kubernetes/listener.go
@@ -86,7 +86,6 @@
// return true means the event type is DELETE
// return false means the event type is CREATE || UPDATE
func (l *EventListener) handleEvents(event *WatcherEvent, listeners ...remoting.DataListener) bool {
-
logger.Infof("got a kubernetes-watcherSet event {type: %d, key: %s}", event.EventType, event.Key)
switch event.EventType {
@@ -120,7 +119,6 @@
// Listen on a set of key with spec prefix
func (l *EventListener) ListenServiceNodeEventWithPrefix(prefix string, listener ...remoting.DataListener) {
-
defer l.wg.Done()
for {
wc, done, err := l.client.WatchWithPrefix(prefix)
@@ -157,7 +155,6 @@
// |
// --------> ListenServiceNodeEvent
func (l *EventListener) ListenServiceEvent(key string, listener remoting.DataListener) {
-
l.keyMapLock.RLock()
_, ok := l.keyMap[key]
l.keyMapLock.RUnlock()
diff --git a/remoting/kubernetes/listener_test.go b/remoting/kubernetes/listener_test.go
index 0b05b6e..4701b5d 100644
--- a/remoting/kubernetes/listener_test.go
+++ b/remoting/kubernetes/listener_test.go
@@ -69,8 +69,7 @@
}
func TestListener(t *testing.T) {
-
- var tests = []struct {
+ tests := []struct {
input struct {
k string
v string
diff --git a/remoting/kubernetes/registry_controller.go b/remoting/kubernetes/registry_controller.go
index f66163d..212549a 100644
--- a/remoting/kubernetes/registry_controller.go
+++ b/remoting/kubernetes/registry_controller.go
@@ -68,9 +68,7 @@
defaultResync = 5 * time.Minute
)
-var (
- ErrDubboLabelAlreadyExist = perrors.New("dubbo label already exist")
-)
+var ErrDubboLabelAlreadyExist = perrors.New("dubbo label already exist")
// dubboRegistryController works like a kubernetes controller
type dubboRegistryController struct {
@@ -96,7 +94,7 @@
listAndWatchStartResourceVersion uint64
namespacedInformerFactory map[string]informers.SharedInformerFactory
namespacedPodInformers map[string]informerscorev1.PodInformer
- queue workqueue.Interface //shared by namespaced informers
+ queue workqueue.Interface // shared by namespaced informers
}
func newDubboRegistryController(
@@ -146,7 +144,6 @@
// GetInClusterKubernetesClient
// current pod running in kubernetes-cluster
func GetInClusterKubernetesClient() (kubernetes.Interface, error) {
-
// read in-cluster config
cfg, err := rest.InClusterConfig()
if err != nil {
@@ -161,7 +158,6 @@
// 2. put every element to watcherSet
// 3. refresh watch book-mark
func (c *dubboRegistryController) initWatchSet() error {
-
req, err := labels.NewRequirement(DubboIOLabelKey, selection.In, []string{DubboIOConsumerLabelValue, DubboIOProviderLabelValue})
if err != nil {
return perrors.WithMessage(err, "new requirement")
@@ -193,7 +189,6 @@
// 1. current pod name
// 2. current pod working namespace
func (c *dubboRegistryController) readConfig() error {
-
// read current pod name && namespace
c.name = os.Getenv(podNameKey)
if len(c.name) == 0 {
@@ -207,7 +202,6 @@
}
func (c *dubboRegistryController) initNamespacedPodInformer(ns string) error {
-
req, err := labels.NewRequirement(DubboIOLabelKey, selection.In, []string{DubboIOConsumerLabelValue, DubboIOProviderLabelValue})
if err != nil {
return perrors.WithMessage(err, "new requirement")
@@ -237,7 +231,6 @@
}
func (c *dubboRegistryController) initPodInformer() error {
-
if c.role == common.PROVIDER {
return nil
}
@@ -323,7 +316,6 @@
// run
// controller process every event in work-queue
func (c *dubboRegistryController) run() {
-
if c.role == common.PROVIDER {
return
}
@@ -402,7 +394,6 @@
// unmarshalRecord unmarshals the kubernetes dubbo annotation value
func (c *dubboRegistryController) unmarshalRecord(record string) ([]*WatcherEvent, error) {
-
if len(record) == 0 {
// []*WatcherEvent is nil.
return nil, nil
@@ -497,7 +488,6 @@
// assembleDUBBOAnnotations assembles the dubbo kubernetes annotations
// accord the current pod && (k,v) assemble the old-pod, new-pod
func (c *dubboRegistryController) assembleDUBBOAnnotations(k, v string, currentPod *v1.Pod) (oldPod *v1.Pod, newPod *v1.Pod, err error) {
-
oldPod = &v1.Pod{}
newPod = &v1.Pod{}
oldPod.Annotations = make(map[string]string, 8)
@@ -563,7 +553,6 @@
// addAnnotationForCurrentPod adds annotation for current pod
func (c *dubboRegistryController) addAnnotationForCurrentPod(k string, v string) error {
-
c.lock.Lock()
defer c.lock.Unlock()
diff --git a/remoting/kubernetes/watch.go b/remoting/kubernetes/watch.go
index 7bb5ef1..34f5a34 100644
--- a/remoting/kubernetes/watch.go
+++ b/remoting/kubernetes/watch.go
@@ -46,7 +46,6 @@
)
func (e eventType) String() string {
-
switch e {
case Create:
return "CREATE"
@@ -143,9 +142,7 @@
// Put puts the watch event to watcher-set
func (s *watcherSetImpl) Put(watcherEvent *WatcherEvent) error {
-
blockSendMsg := func(object *WatcherEvent, w *watcher) {
-
select {
case <-w.done():
// the watcher already stop
@@ -212,7 +209,6 @@
// addWatcher
func (s *watcherSetImpl) addWatcher(key string, prefix bool) (Watcher, error) {
-
if err := s.valid(); err != nil {
return nil, err
}
@@ -239,7 +235,6 @@
// Get gets elements from watcher-set
func (s *watcherSetImpl) Get(key string, prefix bool) ([]*WatcherEvent, error) {
-
s.lock.RLock()
defer s.lock.RUnlock()
@@ -302,7 +297,6 @@
// nolint
func (w *watcher) stop() {
-
// double close will panic
w.closeOnce.Do(func() {
close(w.exit)
diff --git a/remoting/kubernetes/watch_test.go b/remoting/kubernetes/watch_test.go
index efefcc5..9a0139d 100644
--- a/remoting/kubernetes/watch_test.go
+++ b/remoting/kubernetes/watch_test.go
@@ -26,7 +26,6 @@
)
func TestWatchSet(t *testing.T) {
-
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
defer cancel()
@@ -61,7 +60,6 @@
wg.Add(1)
go func() {
-
defer wg.Done()
w, err := s.Watch("key", true)
if err != nil {
diff --git a/remoting/listener.go b/remoting/listener.go
index eb27c71..a87e502 100644
--- a/remoting/listener.go
+++ b/remoting/listener.go
@@ -23,7 +23,7 @@
// DataListener defines common data listener interface
type DataListener interface {
- DataChange(eventType Event) bool //bool is return for interface implement is interesting
+ DataChange(eventType Event) bool // bool is return for interface implement is interesting
}
//////////////////////////////////////////
diff --git a/remoting/nacos/builder.go b/remoting/nacos/builder.go
index 8a247e2..b5c6530 100644
--- a/remoting/nacos/builder.go
+++ b/remoting/nacos/builder.go
@@ -124,6 +124,7 @@
clientConfig.Username = rc.Username
clientConfig.Password = rc.Password
clientConfig.NotLoadCacheAtStart = true
+ clientConfig.NamespaceId = rc.GetParam(constant.NACOS_NAMESPACE_ID, "")
configMap["clientConfig"] = clientConfig
return clients.CreateNamingClient(configMap)
diff --git a/remoting/zookeeper/client.go b/remoting/zookeeper/client.go
index 54f2992..5d39666 100644
--- a/remoting/zookeeper/client.go
+++ b/remoting/zookeeper/client.go
@@ -18,14 +18,12 @@
package zookeeper
import (
- "path"
"strings"
- "sync"
"time"
)
import (
- "github.com/dubbogo/go-zookeeper/zk"
+ gxzookeeper "github.com/dubbogo/gost/database/kv/zk"
perrors "github.com/pkg/errors"
)
@@ -47,79 +45,8 @@
errNilNode = perrors.Errorf("node does not exist")
)
-// ZookeeperClient represents zookeeper client Configuration
-type ZookeeperClient struct {
- name string
- ZkAddrs []string
- sync.RWMutex // for conn
- Conn *zk.Conn
- Timeout time.Duration
- exit chan struct{}
- Wait sync.WaitGroup
-
- eventRegistry map[string][]*chan struct{}
- eventRegistryLock sync.RWMutex
-}
-
-// nolint
-func StateToString(state zk.State) string {
- switch state {
- case zk.StateDisconnected:
- return "zookeeper disconnected"
- case zk.StateConnecting:
- return "zookeeper connecting"
- case zk.StateAuthFailed:
- return "zookeeper auth failed"
- case zk.StateConnectedReadOnly:
- return "zookeeper connect readonly"
- case zk.StateSaslAuthenticated:
- return "zookeeper sasl authenticated"
- case zk.StateExpired:
- return "zookeeper connection expired"
- case zk.StateConnected:
- return "zookeeper connected"
- case zk.StateHasSession:
- return "zookeeper has session"
- case zk.StateUnknown:
- return "zookeeper unknown state"
- case zk.State(zk.EventNodeDeleted):
- return "zookeeper node deleted"
- case zk.State(zk.EventNodeDataChanged):
- return "zookeeper node data changed"
- default:
- return state.String()
- }
-}
-
-// nolint
-type Options struct {
- zkName string
- client *ZookeeperClient
-
- ts *zk.TestCluster
-}
-
-// Option will define a function of handling Options
-type Option func(*Options)
-
-// WithZkName sets zk client name
-func WithZkName(name string) Option {
- return func(opt *Options) {
- opt.zkName = name
- }
-}
-
// ValidateZookeeperClient validates client and sets options
-func ValidateZookeeperClient(container ZkClientFacade, opts ...Option) error {
- var (
- err error
- )
- options := &Options{}
- for _, opt := range opts {
- opt(options)
- }
- connected := false
-
+func ValidateZookeeperClient(container ZkClientFacade, zkName string) error {
lock := container.ZkClientLock()
url := container.GetUrl()
@@ -135,512 +62,13 @@
return perrors.WithMessagef(paramErr, "newZookeeperClient(address:%+v)", url.Location)
}
zkAddresses := strings.Split(url.Location, ",")
- newClient, cltErr := NewZookeeperClient(options.zkName, zkAddresses, timeout)
+ newClient, cltErr := gxzookeeper.NewZookeeperClient(zkName, zkAddresses, true, gxzookeeper.WithZkTimeOut(timeout))
if cltErr != nil {
logger.Warnf("newZookeeperClient(name{%s}, zk address{%v}, timeout{%d}) = error{%v}",
- options.zkName, url.Location, timeout.String(), cltErr)
+ zkName, url.Location, timeout.String(), cltErr)
return perrors.WithMessagef(cltErr, "newZookeeperClient(address:%+v)", url.Location)
}
container.SetZkClient(newClient)
- connected = true
}
-
- if container.ZkClient().Conn == nil {
- var event <-chan zk.Event
- container.ZkClient().Conn, event, err = zk.Connect(container.ZkClient().ZkAddrs, container.ZkClient().Timeout)
- if err == nil {
- container.ZkClient().Wait.Add(1)
- connected = true
- go container.ZkClient().HandleZkEvent(event)
- }
- }
-
- if connected {
- logger.Infof("Connect to zookeeper successfully, name{%s}, zk address{%v}", options.zkName, url.Location)
- container.WaitGroup().Add(1) // zk client start successful, then registry wg +1
- }
-
- return perrors.WithMessagef(err, "newZookeeperClient(address:%+v)", url.PrimitiveURL)
-}
-
-// nolint
-func NewZookeeperClient(name string, zkAddrs []string, timeout time.Duration) (*ZookeeperClient, error) {
- var (
- err error
- event <-chan zk.Event
- z *ZookeeperClient
- )
-
- z = &ZookeeperClient{
- name: name,
- ZkAddrs: zkAddrs,
- Timeout: timeout,
- exit: make(chan struct{}),
- eventRegistry: make(map[string][]*chan struct{}),
- }
- // connect to zookeeper
- z.Conn, event, err = zk.Connect(zkAddrs, timeout)
- if err != nil {
- return nil, perrors.WithMessagef(err, "zk.Connect(zkAddrs:%+v)", zkAddrs)
- }
-
- z.Wait.Add(1)
- go z.HandleZkEvent(event)
-
- return z, nil
-}
-
-// WithTestCluster sets test cluster for zk client
-func WithTestCluster(ts *zk.TestCluster) Option {
- return func(opt *Options) {
- opt.ts = ts
- }
-}
-
-// NewMockZookeeperClient returns a mock client instance
-func NewMockZookeeperClient(name string, timeout time.Duration, opts ...Option) (*zk.TestCluster, *ZookeeperClient, <-chan zk.Event, error) {
- var (
- err error
- event <-chan zk.Event
- z *ZookeeperClient
- ts *zk.TestCluster
- )
-
- z = &ZookeeperClient{
- name: name,
- ZkAddrs: []string{},
- Timeout: timeout,
- exit: make(chan struct{}),
- eventRegistry: make(map[string][]*chan struct{}),
- }
-
- options := &Options{}
- for _, opt := range opts {
- opt(options)
- }
-
- // connect to zookeeper
- if options.ts != nil {
- ts = options.ts
- } else {
- ts, err = zk.StartTestCluster(1, nil, nil)
- if err != nil {
- return nil, nil, nil, perrors.WithMessagef(err, "zk.Connect")
- }
- }
-
- z.Conn, event, err = ts.ConnectWithOptions(timeout)
- if err != nil {
- return nil, nil, nil, perrors.WithMessagef(err, "zk.Connect")
- }
-
- return ts, z, event, nil
-}
-
-// HandleZkEvent handles zookeeper events
-func (z *ZookeeperClient) HandleZkEvent(session <-chan zk.Event) {
- var (
- state int
- event zk.Event
- )
-
- defer func() {
- z.Wait.Done()
- logger.Infof("zk{path:%v, name:%s} connection goroutine game over.", z.ZkAddrs, z.name)
- }()
-
- for {
- select {
- case <-z.exit:
- return
- case event = <-session:
- logger.Infof("client{%s} get a zookeeper event{type:%s, server:%s, path:%s, state:%d-%s, err:%v}",
- z.name, event.Type, event.Server, event.Path, event.State, StateToString(event.State), event.Err)
- switch (int)(event.State) {
- case (int)(zk.StateDisconnected):
- logger.Warnf("zk{addr:%s} state is StateDisconnected, so close the zk client{name:%s}.", z.ZkAddrs, z.name)
- z.Lock()
- conn := z.Conn
- z.Conn = nil
- z.Unlock()
- if conn != nil {
- conn.Close()
- }
- z.stop()
- return
- case (int)(zk.EventNodeDataChanged), (int)(zk.EventNodeChildrenChanged):
- logger.Infof("zkClient{%s} get zk node changed event{path:%s}", z.name, event.Path)
- z.eventRegistryLock.RLock()
- for p, a := range z.eventRegistry {
- if strings.HasPrefix(p, event.Path) {
- logger.Infof("send event{state:zk.EventNodeDataChange, Path:%s} notify event to path{%s} related listener",
- event.Path, p)
- for _, e := range a {
- *e <- struct{}{}
- }
- }
- }
- z.eventRegistryLock.RUnlock()
- case (int)(zk.StateConnecting), (int)(zk.StateConnected), (int)(zk.StateHasSession):
- if state == (int)(zk.StateHasSession) {
- continue
- }
- z.eventRegistryLock.RLock()
- if a, ok := z.eventRegistry[event.Path]; ok && 0 < len(a) {
- for _, e := range a {
- *e <- struct{}{}
- }
- }
- z.eventRegistryLock.RUnlock()
- }
- state = (int)(event.State)
- }
- }
-}
-
-// RegisterEvent registers zookeeper events
-func (z *ZookeeperClient) RegisterEvent(zkPath string, event *chan struct{}) {
- if zkPath == "" || event == nil {
- return
- }
-
- z.eventRegistryLock.Lock()
- defer z.eventRegistryLock.Unlock()
- a := z.eventRegistry[zkPath]
- a = append(a, event)
- z.eventRegistry[zkPath] = a
- logger.Debugf("zkClient{%s} register event{path:%s, ptr:%p}", z.name, zkPath, event)
-}
-
-// UnregisterEvent unregisters zookeeper events
-func (z *ZookeeperClient) UnregisterEvent(zkPath string, event *chan struct{}) {
- if zkPath == "" {
- return
- }
-
- z.eventRegistryLock.Lock()
- defer z.eventRegistryLock.Unlock()
- infoList, ok := z.eventRegistry[zkPath]
- if !ok {
- return
- }
- for i, e := range infoList {
- if e == event {
- infoList = append(infoList[:i], infoList[i+1:]...)
- logger.Infof("zkClient{%s} unregister event{path:%s, event:%p}", z.name, zkPath, event)
- }
- }
- logger.Debugf("after zkClient{%s} unregister event{path:%s, event:%p}, array length %d",
- z.name, zkPath, event, len(infoList))
- if len(infoList) == 0 {
- delete(z.eventRegistry, zkPath)
- } else {
- z.eventRegistry[zkPath] = infoList
- }
-}
-
-// nolint
-func (z *ZookeeperClient) Done() <-chan struct{} {
- return z.exit
-}
-
-func (z *ZookeeperClient) stop() bool {
- select {
- case <-z.exit:
- return true
- default:
- close(z.exit)
- }
-
- return false
-}
-
-// ZkConnValid validates zookeeper connection
-func (z *ZookeeperClient) ZkConnValid() bool {
- select {
- case <-z.exit:
- return false
- default:
- }
-
- z.RLock()
- defer z.RUnlock()
- return z.Conn != nil
-}
-
-// nolint
-func (z *ZookeeperClient) Close() {
- if z == nil {
- return
- }
-
- z.stop()
- z.Wait.Wait()
- z.Lock()
- conn := z.Conn
- z.Conn = nil
- z.Unlock()
- if conn != nil {
- logger.Infof("zkClient Conn{name:%s, zk addr:%d} exit now.", z.name, conn.SessionID())
- conn.Close()
- }
-
- logger.Infof("zkClient{name:%s, zk addr:%s} exit now.", z.name, z.ZkAddrs)
-}
-
-// Create will create the node recursively, which means that if the parent node is absent,
-// it will create parent node first.
-// And the value for the basePath is ""
-func (z *ZookeeperClient) Create(basePath string) error {
- return z.CreateWithValue(basePath, []byte(""))
-}
-
-// CreateWithValue will create the node recursively, which means that if the parent node is absent,
-// it will create parent node first.
-func (z *ZookeeperClient) CreateWithValue(basePath string, value []byte) error {
- var (
- err error
- tmpPath string
- )
-
- logger.Debugf("zookeeperClient.Create(basePath{%s})", basePath)
- conn := z.getConn()
- err = errNilZkClientConn
- if conn == nil {
- return perrors.WithMessagef(err, "zk.Create(path:%s)", basePath)
- }
-
- for _, str := range strings.Split(basePath, "/")[1:] {
- tmpPath = path.Join(tmpPath, "/", str)
- _, err = conn.Create(tmpPath, value, 0, zk.WorldACL(zk.PermAll))
-
- if err != nil {
- if err == zk.ErrNodeExists {
- logger.Debugf("zk.create(\"%s\") exists", tmpPath)
- } else {
- logger.Errorf("zk.create(\"%s\") error(%v)", tmpPath, perrors.WithStack(err))
- return perrors.WithMessagef(err, "zk.Create(path:%s)", basePath)
- }
- }
- }
-
return nil
}
-
-// CreateTempWithValue will create the node recursively, which means that if the parent node is absent,
-// it will create parent node first,and set value in last child path
-// If the path exist, it will update data
-func (z *ZookeeperClient) CreateTempWithValue(basePath string, value []byte) error {
- var (
- err error
- tmpPath string
- )
-
- logger.Debugf("zookeeperClient.Create(basePath{%s})", basePath)
- conn := z.getConn()
- err = errNilZkClientConn
- if conn == nil {
- return perrors.WithMessagef(err, "zk.Create(path:%s)", basePath)
- }
-
- pathSlice := strings.Split(basePath, "/")[1:]
- length := len(pathSlice)
- for i, str := range pathSlice {
- tmpPath = path.Join(tmpPath, "/", str)
- // last child need be ephemeral
- if i == length-1 {
- _, err = conn.Create(tmpPath, value, zk.FlagEphemeral, zk.WorldACL(zk.PermAll))
- if err == zk.ErrNodeExists {
- return err
- }
- } else {
- _, err = conn.Create(tmpPath, []byte{}, 0, zk.WorldACL(zk.PermAll))
- }
- if err != nil {
- if err == zk.ErrNodeExists {
- logger.Debugf("zk.create(\"%s\") exists", tmpPath)
- } else {
- logger.Errorf("zk.create(\"%s\") error(%v)", tmpPath, perrors.WithStack(err))
- return perrors.WithMessagef(err, "zk.Create(path:%s)", basePath)
- }
- }
- }
-
- return nil
-}
-
-// nolint
-func (z *ZookeeperClient) Delete(basePath string) error {
- err := errNilZkClientConn
- conn := z.getConn()
- if conn != nil {
- err = conn.Delete(basePath, -1)
- }
-
- return perrors.WithMessagef(err, "Delete(basePath:%s)", basePath)
-}
-
-// RegisterTemp registers temporary node by @basePath and @node
-func (z *ZookeeperClient) RegisterTemp(basePath string, node string) (string, error) {
- var (
- err error
- zkPath string
- tmpPath string
- )
-
- err = errNilZkClientConn
- zkPath = path.Join(basePath) + "/" + node
- conn := z.getConn()
- if conn != nil {
- tmpPath, err = conn.Create(zkPath, []byte(""), zk.FlagEphemeral, zk.WorldACL(zk.PermAll))
- }
-
- if err != nil {
- logger.Warnf("conn.Create(\"%s\", zk.FlagEphemeral) = error(%v)", zkPath, perrors.WithStack(err))
- return zkPath, perrors.WithStack(err)
- }
- logger.Debugf("zkClient{%s} create a temp zookeeper node:%s", z.name, tmpPath)
-
- return tmpPath, nil
-}
-
-// RegisterTempSeq register temporary sequence node by @basePath and @data
-func (z *ZookeeperClient) RegisterTempSeq(basePath string, data []byte) (string, error) {
- var (
- err error
- tmpPath string
- )
-
- err = errNilZkClientConn
- conn := z.getConn()
- if conn != nil {
- tmpPath, err = conn.Create(
- path.Join(basePath)+"/",
- data,
- zk.FlagEphemeral|zk.FlagSequence,
- zk.WorldACL(zk.PermAll),
- )
- }
-
- logger.Debugf("zookeeperClient.RegisterTempSeq(basePath{%s}) = tempPath{%s}", basePath, tmpPath)
- if err != nil && err != zk.ErrNodeExists {
- logger.Errorf("zkClient{%s} conn.Create(\"%s\", \"%s\", zk.FlagEphemeral|zk.FlagSequence) error(%v)",
- z.name, basePath, string(data), err)
- return "", perrors.WithStack(err)
- }
- logger.Debugf("zkClient{%s} create a temp zookeeper node:%s", z.name, tmpPath)
-
- return tmpPath, nil
-}
-
-// GetChildrenW gets children watch by @path
-func (z *ZookeeperClient) GetChildrenW(path string) ([]string, <-chan zk.Event, error) {
- var (
- err error
- children []string
- stat *zk.Stat
- watcher *zk.Watcher
- )
-
- err = errNilZkClientConn
- conn := z.getConn()
- if conn != nil {
- children, stat, watcher, err = conn.ChildrenW(path)
- }
-
- if err != nil {
- if err == zk.ErrNoChildrenForEphemerals {
- return nil, nil, errNilChildren
- }
- if err == zk.ErrNoNode {
- return nil, nil, errNilNode
- }
- logger.Warnf("zk.ChildrenW(path{%s}) = error(%v)", path, err)
- return nil, nil, perrors.WithMessagef(err, "zk.ChildrenW(path:%s)", path)
- }
- if stat == nil {
- return nil, nil, perrors.Errorf("path{%s} get stat is nil", path)
- }
- if len(children) == 0 {
- return nil, nil, errNilChildren
- }
-
- return children, watcher.EvtCh, nil
-}
-
-// GetChildren gets children by @path
-func (z *ZookeeperClient) GetChildren(path string) ([]string, error) {
- var (
- err error
- children []string
- stat *zk.Stat
- )
-
- err = errNilZkClientConn
- conn := z.getConn()
- if conn != nil {
- children, stat, err = conn.Children(path)
- }
-
- if err != nil {
- if err == zk.ErrNoNode {
- return nil, perrors.Errorf("path{%s} has none children", path)
- }
- logger.Errorf("zk.Children(path{%s}) = error(%v)", path, perrors.WithStack(err))
- return nil, perrors.WithMessagef(err, "zk.Children(path:%s)", path)
- }
- if stat == nil {
- return nil, perrors.Errorf("path{%s} has none children", path)
- }
- if len(children) == 0 {
- return nil, errNilChildren
- }
-
- return children, nil
-}
-
-// ExistW to judge watch whether it exists or not by @zkPath
-func (z *ZookeeperClient) ExistW(zkPath string) (<-chan zk.Event, error) {
- var (
- exist bool
- err error
- watcher *zk.Watcher
- )
-
- err = errNilZkClientConn
- conn := z.getConn()
- if conn != nil {
- exist, _, watcher, err = conn.ExistsW(zkPath)
- }
-
- if err != nil {
- logger.Warnf("zkClient{%s}.ExistsW(path{%s}) = error{%v}.", z.name, zkPath, perrors.WithStack(err))
- return nil, perrors.WithMessagef(err, "zk.ExistsW(path:%s)", zkPath)
- }
- if !exist {
- logger.Warnf("zkClient{%s}'s App zk path{%s} does not exist.", z.name, zkPath)
- return nil, perrors.Errorf("zkClient{%s} App zk path{%s} does not exist.", z.name, zkPath)
- }
-
- return watcher.EvtCh, nil
-}
-
-// GetContent gets content by @zkPath
-func (z *ZookeeperClient) GetContent(zkPath string) ([]byte, *zk.Stat, error) {
- return z.Conn.Get(zkPath)
-}
-
-// nolint
-func (z *ZookeeperClient) SetContent(zkPath string, content []byte, version int32) (*zk.Stat, error) {
- return z.Conn.Set(zkPath, content, version)
-}
-
-// getConn gets zookeeper connection safely
-func (z *ZookeeperClient) getConn() *zk.Conn {
- if z == nil {
- return nil
- }
- z.RLock()
- defer z.RUnlock()
- return z.Conn
-}
diff --git a/remoting/zookeeper/client_test.go b/remoting/zookeeper/client_test.go
deleted file mode 100644
index 3d09499..0000000
--- a/remoting/zookeeper/client_test.go
+++ /dev/null
@@ -1,166 +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 zookeeper
-
-import (
- "testing"
- "time"
-)
-
-import (
- "github.com/dubbogo/go-zookeeper/zk"
- "github.com/stretchr/testify/assert"
-)
-
-import (
- "github.com/apache/dubbo-go/common/logger"
-)
-
-func verifyEventStateOrder(t *testing.T, c <-chan zk.Event, expectedStates []zk.State, source string) {
- for _, state := range expectedStates {
- for {
- event, ok := <-c
- if !ok {
- t.Fatalf("unexpected channel close for %s", source)
- }
- logger.Debug(event)
- if event.Type != zk.EventSession {
- continue
- }
-
- if event.State != state {
- t.Fatalf("mismatched state order from %s, expected %v, received %v", source, state, event.State)
- }
- break
- }
- }
-}
-
-//func Test_newZookeeperClient(t *testing.T) {
-// ts, err := zk.StartTestCluster(1, nil, nil)
-// if err != nil {
-// t.Fatal(err)
-// }
-// defer ts.Stop()
-//
-// callbackChan := make(chan zk.Event)
-// f := func(event zk.Event) {
-// callbackChan <- event
-// }
-//
-// zook, eventChan, err := ts.ConnectWithOptions(15*time.Second, zk.WithEventCallback(f))
-// if err != nil {
-// t.Fatalf("Connect returned error: %+v", err)
-// }
-//
-// states := []zk.State{zk.StateConnecting, zk.StateConnected, zk.StateHasSession}
-// verifyEventStateOrder(t, callbackChan, states, "callback")
-// verifyEventStateOrder(t, eventChan, states, "event channel")
-//
-// zook.Close()
-// verifyEventStateOrder(t, callbackChan, []zk.State{zk.StateDisconnected}, "callback")
-// verifyEventStateOrder(t, eventChan, []zk.State{zk.StateDisconnected}, "event channel")
-//
-//}
-
-func Test_newMockZookeeperClient(t *testing.T) {
- ts, z, event, err := NewMockZookeeperClient("test", 15*time.Second)
- assert.NoError(t, err)
- defer func() {
- err := ts.Stop()
- assert.Nil(t, err)
- }()
- states := []zk.State{zk.StateConnecting, zk.StateConnected, zk.StateHasSession}
- verifyEventStateOrder(t, event, states, "event channel")
-
- z.Close()
- verifyEventStateOrder(t, event, []zk.State{zk.StateDisconnected}, "event channel")
-}
-
-func TestCreate(t *testing.T) {
- ts, z, event, err := NewMockZookeeperClient("test", 15*time.Second)
- assert.NoError(t, err)
- defer func() {
- _ = ts.Stop()
- assert.Nil(t, err)
- }()
- err = z.Create("test1/test2/test3/test4")
- assert.NoError(t, err)
-
- states := []zk.State{zk.StateConnecting, zk.StateConnected, zk.StateHasSession}
- verifyEventStateOrder(t, event, states, "event channel")
-}
-
-func TestCreateDelete(t *testing.T) {
- ts, z, event, err := NewMockZookeeperClient("test", 15*time.Second)
- assert.NoError(t, err)
- defer func() {
- _ = ts.Stop()
- assert.Nil(t, err)
- }()
-
- states := []zk.State{zk.StateConnecting, zk.StateConnected, zk.StateHasSession}
- verifyEventStateOrder(t, event, states, "event channel")
- err = z.Create("/test1/test2/test3/test4")
- assert.NoError(t, err)
- err = z.Delete("/test1/test2/test3/test4")
- assert.NoError(t, err)
- // verifyEventOrder(t, event, []zk.EventType{zk.EventNodeCreated}, "event channel")
-}
-
-func TestRegisterTemp(t *testing.T) {
- ts, z, event, err := NewMockZookeeperClient("test", 15*time.Second)
- assert.NoError(t, err)
- defer func() {
- _ = ts.Stop()
- assert.Nil(t, err)
- }()
- err = z.Create("/test1/test2/test3")
- assert.NoError(t, err)
-
- tmpath, err := z.RegisterTemp("/test1/test2/test3", "test4")
- assert.NoError(t, err)
- assert.Equal(t, "/test1/test2/test3/test4", tmpath)
- states := []zk.State{zk.StateConnecting, zk.StateConnected, zk.StateHasSession}
- verifyEventStateOrder(t, event, states, "event channel")
-}
-
-func TestRegisterTempSeq(t *testing.T) {
- ts, z, event, err := NewMockZookeeperClient("test", 15*time.Second)
- assert.NoError(t, err)
- defer func() {
- _ = ts.Stop()
- assert.Nil(t, err)
- }()
- err = z.Create("/test1/test2/test3")
- assert.NoError(t, err)
- tmpath, err := z.RegisterTempSeq("/test1/test2/test3", []byte("test"))
- assert.NoError(t, err)
- assert.Equal(t, "/test1/test2/test3/0000000000", tmpath)
- states := []zk.State{zk.StateConnecting, zk.StateConnected, zk.StateHasSession}
- verifyEventStateOrder(t, event, states, "event channel")
-}
-
-func Test_UnregisterEvent(t *testing.T) {
- client := &ZookeeperClient{}
- client.eventRegistry = make(map[string][]*chan struct{})
- array := []*chan struct{}{}
- array = append(array, new(chan struct{}))
- client.eventRegistry["test"] = array
- client.UnregisterEvent("test", new(chan struct{}))
-}
diff --git a/remoting/zookeeper/curator_discovery/service_discovery.go b/remoting/zookeeper/curator_discovery/service_discovery.go
index acd43c0..9c7488b 100644
--- a/remoting/zookeeper/curator_discovery/service_discovery.go
+++ b/remoting/zookeeper/curator_discovery/service_discovery.go
@@ -26,6 +26,7 @@
import (
"github.com/dubbogo/go-zookeeper/zk"
+ gxzookeeper "github.com/dubbogo/gost/database/kv/zk"
perrors "github.com/pkg/errors"
)
@@ -46,7 +47,7 @@
// https://github.com/apache/curator/blob/master/curator-x-discovery/src/main/java/org/apache/curator/x/discovery/ServiceDiscovery.java
// It's not exactly the same as curator-x-discovery's service discovery
type ServiceDiscovery struct {
- client *zookeeper.ZookeeperClient
+ client *gxzookeeper.ZookeeperClient
mutex *sync.Mutex
basePath string
services *sync.Map
@@ -54,7 +55,7 @@
}
// NewServiceDiscovery the constructor of service discovery
-func NewServiceDiscovery(client *zookeeper.ZookeeperClient, basePath string) *ServiceDiscovery {
+func NewServiceDiscovery(client *gxzookeeper.ZookeeperClient, basePath string) *ServiceDiscovery {
return &ServiceDiscovery{
client: client,
mutex: &sync.Mutex{},
@@ -119,7 +120,6 @@
return perrors.New("[ServiceDiscovery] services value not entry")
}
data, err := json.Marshal(instance)
-
if err != nil {
return err
}
diff --git a/remoting/zookeeper/facade.go b/remoting/zookeeper/facade.go
index 3440d83..3bc7995 100644
--- a/remoting/zookeeper/facade.go
+++ b/remoting/zookeeper/facade.go
@@ -19,10 +19,11 @@
import (
"sync"
+ "time"
)
+
import (
- "github.com/apache/dubbo-getty"
- perrors "github.com/pkg/errors"
+ gxzookeeper "github.com/dubbogo/gost/database/kv/zk"
)
import (
@@ -31,62 +32,26 @@
)
type ZkClientFacade interface {
- ZkClient() *ZookeeperClient
- SetZkClient(*ZookeeperClient)
+ ZkClient() *gxzookeeper.ZookeeperClient
+ SetZkClient(*gxzookeeper.ZookeeperClient)
ZkClientLock() *sync.Mutex
WaitGroup() *sync.WaitGroup // for wait group control, zk client listener & zk client container
- Done() chan struct{} // for zk client control
+ Done() chan struct{} // for registry destroy
RestartCallBack() bool
GetUrl() *common.URL
}
// HandleClientRestart keeps the connection between client and server
func HandleClientRestart(r ZkClientFacade) {
- var (
- err error
-
- failTimes int
- )
-
-LOOP:
+ defer r.WaitGroup().Done()
for {
select {
+ case <-r.ZkClient().Reconnect():
+ r.RestartCallBack()
+ time.Sleep(10 * time.Microsecond)
case <-r.Done():
- r.WaitGroup().Done() // dec the wg when registry is closed
- logger.Warnf("(ZkProviderRegistry)reconnectZkRegistry goroutine exit now...")
- break LOOP
- // re-register all services
- case <-r.ZkClient().Done():
- r.ZkClientLock().Lock()
- r.ZkClient().Close()
- zkName := r.ZkClient().name
- zkAddress := r.ZkClient().ZkAddrs
- r.SetZkClient(nil)
- r.ZkClientLock().Unlock()
- r.WaitGroup().Done() // dec the wg when zk client is closed
-
- // Connect zk until success.
- failTimes = 0
- for {
- select {
- case <-r.Done():
- r.WaitGroup().Done() // dec the wg when registry is closed
- logger.Warnf("(ZkProviderRegistry)reconnectZkRegistry goroutine exit now...")
- break LOOP
- case <-getty.GetTimeWheel().After(timeSecondDuration(failTimes * ConnDelay)): // Prevent crazy reconnection zk.
- }
- err = ValidateZookeeperClient(r, WithZkName(zkName))
- logger.Infof("ZkProviderRegistry.validateZookeeperClient(zkAddr{%s}) = error{%#v}",
- zkAddress, perrors.WithStack(err))
- if err == nil && r.RestartCallBack() {
- break
- }
- failTimes++
- logger.Warnf("ZK reconnect failed %d times", failTimes)
- if MaxFailTimes <= failTimes {
- failTimes = MaxFailTimes
- }
- }
+ logger.Warnf("receive registry destroy event, quit client restart handler")
+ return
}
}
}
diff --git a/remoting/zookeeper/facade_test.go b/remoting/zookeeper/facade_test.go
index 4a76a80..6463e57 100644
--- a/remoting/zookeeper/facade_test.go
+++ b/remoting/zookeeper/facade_test.go
@@ -22,23 +22,45 @@
"testing"
"time"
)
+
import (
"github.com/dubbogo/go-zookeeper/zk"
+ gxzookeeper "github.com/dubbogo/gost/database/kv/zk"
"github.com/stretchr/testify/assert"
)
+
import (
"github.com/apache/dubbo-go/common"
)
type mockFacade struct {
- client *ZookeeperClient
+ client *gxzookeeper.ZookeeperClient
cltLock sync.Mutex
wg sync.WaitGroup
URL *common.URL
done chan struct{}
}
-func newMockFacade(client *ZookeeperClient, url *common.URL) ZkClientFacade {
+func verifyEventStateOrder(t *testing.T, c <-chan zk.Event, expectedStates []zk.State, source string) {
+ for _, state := range expectedStates {
+ for {
+ event, ok := <-c
+ if !ok {
+ t.Fatalf("unexpected channel close for %s", source)
+ }
+ if event.Type != zk.EventSession {
+ continue
+ }
+
+ if event.State != state {
+ t.Fatalf("mismatched state order from %s, expected %v, received %v", source, state, event.State)
+ }
+ break
+ }
+ }
+}
+
+func newMockFacade(client *gxzookeeper.ZookeeperClient, url *common.URL) ZkClientFacade {
mock := &mockFacade{
client: client,
URL: url,
@@ -48,11 +70,11 @@
return mock
}
-func (r *mockFacade) ZkClient() *ZookeeperClient {
+func (r *mockFacade) ZkClient() *gxzookeeper.ZookeeperClient {
return r.client
}
-func (r *mockFacade) SetZkClient(client *ZookeeperClient) {
+func (r *mockFacade) SetZkClient(client *gxzookeeper.ZookeeperClient) {
r.client = client
}
@@ -86,7 +108,7 @@
}
func Test_Facade(t *testing.T) {
- ts, z, event, err := NewMockZookeeperClient("test", 15*time.Second)
+ ts, z, event, err := gxzookeeper.NewMockZookeeperClient("test", 15*time.Second)
assert.NoError(t, err)
defer func() {
if err := ts.Stop(); err != nil {
@@ -100,5 +122,4 @@
verifyEventStateOrder(t, event, states, "event channel")
z.Close()
verifyEventStateOrder(t, event, []zk.State{zk.StateDisconnected}, "event channel")
- //time.Sleep(2e9)
}
diff --git a/remoting/zookeeper/listener.go b/remoting/zookeeper/listener.go
index f1ac954..5440127 100644
--- a/remoting/zookeeper/listener.go
+++ b/remoting/zookeeper/listener.go
@@ -25,8 +25,9 @@
)
import (
- "github.com/apache/dubbo-getty"
+ getty "github.com/apache/dubbo-getty"
"github.com/dubbogo/go-zookeeper/zk"
+ gxzookeeper "github.com/dubbogo/gost/database/kv/zk"
perrors "github.com/pkg/errors"
)
@@ -37,28 +38,28 @@
"github.com/apache/dubbo-go/remoting"
)
-var (
- defaultTTL = 15 * time.Minute
-)
+var defaultTTL = 15 * time.Minute
// nolint
type ZkEventListener struct {
- client *ZookeeperClient
+ client *gxzookeeper.ZookeeperClient
pathMapLock sync.Mutex
pathMap map[string]struct{}
wg sync.WaitGroup
+ exit chan struct{}
}
// NewZkEventListener returns a EventListener instance
-func NewZkEventListener(client *ZookeeperClient) *ZkEventListener {
+func NewZkEventListener(client *gxzookeeper.ZookeeperClient) *ZkEventListener {
return &ZkEventListener{
client: client,
pathMap: make(map[string]struct{}),
+ exit: make(chan struct{}),
}
}
// nolint
-func (l *ZkEventListener) SetClient(client *ZookeeperClient) {
+func (l *ZkEventListener) SetClient(client *gxzookeeper.ZookeeperClient) {
l.client = client
}
@@ -91,7 +92,7 @@
select {
case zkEvent = <-keyEventCh:
logger.Warnf("get a zookeeper keyEventCh{type:%s, server:%s, path:%s, state:%d-%s, err:%s}",
- zkEvent.Type.String(), zkEvent.Server, zkEvent.Path, zkEvent.State, StateToString(zkEvent.State), zkEvent.Err)
+ zkEvent.Type.String(), zkEvent.Server, zkEvent.Path, zkEvent.State, gxzookeeper.StateToString(zkEvent.State), zkEvent.Err)
switch zkEvent.Type {
case zk.EventNodeDataChanged:
logger.Warnf("zk.ExistW(key{%s}) = event{EventNodeDataChanged}", zkPath)
@@ -119,7 +120,7 @@
logger.Warnf("zk.ExistW(key{%s}) = event{EventNodeDeleted}", zkPath)
return true
}
- case <-l.client.Done():
+ case <-l.exit:
return false
}
}
@@ -247,9 +248,9 @@
case <-getty.GetTimeWheel().After(timeSecondDuration(failTimes * ConnDelay)):
l.client.UnregisterEvent(zkPath, &event)
continue
- case <-l.client.Done():
+ case <-l.exit:
l.client.UnregisterEvent(zkPath, &event)
- logger.Warnf("client.done(), listen(path{%s}) goroutine exit now...", zkPath)
+ logger.Warnf("listen(path{%s}) goroutine exit now...", zkPath)
return
case <-event:
logger.Infof("get zk.EventNodeDataChange notify event")
@@ -302,7 +303,7 @@
logger.Infof("listen dubbo service key{%s}", dubboPath)
l.wg.Add(1)
go func(zkPath string, listener remoting.DataListener) {
- if l.listenServiceNodeEvent(zkPath) {
+ if l.listenServiceNodeEvent(zkPath, listener) {
listener.DataChange(remoting.Event{Path: zkPath, Action: remoting.EventTypeDel})
l.pathMapLock.Lock()
delete(l.pathMap, zkPath)
@@ -331,15 +332,15 @@
l.handleZkNodeEvent(zkPath, children, listener)
case zkEvent = <-childEventCh:
logger.Warnf("get a zookeeper childEventCh{type:%s, server:%s, path:%s, state:%d-%s, err:%s}",
- zkEvent.Type.String(), zkEvent.Server, zkEvent.Path, zkEvent.State, StateToString(zkEvent.State), zkEvent.Err)
+ 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.client.Done():
- logger.Warnf("watch client.done(), listen(path{%s}) goroutine exit now...", zkPath)
+ case <-l.exit:
+ logger.Warnf("listen(path{%s}) goroutine exit now...", zkPath)
ticker.Stop()
return
}
@@ -371,6 +372,6 @@
// Close will let client listen exit
func (l *ZkEventListener) Close() {
- close(l.client.exit)
+ close(l.exit)
l.wg.Wait()
}
diff --git a/remoting/zookeeper/listener_test.go b/remoting/zookeeper/listener_test.go
index 896bdc6..67abd23 100644
--- a/remoting/zookeeper/listener_test.go
+++ b/remoting/zookeeper/listener_test.go
@@ -23,21 +23,22 @@
"testing"
"time"
)
+
import (
"github.com/dubbogo/go-zookeeper/zk"
+ gxzookeeper "github.com/dubbogo/gost/database/kv/zk"
"github.com/stretchr/testify/assert"
)
+
import (
"github.com/apache/dubbo-go/common/logger"
"github.com/apache/dubbo-go/remoting"
)
-var (
- dubboPropertiesPath = "/dubbo/dubbo.properties"
-)
+var dubboPropertiesPath = "/dubbo/dubbo.properties"
-func initZkData(t *testing.T) (*zk.TestCluster, *ZookeeperClient, <-chan zk.Event) {
- ts, client, event, err := NewMockZookeeperClient("test", 15*time.Second)
+func initZkData(t *testing.T) (*zk.TestCluster, *gxzookeeper.ZookeeperClient, <-chan zk.Event) {
+ ts, client, event, err := gxzookeeper.NewMockZookeeperClient("test", 15*time.Second)
assert.NoError(t, err)
data := `
@@ -94,7 +95,7 @@
dubbo.service.com.ikurento.user.UserProvider.cluster=failover
`
var wait sync.WaitGroup
- ts, client, event := initZkData(t)
+ ts, client, _ := initZkData(t)
defer func() {
if err := ts.Stop(); err != nil {
t.Errorf("ts.Stop() = error: %v", err)
@@ -102,7 +103,7 @@
}()
client.Wait.Add(1)
wait.Add(1)
- go client.HandleZkEvent(event)
+ go client.GetEventHandler().HandleZkEvent(client)
listener := NewZkEventListener(client)
dataListener := &mockDataListener{client: client, changedData: changedData, wait: &wait}
listener.ListenServiceEvent(nil, "/dubbo", dataListener)
@@ -111,12 +112,11 @@
assert.NoError(t, err)
wait.Wait()
assert.Equal(t, changedData, dataListener.eventList[1].Content)
-
}
type mockDataListener struct {
eventList []remoting.Event
- client *ZookeeperClient
+ client *gxzookeeper.ZookeeperClient
changedData string
wait *sync.WaitGroup
}
@@ -126,8 +126,6 @@
m.eventList = append(m.eventList, eventType)
if eventType.Content == m.changedData {
m.wait.Done()
- m.client.Close()
-
}
return true
}
diff --git a/samples b/samples
new file mode 160000
index 0000000..ac38818
--- /dev/null
+++ b/samples
@@ -0,0 +1 @@
+Subproject commit ac38818cd13ec2536fe59e51523a4fde3aee37da
diff --git a/test/integrate/dubbo/go-client/client.go b/test/integrate/dubbo/go-client/client.go
index 4c62674..afe965e 100644
--- a/test/integrate/dubbo/go-client/client.go
+++ b/test/integrate/dubbo/go-client/client.go
@@ -37,9 +37,7 @@
_ "github.com/apache/dubbo-go/registry/zookeeper"
)
-var (
- survivalTimeout int = 10e9
-)
+var survivalTimeout int = 10e9
func println(format string, args ...interface{}) {
fmt.Printf("\033[32;40m"+format+"\033[0m\n", args...)
diff --git a/test/integrate/dubbo/go-client/go.mod b/test/integrate/dubbo/go-client/go.mod
index 4708eb1..95a0449 100644
--- a/test/integrate/dubbo/go-client/go.mod
+++ b/test/integrate/dubbo/go-client/go.mod
@@ -1,3 +1,10 @@
module github.com/apache/dubbo-go/test/integrate/dubbo/go-client
go 1.13
+
+require (
+ github.com/apache/dubbo-go v1.5.5
+ github.com/apache/dubbo-go-hessian2 v1.9.1
+)
+
+replace github.com/apache/dubbo-go => ../../../../../dubbo-go
diff --git a/test/integrate/dubbo/go-client/version.go b/test/integrate/dubbo/go-client/version.go
index c613858..9297464 100644
--- a/test/integrate/dubbo/go-client/version.go
+++ b/test/integrate/dubbo/go-client/version.go
@@ -17,6 +17,4 @@
package main
-var (
- Version = "2.6.0"
-)
+var Version = "2.6.0"
diff --git a/test/integrate/dubbo/go-server/go.mod b/test/integrate/dubbo/go-server/go.mod
index 9e11623..0de92a4 100644
--- a/test/integrate/dubbo/go-server/go.mod
+++ b/test/integrate/dubbo/go-server/go.mod
@@ -1,3 +1,10 @@
module github.com/apache/dubbo-go/test/integrate/dubbo/go-server
go 1.13
+
+require (
+ github.com/apache/dubbo-go v1.5.5
+ github.com/apache/dubbo-go-hessian2 v1.9.1
+)
+
+replace github.com/apache/dubbo-go => ../../../../../dubbo-go
diff --git a/test/integrate/dubbo/go-server/server.go b/test/integrate/dubbo/go-server/server.go
index a5d18db..0a38819 100644
--- a/test/integrate/dubbo/go-server/server.go
+++ b/test/integrate/dubbo/go-server/server.go
@@ -33,15 +33,12 @@
_ "github.com/apache/dubbo-go/registry/zookeeper"
)
-var (
- stopC = make(chan struct{})
-)
+var stopC = make(chan struct{})
// they are necessary:
// export CONF_PROVIDER_FILE_PATH="xxx"
// export APP_LOG_CONF_FILE="xxx"
func main() {
-
hessian.RegisterPOJO(&User{})
config.Load()
diff --git a/test/integrate/dubbo/go-server/user.go b/test/integrate/dubbo/go-server/user.go
index 7bff415..aace76c 100644
--- a/test/integrate/dubbo/go-server/user.go
+++ b/test/integrate/dubbo/go-server/user.go
@@ -41,8 +41,7 @@
Time time.Time
}
-type UserProvider struct {
-}
+type UserProvider struct{}
func (u *UserProvider) GetUser(ctx context.Context, req []interface{}) (*User, error) {
println("req:%#v", req)
diff --git a/test/integrate/dubbo/go-server/version.go b/test/integrate/dubbo/go-server/version.go
index c613858..9297464 100644
--- a/test/integrate/dubbo/go-server/version.go
+++ b/test/integrate/dubbo/go-server/version.go
@@ -17,6 +17,4 @@
package main
-var (
- Version = "2.6.0"
-)
+var Version = "2.6.0"
diff --git a/tools/cli/client/client.go b/tools/cli/client/client.go
index fd15939..b6ab019 100644
--- a/tools/cli/client/client.go
+++ b/tools/cli/client/client.go
@@ -68,7 +68,7 @@
return &TelnetClient{
tcpAddr: tcpAddr,
conn: conn,
- responseTimeout: time.Duration(timeout) * time.Millisecond, //default timeout
+ responseTimeout: time.Duration(timeout) * time.Millisecond, // default timeout
protocolName: protocolName,
pendingResponses: &sync.Map{},
proto: proto,
@@ -95,7 +95,7 @@
// ProcessRequests send all requests
func (t *TelnetClient) ProcessRequests(userPkg interface{}) {
- for i, _ := range t.requestList {
+ for i := range t.requestList {
t.processSingleRequest(t.requestList[i], userPkg)
}
}
diff --git a/tools/cli/common/protocol.go b/tools/cli/common/protocol.go
index dd2454a..d54d553 100644
--- a/tools/cli/common/protocol.go
+++ b/tools/cli/common/protocol.go
@@ -21,9 +21,7 @@
"github.com/apache/dubbo-go/tools/cli/protocol"
)
-var (
- protocols = make(map[string]func() protocol.Protocol, 8)
-)
+var protocols = make(map[string]func() protocol.Protocol, 8)
// SetProtocol sets the protocol extension with @name
func SetProtocol(name string, v func() protocol.Protocol) {
diff --git a/tools/cli/example/server/main.go b/tools/cli/example/server/main.go
index ed1ed52..00ea543 100644
--- a/tools/cli/example/server/main.go
+++ b/tools/cli/example/server/main.go
@@ -38,9 +38,7 @@
_ "github.com/apache/dubbo-go/registry/protocol"
)
-var (
- survivalTimeout = int(3e9)
-)
+var survivalTimeout = int(3e9)
// they are necessary:
// export CONF_PROVIDER_FILE_PATH="xxx"
diff --git a/tools/cli/example/server/user.go b/tools/cli/example/server/user.go
index 5835848..0bb25b5 100644
--- a/tools/cli/example/server/user.go
+++ b/tools/cli/example/server/user.go
@@ -34,8 +34,7 @@
hessian.RegisterPOJO(&CallUserStruct{})
}
-type UserProvider struct {
-}
+type UserProvider struct{}
func (u *UserProvider) GetUser(ctx context.Context, userStruct *CallUserStruct) (*User, error) {
fmt.Printf("=======================\nreq:%#v\n", userStruct)
diff --git a/tools/cli/main.go b/tools/cli/main.go
index 1f90f67..43ed374 100644
--- a/tools/cli/main.go
+++ b/tools/cli/main.go
@@ -27,16 +27,18 @@
"github.com/apache/dubbo-go/tools/cli/json_register"
)
-var host string
-var port int
-var protocolName string
-var InterfaceID string
-var version string
-var group string
-var method string
-var sendObjFilePath string
-var recvObjFilePath string
-var timeout int
+var (
+ host string
+ port int
+ protocolName string
+ InterfaceID string
+ version string
+ group string
+ method string
+ sendObjFilePath string
+ recvObjFilePath string
+ timeout int
+)
func init() {
flag.StringVar(&host, "h", "localhost", "target server host")
diff --git a/tools/cli/protocol/dubbo/codec.go b/tools/cli/protocol/dubbo/codec.go
index f73bf8e..ba5e6b4 100644
--- a/tools/cli/protocol/dubbo/codec.go
+++ b/tools/cli/protocol/dubbo/codec.go
@@ -33,7 +33,7 @@
hessian "github.com/apache/dubbo-go-hessian2"
)
-//SerialID serial ID
+// SerialID serial ID
type SerialID byte
const (
@@ -41,7 +41,7 @@
S_Dubbo SerialID = 2
)
-//CallType call type
+// CallType call type
type CallType int32
const (
diff --git a/tools/cli/protocol/dubbo/dubbo_protocol.go b/tools/cli/protocol/dubbo/dubbo_protocol.go
index 97a3ac7..f16f838 100644
--- a/tools/cli/protocol/dubbo/dubbo_protocol.go
+++ b/tools/cli/protocol/dubbo/dubbo_protocol.go
@@ -39,8 +39,7 @@
}
// RpcClientPackageHandler handle package for client in getty.
-type RpcClientPackageHandler struct {
-}
+type RpcClientPackageHandler struct{}
func NewRpcClientPackageHandler() protocol.Protocol {
return RpcClientPackageHandler{}