diff --git a/README.md b/README.md index 24f9f894adb54e4eb7ff13e3ea128c477d0dc6cf..56408df75d92ffeeb551bcd270d4878bea458cb7 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ Finished List: - Transport: HTTP, TCP - Codec: JsonRPC v2, Hessian v2 - Registry: ZooKeeper/[etcd v3](https://github.com/apache/dubbo-go/pull/148)/[nacos](https://github.com/apache/dubbo-go/pull/151)/[consul](https://github.com/apache/dubbo-go/pull/121) -- Configure Center: Zookeeper +- Dynamic Configure Center & Service Management Configurator: Zookeeper - Cluster Strategy: Failover/[Failfast](https://github.com/apache/dubbo-go/pull/140)/[Failsafe/Failback](https://github.com/apache/dubbo-go/pull/136)/[Available](https://github.com/apache/dubbo-go/pull/155)/[Broadcast](https://github.com/apache/dubbo-go/pull/158)/[Forking](https://github.com/apache/dubbo-go/pull/161) - Load Balance: Random/[RoundRobin](https://github.com/apache/dubbo-go/pull/66)/[LeastActive](https://github.com/apache/dubbo-go/pull/65) - Filter: Echo Health Check/[Circuit break and service downgrade](https://github.com/apache/dubbo-go/pull/133)/[TokenFilter](https://github.com/apache/dubbo-go/pull/202)/[AccessLogFilter](https://github.com/apache/dubbo-go/pull/214) @@ -43,7 +43,7 @@ Working List: - Filter: CountFilter/ExecuteLimitFilter/TpsLimitFilter - Registry: k8s - Configure Center: apollo -- Dynamic Configuration Center & Metadata Center (dubbo v2.7.x) +- Metadata Center (dubbo v2.7.x) - Metrics: Promethus(dubbo v2.7.x) Todo List: @@ -64,6 +64,19 @@ TODO ## Running unit tests +### Prepare + +Mac/Linux +```bash +sh ./before_ut.sh +``` + +Windows +```bash +before_ut.bat +``` + +# Run ```bash go test ./... diff --git a/README_CN.md b/README_CN.md index 28243a9e9e4dc2e03e006451b00360bf3ef19e23..4bd69d9c1e1f94c23e6c67b27618cc82ecc81ab5 100644 --- a/README_CN.md +++ b/README_CN.md @@ -30,7 +30,7 @@ Apache License, Version 2.0 - 传输协议: HTTP, TCP - 序列化协议: JsonRPC v2, Hessian v2 - 注册中心: ZooKeeper/[etcd v3](https://github.com/apache/dubbo-go/pull/148)/[nacos](https://github.com/apache/dubbo-go/pull/151)/[consul](https://github.com/apache/dubbo-go/pull/121) -- 配置中心: Zookeeper +- 动态配置中心与服务治理配置器(config center): Zookeeper - 集群策略: Failover/[Failfast](https://github.com/apache/dubbo-go/pull/140)/[Failsafe/Failback](https://github.com/apache/dubbo-go/pull/136)/[Available](https://github.com/apache/dubbo-go/pull/155)/[Broadcast](https://github.com/apache/dubbo-go/pull/158)/[Forking](https://github.com/apache/dubbo-go/pull/161) - 负载均衡策略: Random/[RoundRobin](https://github.com/apache/dubbo-go/pull/66)/[LeastActive](https://github.com/apache/dubbo-go/pull/65) - 过滤器: Echo Health Check/[服务熔断&降级](https://github.com/apache/dubbo-go/pull/133)/[TokenFilter](https://github.com/apache/dubbo-go/pull/202)/[AccessLogFilter](https://github.com/apache/dubbo-go/pull/214) @@ -43,7 +43,7 @@ Apache License, Version 2.0 - 过滤器: CountFilter/ExecuteLimitFilter/TpsLimitFilter - 注册中心: k8s - 配置中心: apollo -- 动态配置中心 & 元数据中心 (dubbo v2.7.x) +- 元数据中心 (dubbo v2.7.x) - Metrics: Promethus(dubbo v2.7.x) 任务列表: @@ -64,10 +64,23 @@ TODO ## 运行单测 +### 准备 + +Mac/Linux +```bash +sh ./before_ut.sh +``` + +Windows +```bash +before_ut.bat +``` + +# 执行 ```bash go test ./... -# 覆盖率 +# coverage go test ./... -coverprofile=coverage.txt -covermode=atomic ``` diff --git a/before_ut.bat b/before_ut.bat new file mode 100644 index 0000000000000000000000000000000000000000..a10df71a7eeb2eadb9d86574dc374b14a4f74e05 --- /dev/null +++ b/before_ut.bat @@ -0,0 +1,5 @@ +set zkJar=zookeeper-3.4.9-fatjar.jar +md remoting\zookeeper\zookeeper-4unittest\contrib\fatjar config_center\zookeeper\zookeeper-4unittest\contrib\fatjar registry\zookeeper\zookeeper-4unittest\contrib\fatjar +curl -L https://github.com/dubbogo/resources/raw/master/zookeeper-4unitest/contrib/fatjar/%zkJar% -o remoting/zookeeper/zookeeper-4unittest/contrib/fatjar/%zkJar% +xcopy /f "remoting/zookeeper/zookeeper-4unittest/contrib/fatjar/%zkJar%" "config_center/zookeeper/zookeeper-4unittest/contrib/fatjar/" +xcopy /f "remoting/zookeeper/zookeeper-4unittest/contrib/fatjar/%zkJar%" "registry/zookeeper/zookeeper-4unittest/contrib/fatjar/" \ No newline at end of file diff --git a/registry/directory/directory.go b/registry/directory/directory.go index b6794e2ebf212ec024d73335ddb19441afa5b96e..e88c611f6f20bc182c3630e328caab848affc08b 100644 --- a/registry/directory/directory.go +++ b/registry/directory/directory.go @@ -38,6 +38,7 @@ import ( "github.com/apache/dubbo-go/protocol" "github.com/apache/dubbo-go/protocol/protocolwrapper" "github.com/apache/dubbo-go/registry" + "github.com/apache/dubbo-go/remoting" ) type Options struct { @@ -119,20 +120,19 @@ func (dir *registryDirectory) refreshInvokers(res *registry.ServiceEvent) { url = nil //TODO: router } + switch res.Action { + case remoting.EventTypeAdd, remoting.EventTypeUpdate: + //dir.cacheService.EventTypeAdd(res.Path, dir.serviceTTL) + dir.cacheInvoker(url) + case remoting.EventTypeDel: + //dir.cacheService.EventTypeDel(res.Path, dir.serviceTTL) + dir.uncacheInvoker(url) + logger.Infof("selector delete service url{%s}", res.Service) + default: + return + } } - // - //switch res.Action { - //case remoting.EventTypeAdd: - // //dir.cacheService.EventTypeAdd(res.Path, dir.serviceTTL) - // dir.cacheInvoker(&res.Service) - //case remoting.EventTypeDel: - // //dir.cacheService.EventTypeDel(res.Path, dir.serviceTTL) - // dir.uncacheInvoker(&res.Service) - // logger.Infof("selector delete service url{%s}", res.Service) - //default: - // return - //} - dir.cacheInvoker(url) + newInvokers := dir.toGroupInvokers() dir.listenerLock.Lock() defer dir.listenerLock.Unlock()