rs-zero 0.2.6

Rust-first microservice framework inspired by go-zero engineering practices
Documentation
# 生产检查清单

上线前按以下项目逐项确认。

## 配置

- [ ] 服务名、监听地址、超时、body limit、日志级别已配置。
- [ ] 环境差异通过配置或环境变量管理。
- [ ] 文档和配置中没有真实凭据或个人路径。

## REST/RPC 边界

- [ ] REST handler 使用统一响应和错误格式。
- [ ] RPC 服务启用 request-id metadata 或等价 trace 关联。
- [ ] RPC 客户端 timeout、deadline metadata、retry 次数和 backoff 已配置。
- [ ] RPC discovery selector 的 service name、权重和无实例错误路径已验证。
- [ ] streaming RPC 的 send/recv、正常关闭和错误关闭有明确记录边界。
- [ ] public path 仅包含明确允许的健康检查和观测 endpoint。

## 可靠性

- [ ] 外部调用配置 timeout。
- [ ] 高并发入口有并发限制或上游限流。
- [ ] 不稳定依赖接入熔断或降级策略。
- [ ] ConcurrencyLimit、CircuitBreaker、AdaptiveShedder、RollingWindow 的压力、故障和恢复测试已通过。
- [ ] 优雅停机路径已验证。

## 观测

- [ ] 关键 REST/RPC 路径有日志、metrics 或 trace。
- [ ] 结构化日志包含 request_id、traceparent、trace_id/span_id、service、transport、route/method 和 status/code;route 使用 pattern,不使用 raw path。
- [ ] Subscriber 输出层脱敏覆盖 text/JSON、span fields、event fields、错误文本、Authorization、Cookie、token、password、secret、api_key 以及业务自定义敏感字段。
- [ ] 高频重复日志配置采样;错误聚合不会把用户 id、token、SQL 参数等高基数字段作为 fingerprint。
- [ ] 文件日志如启用,已确认路径权限、`max_bytes`、`max_files`、flush 行为和运行期轮转;按时间清理由 logrotate、journald、容器日志驱动或托管平台承接。
- [ ] OTLP exporter 如启用,已配置 endpoint、resource attributes、shutdown/flush。
- [ ] Pyroscope profiling 如启用,已按实验性 opt-in 能力处理,确认 endpoint、service_name、低基数 tags、sample_rate、shutdown 和采样开销压测结果。
- [ ] metrics endpoint 不暴露敏感数据。
- [ ] 高并发 metrics 路径已运行 `cargo test -p rs-zero --features observability --test metrics_stress`;如使用成熟 client adapter,已运行 `cargo check -p rs-zero --no-default-features --features observability-prometheus-client`。

## 数据库与缓存

- [ ] database pool health check 已接入。
- [ ] transaction 失败路径有错误处理。
- [ ] cache key 使用稳定 namespace 和索引列顺序。
- [ ] Redis 等外部 cache 配置 timeout 和 health check。
- [ ] Redis cache adapter 已按路径风险显式决定是否启用 `RedisBreakerConfig`;启用时已验证 breaker 打开、拒绝和恢复行为。
- [ ] Redis token limiter 如启用 rescue,本地 rescue 限流和 Redis 恢复监控已通过 `scripts/external-integration.sh redis-recovery` 或等价环境验证。
- [ ] Redis Cluster 与应用级分片语义已区分;如使用 Cluster,startup nodes、MOVED/ASK、跨 slot delete_many 和重定向上限已验证。
- [ ] Redis 脚本缓存和 NOSCRIPT 恢复路径已验证。
- [ ] Redis 不可用降级策略已显式配置,默认 fail-closed 未被静默改写。
- [ ] Redis 指标不包含 key、URL、密码或用户输入高基数字段。
- [ ] 如使用 Redis distributed lock,TTL、namespace、owner token 校验解锁、Cluster hash tag、breaker 和 Redis down 错误路径已验证。
- [ ] 分布式锁没有替代数据库唯一约束、事务、幂等或 fencing token;保护外部写入时已有额外版本/令牌校验。
- [ ] CacheAside、LRU、TwoLevel 的压力、并发冲突和故障注入测试已通过。

## 注册中心与 adapter

- [ ] discovery adapter 的 service name、namespace、metadata、health 语义已确认。
- [ ] etcd registry 的 endpoint、prefix、lease TTL、keep-alive、operation timeout 和 watch backoff 已配置。
- [ ] etcd 注册、续期、health update、watch、deregister 和 lease revoke 已在独立环境测试。
- [ ] Kubernetes discovery 的 kubeconfig context、namespace、EndpointSlice RBAC、service_name、port_name、watch timeout 和首次同步超时已配置。
- [ ] Kubernetes EndpointSlice watcher 的 discover、健康过滤、delete 更新和错误状态已在独立环境测试。
- [ ] 默认 CI 不依赖外部服务。
- [ ] Redis、etcd、Kubernetes、OTLP、Pyroscope、MySQL 和 PostgreSQL external integration CI 已通过或有明确豁免记录。

## 发布前验证

- [ ] `cargo metadata --format-version 1 --no-deps`
- [ ] `cargo fmt --all -- --check`
- [ ] `cargo clippy --workspace --all-targets -- -D warnings`
- [ ] `cargo test --workspace`
- [ ] `cargo test --test cache_stress`
- [ ] `cargo test --test resilience_stress`
- [ ] `cargo test -p rs-zero --features observability,rest,rpc --test observability_trace_correlation`
- [ ] `cargo test -p rs-zero --test logging_integration`
- [ ] `RS_ZERO_LONG_TEST_SECONDS=2 RS_ZERO_LONG_TEST_TASKS=8 RS_ZERO_LONG_TEST_KEYS=16 cargo test --test cache_resilience_long_running -- --ignored`
- [ ] `cargo test -p rs-zero --features cache-redis,observability --test cache_redis_degradation`
- [ ] `cargo test -p rs-zero --features cache-redis --test redis_lock`
- [ ] `cargo check -p rs-zero --features profiling`
- [ ] 文档链接和敏感信息检查通过。
- [ ] 如变更生产 adapter,`scripts/external-integration.sh all` 或 GitHub Actions external integrations matrix 已通过;如涉及 Redis Cluster,另行提供 `RS_ZERO_TEST_REDIS_CLUSTER_URL` 并运行 `scripts/external-integration.sh redis-cluster`;如涉及 Redis limiter rescue,运行 `scripts/external-integration.sh redis-recovery`;如涉及 Redis distributed lock,运行 `scripts/external-integration.sh redis-lock`;如涉及 CPU-aware shedder,需在 Linux 上运行 `scripts/external-integration.sh linux-cpu`。
- [ ] 如涉及 OTLP 或 Pyroscope,运行 `scripts/external-integration.sh otlp pyroscope` 或记录明确豁免。

## 回滚边界

- [ ] 生成代码和手写代码分层清楚。
- [ ] 配置变更可回滚。
- [ ] 外部 adapter feature gate 和 fallback 路径已明确。