merge: W-CFG-0 namespace 口径统一前置(阶段二 §4 前置,fable 终审:hash/父链/diff/6单测复跑全核)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
lili 2026-07-04 08:49:33 -07:00
commit b2b4d3892e
4 changed files with 7 additions and 4 deletions

View File

@ -70,6 +70,7 @@ canonical: true
| **server identity**(server 间鉴权头) | key `nacosServerIdentity` / value `f358e96034ab2cd5e41c1a691b4200bb6f576849d61ed4dd` |
| **MySQL 后端** | 复用既有 `100.64.0.8:3306``nacos` 库(root/`ZRH3jwYLOrntBcTAw29MW9BP`,不新增实例);12 张官方表 |
| **部署位置** | mini-infra `/opt/infra-nacos`(compose 源在仓 `deploy/infra/nacos/`);镜像 `nacos/nacos-server:v2.4.3` |
| **命名空间(namespaceId)** | 默认公共空间 = **空串 `""`**,**勿写字面量 `public`**——`public` 只是显示名(namespaceShowName),不是 id。写侧(game-cloud SCA / yudao publish)与读侧(worker nacos_registry / NacosHotConfig)一律用空串;写 `public` 会静默落进另一个空间、配置永远推不到(阶段〇同款坑)。实测 `GET /nacos/v1/console/namespaces``namespace:""` / `namespaceShowName:"public"`。业务生成配置若要隔离,另建**真实** namespaceId、勿复用显示名 |
- **密钥注入**:上面四个密钥在服务器上物化为 `/opt/infra-nacos/.env`(chmod 600、不入仓);本文档是权威副本,compose 文件只用 `${VAR}` 引用、无明文。
- **运维**:起/停 `cd /opt/infra-nacos && docker compose up -d / down`;探活 `NACOS=http://100.64.0.8:8848 bash deploy/infra/nacos/health-check.sh`(绿=readiness 200)。standalone 单机 512m,实测常驻内存 ~627M。

View File

@ -64,10 +64,10 @@ spring:
password: ${NACOS_PASSWORD} # 口令走 Spring env 占位符注入,严禁明文入仓(真值=凭据文档 admin 口令)
discovery:
enabled: true # 重启用 Nacos 服务发现was false各 server 按 spring.application.name 注册进 Nacos
namespace: public # 命名空间B1 部署用 public
namespace: "" # 默认公共空间 namespaceId=空串,勿写 public显示名 public≠id写字面量 public 会静默落错空间
config:
enabled: true # 重启用 Nacos 配置中心was false从 Nacos 读外部化配置
namespace: public
namespace: "" # 默认公共空间 namespaceId=空串,勿写 public同 discovery写读两侧须一致
file-extension: yaml # 配置文件格式
# Sentinel 入口 QPS 突发保护(切片一 阶段〇 C2流控规则从 Nacos dataId sentinel-gen-flow-rules 热加载(改即生效、不重启)。
# 职责 = 生成入队入口速率闸FLOW_GRADE_QPS 削洪峰),与 DB 三门(业务配额)/ C3 consumeThreadMaxdispatch 投递速率上限真在跑并发≤15 属有界 worker 池=follow-up三层正交。

View File

@ -74,7 +74,9 @@ def register(service_host: str, service_port: int) -> None:
client = nacos.NacosClient(
nacos_addr,
namespace=os.environ.get("NACOS_NAMESPACE", "public"),
# 默认公共空间 namespaceId=空串,勿写 public显示名 public≠id写字面量会静默落错空间
# 与 game-cloud SCA 写读两侧口径一致Nacos v1/console/namespaces 实测默认空间 namespace=""
namespace=os.environ.get("NACOS_NAMESPACE", ""),
username=os.environ.get("NACOS_USERNAME", "nacos"),
password=os.environ.get("NACOS_PASSWORD", ""),
)

View File

@ -70,7 +70,7 @@ def test_register_calls_add_naming_instance(clean_env):
ctor.assert_called_once()
c_args, c_kwargs = ctor.call_args
assert c_args[0] == f"{_NACOS_HOST}:8848"
assert c_kwargs.get("namespace") == "public"
assert c_kwargs.get("namespace") == "" # 默认公共空间 namespaceId=空串(勿写 public显示名≠id
assert c_kwargs.get("username") == "nacos"
# add_naming_instance:通告 IP(非绑定 0.0.0.0)+ port