You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "xxs588 (via GitHub)" <gi...@apache.org> on 2026/06/11 05:57:11 UTC
[PR] fix(task/shop): 修复商城 demo 灰度路由相关的 3 个问题 [dubbo-go-samples]
xxs588 opened a new pull request, #1111:
URL: https://github.com/apache/dubbo-go-samples/pull/1111
## 概述
修复 `task/shop` 商城 demo 中导致灰度路由(tag routing)无法工作的 3 个代码问题。
## 修复内容
### 修复 1:CheckItem/CheckItemGray 语义反转
`frontend/server_v1/server.go` 中 `CheckItem` 和 `CheckItemGray` 的实现与命名完全反了:
- `CheckItem` 内部附加了 `dubbo.tag=gray`(实际在做灰度路由)
- `CheckItemGray` 用 `context.Background()`(实际在做普通路由)
**修复:** 交换两个方法的实现,使命名与行为一致。
### 修复 2:所有服务缺少 ConfigCenter 配置
所有 8 个服务实例只配置了 `WithRegistry`,没有 `WithConfigCenter`。导致日志持续输出 "Config center does not start",Tag/Condition/Script Router 全部禁用。
**修复:** 为所有服务添加 `WithConfigCenter(config_center.WithZookeeper(), config_center.WithAddress("127.0.0.1:2181"))`。
涉及文件:
- `frontend/server_v1/server.go`
- `comment/server_v1/cmd/server.go`
- `comment/server_v2/cmd/server.go`
- `detail/server_v1/cmd/server.go`
- `detail/server_v2/cmd/server.go`
- `order/server_v1/cmd/server.go`
- `order/server_v2/cmd/server.go`
- `user/go-server/cmd/server.go`
### 修复 3:v2 服务缺少灰度标签
v2 服务没有配置灰度标签,与 v1 在注册中心里无法区分,tag routing 无法命中灰度 provider。
**修复:** 为 comment-v2、detail-v2、order-v2 添加实例级标签 `dubbo.WithTag("gray")` 和服务级标签 `server.WithTag("gray")`。
涉及文件:
- `comment/server_v2/cmd/server.go`
- `detail/server_v2/cmd/server.go`
- `order/server_v2/cmd/server.go`
## 测试验证
使用 Playwright 浏览器自动化验证:
| 场景 | 预期 | 结果 |
|---|---|---|
| `/login` 普通登录 | 返回 v1 数据 | ✅ |
| `/timeoutLogin` 超时登录 | 显示超时提示 | ✅ |
| `/order` 下单 | 下单成功 | ✅ |
| `/userinfo` 用户信息 | 返回用户信息 | ✅ |
| `/grayLogin` 灰度登录 | 返回 v2 数据 | ❌ 需要框架修复 |
## 备注
灰度登录(`/grayLogin`)需要 dubbo-go 框架层面的修复才能真正工作。`application.tag` 在 service-discovery-registry 路径中未正确传播到 `dubbo.tag`,详见 [apache/dubbo-go#3397](https://github.com/apache/dubbo-go/issues/3397) 和 [apache/dubbo-go#3398](https://github.com/apache/dubbo-go/issues/3398)。
本 PR 仅修复 sample 代码问题,不涉及框架改动。
--
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: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
Re: [PR] fix(task/shop): 修复商城 demo 灰度路由相关的 2 个问题 [dubbo-go-samples]
Posted by "Alanxtl (via GitHub)" <gi...@apache.org>.
Alanxtl merged PR #1111:
URL: https://github.com/apache/dubbo-go-samples/pull/1111
--
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: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
Re: [PR] fix(task/shop): 修复商城 demo 灰度路由相关的 2 个问题 [dubbo-go-samples]
Posted by "xxs588 (via GitHub)" <gi...@apache.org>.
xxs588 commented on PR #1111:
URL: https://github.com/apache/dubbo-go-samples/pull/1111#issuecomment-4688710134
> pls fix copilot's comment
好的
--
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: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
Re: [PR] fix(task/shop): 修复商城 demo 灰度路由相关的 2 个问题 [dubbo-go-samples]
Posted by "xxs588 (via GitHub)" <gi...@apache.org>.
xxs588 commented on PR #1111:
URL: https://github.com/apache/dubbo-go-samples/pull/1111#issuecomment-4681451918
备注问题已被https://github.com/apache/dubbo-go/issues/3400 解决
--
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: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
Re: [PR] fix(task/shop): 修复商城 demo 灰度路由相关的 2 个问题 [dubbo-go-samples]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #1111:
URL: https://github.com/apache/dubbo-go-samples/pull/1111#discussion_r3400176001
##########
task/shop/frontend/server_v1/server.go:
##########
@@ -126,22 +126,22 @@ func (s *ShopServiceProvider) CheckItem(sku int64, username string) (*detailAPI.
Sku: sku,
UserName: username,
}
- // add tag
- ctx := context.Background()
- atm := map[string]string{
- "dubbo.tag": "gray",
- "dubbo.force.tag": "true",
- }
- ctx = context.WithValue(ctx, constant.AttachmentKey, atm)
- return s.detailService.GetItem(ctx, req)
+ return s.detailService.GetItem(context.Background(), req)
}
func (s *ShopServiceProvider) CheckItemGray(sku int64, username string) (*detailAPI.Item, error) {
req := &detailAPI.GetItemReq{
Sku: sku,
UserName: username,
}
- return s.detailService.GetItem(context.Background(), req)
+ // add tag for gray routing
+ ctx := context.Background()
+ atm := map[string]string{
+ "dubbo.tag": "gray",
+ "dubbo.force.tag": "true",
+ }
Review Comment:
Tag routing attachments use hard-coded keys ("dubbo.tag" / "dubbo.force.tag"). This is easy to mistype and diverges from other tag-router samples in this repo which use dubbo-go constants (e.g., constant.Tagkey / constant.ForceUseTag). Using the constants improves consistency and protects against future key changes.
--
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: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
Re: [PR] fix(task/shop): 修复商城 demo 灰度路由相关的 2 个问题 [dubbo-go-samples]
Posted by "Alanxtl (via GitHub)" <gi...@apache.org>.
Alanxtl commented on PR #1111:
URL: https://github.com/apache/dubbo-go-samples/pull/1111#issuecomment-4688569084
pls fix copilot's comment
--
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: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org