feat: replace iot adapter with mqtt command pipeline

This commit is contained in:
2026-08-03 13:18:11 +08:00
parent 6ed417c8c1
commit fefdba470a
48 changed files with 1620 additions and 338 deletions

View File

@@ -66,6 +66,12 @@ type PaymentConfig struct {
Wechat WechatPayConfig `yaml:"Wechat"`
}
// IoTConfig 保存 API、Worker 与 IoT Client 间的内部认证和地址。
type IoTConfig struct {
InternalServiceToken string `yaml:"InternalServiceToken"`
ClientBaseURL string `yaml:"ClientBaseURL"`
}
// SrvConfig 与仓库现有进程的配置结构保持一致。
type SrvConfig struct {
conf.Base `yaml:",inline"`
@@ -75,6 +81,7 @@ type SrvConfig struct {
Global GlobalConfig `yaml:"Global"`
Wallet WalletConfig `yaml:"-"`
Payment PaymentConfig `yaml:"Payment"`
IoT IoTConfig `yaml:"IoT"`
}
// New 初始化 BSM 配置并校验服务监听地址。
@@ -103,6 +110,9 @@ func New(srvKey string) {
if Spec.Payment.ExpireMinutes <= 0 || Spec.Payment.RefundWindowDays <= 0 {
panic("Payment expiration and refund window must be greater than zero")
}
if len(strings.TrimSpace(Spec.IoT.InternalServiceToken)) < 16 || !strings.HasPrefix(Spec.IoT.ClientBaseURL, "http") {
panic("IoT internal token and client base URL are required")
}
registerURL, err := url.ParseRequestURI(Spec.Global.UserRegisterURL)
if err != nil || (registerURL.Scheme != "http" && registerURL.Scheme != "https") || registerURL.Host == "" {
panic("Global.UserRegisterURL must be a valid HTTP or HTTPS URL")