155 lines
3.8 KiB
Go
155 lines
3.8 KiB
Go
|
|
package configYaml
|
|||
|
|
|
|||
|
|
var ConfigYaml = Config{}
|
|||
|
|
|
|||
|
|
// Config 定义与 YAML 文件结构匹配的结构体
|
|||
|
|
type Config struct {
|
|||
|
|
Root Root
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Root 是整个配置文件的根结构体
|
|||
|
|
type Root struct {
|
|||
|
|
// 是否是调试模式
|
|||
|
|
Debug bool `yaml:"debug"`
|
|||
|
|
|
|||
|
|
// 是否是 CrossServer 中心节点(标记为 true 时,才会进行排行榜处理)
|
|||
|
|
CrossServerCenter bool `yaml:"cross_server_center"`
|
|||
|
|
|
|||
|
|
// ManagerCenter 配置
|
|||
|
|
ManagerCenterConfig ManagerCenterConf `yaml:"manager_center_config"`
|
|||
|
|
|
|||
|
|
// logmgr 配置
|
|||
|
|
LogMgr LogMgr `yaml:"log_mgr"`
|
|||
|
|
|
|||
|
|
// Web 服务监听地址和端口
|
|||
|
|
WebServerAddress string `yaml:"web_server_address"`
|
|||
|
|
|
|||
|
|
// gRPC 监听地址和端口 (内网地址即可)
|
|||
|
|
GrpcServerAddress string `yaml:"grpc_server_address"`
|
|||
|
|
|
|||
|
|
// 战斗服务器地址
|
|||
|
|
FightServerAddress string `yaml:"fight_server_address"`
|
|||
|
|
|
|||
|
|
// 数据中心地址
|
|||
|
|
DataCenterAddress string `yaml:"data_center_address"`
|
|||
|
|
|
|||
|
|
// OrderId 和 BigGroupId(仅用于非 PlayerServer)
|
|||
|
|
OrderId int `yaml:"order_id"`
|
|||
|
|
BigGroupId int `yaml:"big_group_id"`
|
|||
|
|
|
|||
|
|
// 重启时载入 Redis 数据日期范围
|
|||
|
|
BaseDay int `yaml:"base_day"`
|
|||
|
|
|
|||
|
|
// ES 地址
|
|||
|
|
EsUrls string `yaml:"es_urls"`
|
|||
|
|
|
|||
|
|
// 数据库配置
|
|||
|
|
DbConfig DBConfig `yaml:"db_config"`
|
|||
|
|
|
|||
|
|
// 监控相关配置
|
|||
|
|
MonitorConfig MonitorConf `yaml:"monitor_config"`
|
|||
|
|
|
|||
|
|
// 功能开关配置
|
|||
|
|
FunctionConfig FunctionConf `yaml:"function_config"`
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// ManagerCenterConf 是 ManagerCenter 的配置结构体
|
|||
|
|
type ManagerCenterConf struct {
|
|||
|
|
// ManagerCenter API 的 URL
|
|||
|
|
ManageCenterAPIUrl string `yaml:"manage_center_api_url"`
|
|||
|
|
|
|||
|
|
// 服务器组类型
|
|||
|
|
GroupType string `yaml:"group_type"`
|
|||
|
|
|
|||
|
|
// 刷新间隔,单位:分钟
|
|||
|
|
RefreshInterval int `yaml:"refresh_interval"`
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// LogMgr 是日志管理器的配置结构体
|
|||
|
|
type LogMgr struct {
|
|||
|
|
// group boxId
|
|||
|
|
GroupId string `yaml:"group_id"`
|
|||
|
|
|
|||
|
|
// group secret
|
|||
|
|
GroupSecret string `yaml:"group_secret"`
|
|||
|
|
|
|||
|
|
// product boxId
|
|||
|
|
ProductId string `yaml:"product_id"`
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// DBConfig 包含数据库和 Redis 的配置
|
|||
|
|
type DBConfig struct {
|
|||
|
|
|
|||
|
|
//管理员数据库配置
|
|||
|
|
AdminDB DatabaseConfig `yaml:"admin_db"`
|
|||
|
|
|
|||
|
|
// 用户数据库配置
|
|||
|
|
UserDB DatabaseConfig `yaml:"user_db"`
|
|||
|
|
|
|||
|
|
// 游戏模型数据库配置
|
|||
|
|
GameModel DatabaseConfig `yaml:"game_model"`
|
|||
|
|
|
|||
|
|
// 游戏数据库配置
|
|||
|
|
GameDB DatabaseConfig `yaml:"game_db"`
|
|||
|
|
|
|||
|
|
// 玩家数据库配置
|
|||
|
|
PlayerDB DatabaseConfig `yaml:"player_db"`
|
|||
|
|
|
|||
|
|
// Redis 配置
|
|||
|
|
RedisConfig RedisConfig `yaml:"redis_config"`
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// DatabaseConfig 是数据库连接的配置结构体
|
|||
|
|
type DatabaseConfig struct {
|
|||
|
|
// 最大处于开启状态的连接数
|
|||
|
|
MaxOpenConns int `yaml:"max_open_conns"`
|
|||
|
|
|
|||
|
|
// 最大处于空闲状态的连接数
|
|||
|
|
MaxIdleConns int `yaml:"max_idle_conns"`
|
|||
|
|
|
|||
|
|
// 数据库连接字符串
|
|||
|
|
ConnectionString string `yaml:"connection_string"`
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// RedisConfig 是 Redis 连接的配置结构体
|
|||
|
|
type RedisConfig struct {
|
|||
|
|
// Redis 数据库连接字符串
|
|||
|
|
ConnectionString string `yaml:"connection_string"`
|
|||
|
|
|
|||
|
|
// 密码, 如果要设置用户 Id,则密码设置为: "UserId:Password"
|
|||
|
|
Password string `yaml:"password"`
|
|||
|
|
|
|||
|
|
// 数据库序号
|
|||
|
|
Database int `yaml:"database"`
|
|||
|
|
|
|||
|
|
// 最大活跃连接数
|
|||
|
|
MaxActive int `yaml:"max_active"`
|
|||
|
|
|
|||
|
|
// 最大空闲的连接数
|
|||
|
|
MaxIdle int `yaml:"max_idle"`
|
|||
|
|
|
|||
|
|
// 连接空闲超时时间,单位:秒
|
|||
|
|
IdleTimeout int `yaml:"idle_timeout"`
|
|||
|
|
|
|||
|
|
// 连接超时时间, 单位:秒
|
|||
|
|
DialConnectTimeout int `yaml:"dial_connect_timeout"`
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// MonitorConf 是监控配置的结构体
|
|||
|
|
type MonitorConf struct {
|
|||
|
|
// 监控使用的服务器 IP (本机的外网地址)
|
|||
|
|
ServerIP string `yaml:"server_ip"`
|
|||
|
|
|
|||
|
|
// 监控使用的服务器名称
|
|||
|
|
ServerName string `yaml:"server_name"`
|
|||
|
|
|
|||
|
|
// 监控的时间间隔(单位:分钟)
|
|||
|
|
Interval int `yaml:"interval"`
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// FunctionConf 是功能开关配置的结构体
|
|||
|
|
type FunctionConf struct {
|
|||
|
|
// 游戏代码: qyc, xh, dzz
|
|||
|
|
GameCode string `yaml:"game_code"`
|
|||
|
|
}
|