增加安全字段校验提示、请求预算和就绪/存活探针, 让绑定、数据库、Redis 和出站响应解码保留可信诊断上下文。 补充完整应用装配及逆序清理示例,同步接入和迁移文档。 验证:make verify、make race-check 全部通过。 BREAKING CHANGE: 普通 Controller 默认启用 30 秒协作式请求预算, 可用 request_timeout_ms: 0 或 max-exec-time:"0" 关闭; 字段校验失败的 400 响应增加安全字段明细。
This commit is contained in:
1 parent
b4c3ac622c
commit
3196e45a01
22 files changed
+1294
-79
No files matched your search
+2
-2
@@ -51,7 +51,7 @@ func Open(ctx context.Context, cfg Config, instance *zap.Logger) (*redisclient.C
|
||||
ctx = context.Background()
|
||||
}
|
||||
if cfg.Address == "" || cfg.DB < 0 || cfg.ProbeTimeoutMS < 0 || cfg.PoolSize < 0 || cfg.MinIdleConns < 0 || cfg.MaxIdleConns < 0 || cfg.MaxActiveConns < 0 || cfg.PoolTimeoutMS < 0 || cfg.ConnMaxIdleTimeMS < 0 || cfg.ConnMaxLifetimeMS < 0 || (cfg.Network != "" && cfg.Network != "tcp" && cfg.Network != "unix") {
|
||||
return nil, fault.Wrap(CodeConfig, "validate Redis configuration failed", errors.New("invalid Redis target or pool configuration"))
|
||||
return nil, fault.WrapContext(ctx, CodeConfig, "validate Redis configuration failed", errors.New("invalid Redis target or pool configuration"))
|
||||
}
|
||||
options := &redisclient.Options{
|
||||
Addr: cfg.Address, Network: cfg.Network, Username: cfg.Username, Password: cfg.Password, DB: cfg.DB, ClientName: cfg.Name,
|
||||
@@ -81,7 +81,7 @@ func Open(ctx context.Context, cfg Config, instance *zap.Logger) (*redisclient.C
|
||||
probe, cancel := context.WithTimeout(ctx, time.Duration(cfg.ProbeTimeoutMS)*time.Millisecond)
|
||||
defer cancel()
|
||||
if err := client.Ping(probe).Err(); err != nil {
|
||||
return nil, errors.Join(fault.Wrap(CodeProbe, "probe Redis failed", err), fault.Wrap(CodeClose, "close pending Redis client failed", client.Close()))
|
||||
return nil, errors.Join(fault.WrapContext(ctx, CodeProbe, "probe Redis failed", err), fault.WrapContext(ctx, CodeClose, "close pending Redis client failed", client.Close()))
|
||||
}
|
||||
return client, nil
|
||||
}
|
||||
|
||||