本文整理汇总了Golang中tools/cfg.GetValue函数的典型用法代码示例。如果您正苦于以下问题:Golang GetValue函数的具体用法?Golang GetValue怎么用?Golang GetValue使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetValue函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: main
func main() {
defer func() {
if x := recover(); x != nil {
ERR("caught panic in main()", x)
}
}()
// 获取监听端口
getPort()
//启动
global.Startup(global.ServerName, "world_log", nil)
//连接Redis
redisProxyErr := redisProxy.InitClient(cfg.GetValue("redis_ip"), cfg.GetValue("redis_port"), cfg.GetValue("redis_pwd"))
checkError(redisProxyErr)
//连接LogServer
logProxyErr := logProxy.InitClient(cfg.GetValue("log_ip"), cfg.GetValue("log_port"))
checkError(logProxyErr)
//启动WorldServer
worldProxyErr := worldProxy.InitServer(world_port)
checkError(worldProxyErr)
//开启下线用户处理
module.User.StartDealOfflineUser()
//保持进程
global.Run()
}
示例2: startLocalServer
func startLocalServer() {
//连接DB
db.Init()
//连接Redis
redisProxyErr := redisProxy.InitClient(cfg.GetValue("redis_ip"), cfg.GetValue("redis_port"))
checkError(redisProxyErr)
listener, err := link.Serve("tcp", "0.0.0.0:"+local_port, packet.New(
binary.SplitByUint32BE, 1024, 1024, 1024,
))
checkError(err)
listener.Serve(func(session *link.Session) {
session.AddCloseCallback(session, func() {
session.Close()
})
global.AddSession(session)
var msg packet.RAW
for {
if err := session.Receive(&msg); err != nil {
break
}
module.ReceiveMessage(session, msg)
}
})
}
示例3: getPort
func getPort() {
//端口号
gateway_ip = cfg.GetValue("gateway_ip")
gateway_port = cfg.GetValue("gateway_port")
global.ServerName = "GateServer[" + gateway_port + "]"
transfer_ip = cfg.GetValue("transfer_ip")
transfer_port = cfg.GetValue("transfer_port")
}
示例4: getPort
func getPort() {
var s int
flag.IntVar(&s, "s", 0, "tcp listen port")
flag.Parse()
if s == 0 {
ERR("please set gameserver port")
os.Exit(-1)
}
game_ip = cfg.GetValue("game_ip_" + strconv.Itoa(s))
game_port = cfg.GetValue("game_port_" + strconv.Itoa(s))
global.ServerName = "GameServer[" + game_port + "]"
}
示例5: init
func init() {
if cfg.GetValue("debug") == "true" {
debug_open = true
}
logs = make(map[string]int64)
}
示例6: startLocalServer
func startLocalServer() {
//连接Redis
redisProxyErr := redisProxy.InitClient(cfg.GetValue("redis_ip"), cfg.GetValue("redis_port"), cfg.GetValue("redis_pwd"))
checkError(redisProxyErr)
//开启DB
db.Init()
//开启同步DB数据到数据库
dbProxy.StartSysDB()
//开启客户端监听
addr := "0.0.0.0:" + local_port
err := global.Listener("tcp", addr, global.PackCodecType_UnSafe,
func(session *link.Session) {
global.AddSession(session)
},
gameProxy.MsgDispatch,
)
checkError(err)
}
示例7: main
func main() {
defer func() {
if x := recover(); x != nil {
ERR("caught panic in main()", x)
}
}()
// 获取监听端口
getPort()
//启动
global.Startup(global.ServerName, "login_log", nil)
//连接TransferServer
err := transferProxy.InitClient(cfg.GetValue("transfer_ip"), cfg.GetValue("transfer_port"))
checkError(err)
//连接DB
dbProxyErr := dbProxy.InitClient(cfg.GetValue("db_ip"), cfg.GetValue("db_port"))
checkError(dbProxyErr)
//连接Redis
redisProxyErr := redisProxy.InitClient(cfg.GetValue("redis_ip"), cfg.GetValue("redis_port"))
checkError(redisProxyErr)
//保持进程
global.Run()
}
示例8: Init
//数据库初始化
func Init() {
hostname := cfg.GetValue("mysql_hostname")
port := cfg.GetValue("mysql_port")
username := cfg.GetValue("mysql_username")
password := cfg.GetValue("mysql_password")
database := cfg.GetValue("mysql_database")
charset := cfg.GetValue("mysql_charset")
sqlDb, err := sql.Open("mysql", username+":"+password+"@tcp("+hostname+":"+port+")/"+database+"?charset="+charset)
if err != nil {
ERR("Sql Open Error", err)
}
sqlDb.SetMaxOpenConns(5000)
sqlDb.SetMaxIdleConns(1000)
err = sqlDb.Ping()
if err != nil {
ERR("Sql Ping Error", err)
}
DBOrm = new(Model)
DBOrm.db = sqlDb
INFO("DB Open Success")
}
示例9: init
func init() {
if cfg.GetValue("debug") == "true" {
debug_open = true
}
}
示例10: Test_gateway
func Test_gateway(t *testing.T) {
DEBUG("消息通信测试")
var wg sync.WaitGroup
var successNum uint32
for i := 0; i < 3000; i++ {
wg.Add(1)
go func(flag int) {
// if flag != 0 && RandomInt31n(100) < 50 {
// flag -= 1
// }
defer wg.Done()
var count uint32 = 0
var userName string = "User" + strconv.Itoa(flag)
//超时处理
timerFunc := func() {
ERR("失败:", userName, count)
}
var timer *time.Timer = time.AfterFunc(10*time.Second, timerFunc)
//连接服务器
client, err := link.ConnectTimeout("tcp", "0.0.0.0:"+cfg.GetValue("gateway_port"), time.Second*3, protocol)
if !unitest.NotError(t, err) {
return
}
defer client.Close()
count += 1
//接收服务器连接成功消息
var revMsg packet.RAW
// err = client.Receive(&revMsg)
// if !unitest.NotError(t, err) {
// return
// }
// msg := &gameProto.ConnectSuccessS2C{}
// proto.Unmarshal(revMsg[2:], msg)
// DEBUG(binary.GetUint16LE(revMsg[:2]), msg)
count += 1
//发送登录消息
send_msg := createLoginBytes(userName)
// DEBUG("发送数据:", flag, send_msg)
err = client.Send(send_msg)
if !unitest.NotError(t, err) {
return
}
count += 1
//接受登录成功消息
err = client.Receive(&revMsg)
if !unitest.NotError(t, err) {
return
}
// DEBUG(binary.GetUint16LE(revMsg[:2]))
msg1 := &gameProto.UserLoginS2C{}
proto.Unmarshal(revMsg[2:], msg1)
count += 1
if !unitest.Pass(t, msg1.GetUserID() > 0) {
return
}
count += 1
//发送获取用户信息消息
if msg1.GetUserID() != 0 {
err = client.Send(createGetUserInfoBytes(msg1.GetUserID()))
if !unitest.NotError(t, err) {
return
}
count += 1
//接受用户信息消息
err = client.Receive(&revMsg)
if !unitest.NotError(t, err) {
return
}
count += 1
if binary.GetUint16LE(revMsg[:2]) == gameProto.ID_ErrorMsgS2C {
msg2 := &gameProto.ErrorMsgS2C{}
proto.Unmarshal(revMsg[2:], msg2)
// DEBUG(binary.GetUint16LE(revMsg[:2]), msg2)
} else {
msg2 := &gameProto.GetUserInfoS2C{}
proto.Unmarshal(revMsg[2:], msg2)
// DEBUG(binary.GetUint16LE(revMsg[:2]), msg2)
successNum += 1
DEBUG("成功:", userName, msg1.GetUserID(), successNum)
}
}
//.........这里部分代码省略.........