98 lines
2.0 KiB
Go
98 lines
2.0 KiB
Go
/*
|
||
配置包,提供项目的配置信息
|
||
*/
|
||
package configYaml
|
||
|
||
import (
|
||
"goutil/debugUtil"
|
||
)
|
||
|
||
var (
|
||
// 是否是DEBUG模式
|
||
DEBUG bool
|
||
|
||
// web服务监听端口
|
||
WebServerAddress string
|
||
|
||
// gRpc监听地址和端口(内网地址即可)
|
||
GrpcServerAddress string
|
||
|
||
// 战斗服务器地址
|
||
FightServerAddress string
|
||
|
||
// 战区Id
|
||
BigGroupId int
|
||
|
||
// 页签Id
|
||
TagId int
|
||
|
||
// 是否是中心服务器地址
|
||
PlayerServerCenter bool
|
||
|
||
// 数据中心服务器地址
|
||
DataCenterAddress string
|
||
|
||
// es urls
|
||
EsUrls string
|
||
|
||
BaseDay int
|
||
)
|
||
|
||
// initBaseConfig
|
||
// @description: 初始化基础配置数据
|
||
// parameter:
|
||
// @configObj: 基础配置数据
|
||
// return:
|
||
// @error: 错误信息
|
||
func initBaseConfig() {
|
||
|
||
root := ConfigYaml.Root
|
||
|
||
// 为DEBUG模式赋值
|
||
DEBUG = root.Debug
|
||
|
||
// 设置debugUtil的状态
|
||
debugUtil.SetDebug(DEBUG)
|
||
|
||
// 解析rpcConfig配置
|
||
WebServerAddress = root.WebServerAddress
|
||
|
||
// gRpc监听地址和端口(内网地址即可)
|
||
GrpcServerAddress = root.GrpcServerAddress
|
||
|
||
// 解析BigGroupId配置
|
||
BigGroupId = root.BigGroupId
|
||
|
||
// 解析FightServerAddress配置
|
||
FightServerAddress = root.FightServerAddress
|
||
|
||
EsUrls = root.EsUrls
|
||
|
||
BaseDay = root.BaseDay
|
||
}
|
||
|
||
// GetDebug
|
||
// @description: 获取是否是开发环境
|
||
// parameter:
|
||
// return:
|
||
// @bool:
|
||
func GetDebug() bool {
|
||
return ConfigYaml.Root.Debug
|
||
}
|
||
|
||
// GetWebServerAddress 返回Web服务器的地址。
|
||
// 该函数通过访问ConfigYaml中的配置信息,获取并返回Web服务器的地址。
|
||
// 主要用于需要与Web服务器建立连接的场景。
|
||
func GetWebServerAddress() string {
|
||
return ConfigYaml.Root.WebServerAddress
|
||
}
|
||
|
||
// GetEsUrls 返回配置文件中 Elasticsearch 的 URL 地址。
|
||
//
|
||
// 该函数通过访问全局变量 ConfigYaml,获取其 Root 字段下的 EsUrls 属性,
|
||
// 并将其作为字符串返回。这提供了一种简单的方法来获取 Elasticsearch 数据库的连接信息,
|
||
// 而无需直接访问配置文件。
|
||
func GetEsUrls() string {
|
||
return ConfigYaml.Root.EsUrls
|
||
}
|