package config import "hyapp/pkg/configx" // Config 描述 activity-service 启动配置。 type Config struct { ServiceName string `yaml:"service_name"` NodeID string `yaml:"node_id"` GRPCAddr string `yaml:"grpc_addr"` // MySQLDSN 是活动状态、事件消费幂等和 outbox 的必需存储连接串。 MySQLDSN string `yaml:"mysql_dsn"` // MySQLAutoMigrate 保留给显式本地迁移;线上 schema 由发布流程或 initdb 管理。 MySQLAutoMigrate bool `yaml:"mysql_auto_migrate"` Consumer ConsumerConfig `yaml:"consumer"` } // ConsumerConfig 保存 room outbox 消费底座配置。 type ConsumerConfig struct { RoomOutboxPollIntervalMs int64 `yaml:"room_outbox_poll_interval_ms"` BatchSize int `yaml:"batch_size"` } // Default 返回本地默认配置。 func Default() Config { return Config{ ServiceName: "activity-service", NodeID: "activity-local", GRPCAddr: ":13006", MySQLDSN: "hyapp:hyapp@tcp(127.0.0.1:23306)/hyapp_activity?parseTime=true&charset=utf8mb4&loc=Local", MySQLAutoMigrate: false, Consumer: ConsumerConfig{ RoomOutboxPollIntervalMs: 1000, BatchSize: 100, }, } } // Load 从独立 config.yaml 读取 activity-service 配置。 func Load(path string) (Config, error) { cfg := Default() if path == "" { return cfg, nil } if err := configx.LoadYAML(path, &cfg); err != nil { return Config{}, err } return cfg, nil }