FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Support nacos v1 v2 and v3 for reading hosts from instance list. by xiewxin · Pull Request #7790 · hyperf/hyperf · GitHub

/ hyperf Public

Support nacos v1 v2 and v3 for reading hosts from instance list. - #7790

Merged
limingxinleo merged 3 commits into
hyperf:masterfrom
xiewxin:fix/nacos-v3-instance-list
Aug 7, 2026
Merged

Support nacos v1 v2 and v3 for reading hosts from instance list.#7790
limingxinleo merged 3 commits into
hyperf:masterfrom
xiewxin:fix/nacos-v3-instance-list

Conversation

xiewxin commented Jul 31, 2026
edited
Loading

Copy link
Copy Markdown
Contributor

修改内容

  • 兼容 Nacos V1 的 hosts 实例列表结构。
  • 兼容 Nacos V2 的 data.hosts 实例列表结构。
  • 兼容 Nacos V3 的 data 实例列表结构。
  • 保持现有的健康实例筛选和 HTTP 状态码异常处理逻辑不变。

问题原因

Nacos V3 使用统一响应结构,将实例数组放在 data 字段中。当前代码只读取
顶层 hosts 字段,因此使用 Nacos V3 进行服务发现时无法取得任何节点。

本次修改同时保留 V1 兼容性,并覆盖 Nacos 官方文档定义的 V2 响应结构。

测试

  • 新增 Nacos V1、V2、V3 实例列表响应测试。
  • 新增非数组 data 的回归测试,避免引入 PHP warning。
  • 已运行 Nacos、Config Nacos 和 Service Governance Nacos 相关测试:
    18 个测试,32 个断言全部通过。
  • PHP CS Fixer 和针对性 PHPStan 检查通过。

修复 #7571

同时解决 #7542 中服务发现响应解析的部分;服务注册和心跳续约不在本次
PR 的修改范围内。

limingxinleo changed the title Fix Nacos V2 and V3 instance list response parsing Support nacos v1 v2 and v3 for reading hosts from instance list. Aug 7, 2026
limingxinleo merged commit 06f6c9f into hyperf:master Aug 7, 2026
65 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL