update
This commit is contained in:
@ -10,8 +10,18 @@ import (
|
||||
var GlobalConfig Config
|
||||
|
||||
type Config struct {
|
||||
App AppConfig `mapstructure:"app"`
|
||||
Database DatabaseConfig `mapstructure:"database"`
|
||||
App AppConfig `mapstructure:"app"`
|
||||
Ingest IngestConfig `mapstructure:"ingest"`
|
||||
}
|
||||
|
||||
// IngestConfig 入库管线配置:爬虫 → 后台 ingest 接口(HMAC 签名)。
|
||||
// spider 不直连数据库:品牌任务经 GET /admin/internal/crawl/brands 拉取,
|
||||
// 抓取结果经 POST /admin/internal/ingest 上报,由后台 worker 异步落库。
|
||||
type IngestConfig struct {
|
||||
Enabled bool `mapstructure:"enabled"` // 是否启用签名上报(替代直写)
|
||||
Endpoint string `mapstructure:"endpoint"` // 后台 ingest 地址,如 http://localhost:8092/admin/internal/ingest
|
||||
Secret string `mapstructure:"secret"` // 必须与后台 INGEST_SECRET 一致
|
||||
HashIDSecret string `mapstructure:"hashid_secret"` // 必须与后台 HASHID_SECRET 一致(用于编码 brand_uid)
|
||||
}
|
||||
|
||||
type AppConfig struct {
|
||||
@ -19,14 +29,6 @@ type AppConfig struct {
|
||||
Debug bool `mapstructure:"debug"` // 新增 Debug 字段
|
||||
}
|
||||
|
||||
type DatabaseConfig struct {
|
||||
DSN string `mapstructure:"dsn"`
|
||||
MaxOpenConns int `mapstructure:"max_open_conns"`
|
||||
MaxIdleConns int `mapstructure:"max_idle_conns"`
|
||||
ConnMaxLifetime int `mapstructure:"conn_max_lifetime"`
|
||||
ConnMaxIdleTime int `mapstructure:"conn_max_idle_time"`
|
||||
}
|
||||
|
||||
// InitConfig 初始化并读取 YAML 配置文件
|
||||
func InitConfig(cfgFile string) error {
|
||||
if cfgFile != "" {
|
||||
|
||||
Reference in New Issue
Block a user