Alanxtl opened a new issue, #3459:
URL: https://github.com/apache/dubbo-go/issues/3459
我们当前依赖的是自维护 fork:
```go
github.com/dubbogo/go-zookeeper v1.0.4-0.20211212162352-f9d2183d89d5
```
上游仓库已经迁移到:
```go
github.com/go-zookeeper/zk
```
希望评估并完成迁移,弃用 fork。
## 背景
对比 fork 和 upstream 后发现,fork 里确实有一些独有改动,但当前 dubbo-go 对这些改动的依赖并不重。主要差异如下:
1. fork 修改了 watcher API:
- fork 的 `GetW/ChildrenW/ExistsW` 返回 `*Watcher`
- upstream 返回 `<-chan Event`
- fork 额外提供了 `RemoveWatcher` 和 `ErrWatcherRemoved`
2. 当前 dubbo-go 代码里没有发现 `RemoveWatcher` 的使用。
3. dubbo-go 中直接调用 `ExistsW` 的地方都丢弃了第三返回值,因此 watcher 返回类型差异对这些调用点影响较小。
4. 真正需要同步处理的是 `github.com/dubbogo/gost`,其中 `database/kv/zk` 封装依赖了 fork 的
watcher API,例如使用了 `watcher.EvtCh`。
5. `gost` 还依赖 fork 暴露的测试 helper:
- `zk.TestCluster`
- `zk.StartTestCluster`
- `zk.WithRetryTimes`
但 upstream 中 `TestCluster/StartTestCluster` 位于 `_test.go`,不是普通库
API,不能直接作为生产代码依赖。
## 需要修改的内容
- 将 dubbo-go 中的依赖从:
```go
github.com/dubbogo/go-zookeeper/zk
```
替换为:
```go
github.com/go-zookeeper/zk
```
- 更新 `go.mod` / `go.sum`。
- 同步处理 `github.com/dubbogo/gost` 中的 zookeeper 封装:
- `GetChildrenW` 中直接返回 upstream 的 `<-chan zk.Event`
- `ExistW` 中直接返回 upstream 的 `<-chan zk.Event`
- 移除或重构对 `zk.TestCluster` / `zk.StartTestCluster` 的生产代码依赖
## 风险点
- Zookeeper watcher 重设逻辑需要重点验证。
- Registry / Config Center / Metadata Report 中依赖 Zookeeper 的监听路径需要跑回归测试。
- `gost` 如果不先适配 upstream,dubbo-go 直接替换依赖可能会出现类型不匹配或编译失败。
## 验证建议
迁移后至少验证以下场景:
- Zookeeper registry 服务注册、订阅、取消订阅
- Config Center 配置监听和变更通知
- Metadata Report 的 service mapping 监听
- Zookeeper 断连、重连后 watcher 是否能重新生效
- 相关单测和集成测试是否通过
## 结论
可以弃用 `dubbogo/go-zookeeper` fork,但不应只改 dubbo-go 的 `go.mod`。需要同步适配 `gost` 的
zookeeper 封装,尤其是 watcher API 和测试 helper 依赖。
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]