fix: 修复写队列 busy 恢复、关闭安全、备份与配置构建问题
This commit is contained in:
@@ -12,6 +12,9 @@ import (
|
||||
// MaxBodyBytesCap 是 max_body_bytes 的硬上限(DEVELOPMENT 11.1)。
|
||||
const MaxBodyBytesCap = 262144
|
||||
|
||||
// MaxFrameBytesCap 是 max_frame_bytes 的硬上限,与 broker MaximumPacketSize 一致。
|
||||
const MaxFrameBytesCap = 786432
|
||||
|
||||
// Config 对应 DEVELOPMENT 第 11.1 节的配置文件。
|
||||
type Config struct {
|
||||
Listen string `yaml:"listen"`
|
||||
@@ -124,39 +127,8 @@ func applyEmptyDefaults(cfg *Config) {
|
||||
if cfg.Log.Level == "" {
|
||||
cfg.Log.Level = def.Log.Level
|
||||
}
|
||||
if cfg.Limits.MaxBodyBytes == 0 {
|
||||
cfg.Limits.MaxBodyBytes = def.Limits.MaxBodyBytes
|
||||
}
|
||||
if cfg.Limits.MaxMetaBytes == 0 {
|
||||
cfg.Limits.MaxMetaBytes = def.Limits.MaxMetaBytes
|
||||
}
|
||||
if cfg.Limits.MaxFrameBytes == 0 {
|
||||
cfg.Limits.MaxFrameBytes = def.Limits.MaxFrameBytes
|
||||
}
|
||||
if cfg.Limits.MaxTTLSeconds == 0 {
|
||||
cfg.Limits.MaxTTLSeconds = def.Limits.MaxTTLSeconds
|
||||
}
|
||||
if cfg.Limits.MaxScheduleSeconds == 0 {
|
||||
cfg.Limits.MaxScheduleSeconds = def.Limits.MaxScheduleSeconds
|
||||
}
|
||||
if cfg.Limits.MaxGroupMembers == 0 {
|
||||
cfg.Limits.MaxGroupMembers = def.Limits.MaxGroupMembers
|
||||
}
|
||||
if cfg.Limits.GraceSeconds == 0 {
|
||||
cfg.Limits.GraceSeconds = def.Limits.GraceSeconds
|
||||
}
|
||||
if cfg.Limits.AckTimeoutSeconds == 0 {
|
||||
cfg.Limits.AckTimeoutSeconds = def.Limits.AckTimeoutSeconds
|
||||
}
|
||||
if cfg.Limits.DeliveryWindow == 0 {
|
||||
cfg.Limits.DeliveryWindow = def.Limits.DeliveryWindow
|
||||
}
|
||||
if cfg.Limits.ReceiptWindow == 0 {
|
||||
cfg.Limits.ReceiptWindow = def.Limits.ReceiptWindow
|
||||
}
|
||||
if cfg.Limits.RequestsPerSecond == 0 {
|
||||
cfg.Limits.RequestsPerSecond = def.Limits.RequestsPerSecond
|
||||
}
|
||||
// 数值字段不在这里把 0 改回默认:Load 已先填 Default 再解析 YAML,
|
||||
// 未写的字段保留默认值;显式写 0 对 grace 等字段有意义,其余由 Validate 拒绝。
|
||||
}
|
||||
|
||||
// Validate 校验 DEVELOPMENT 11.1 全部字段;拒绝 max_body_bytes > 262144。
|
||||
@@ -189,6 +161,9 @@ func (c Config) Validate() error {
|
||||
if c.Limits.MaxFrameBytes <= 0 {
|
||||
errs = append(errs, "limits.max_frame_bytes must be > 0")
|
||||
}
|
||||
if c.Limits.MaxFrameBytes > MaxFrameBytesCap {
|
||||
errs = append(errs, fmt.Sprintf("limits.max_frame_bytes must be <= %d", MaxFrameBytesCap))
|
||||
}
|
||||
if c.Limits.MaxFrameBytes < c.Limits.MaxBodyBytes {
|
||||
errs = append(errs, "limits.max_frame_bytes must be >= limits.max_body_bytes")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user