當前位置: 首頁>>代碼示例>>Golang>>正文


Golang cfg.GetValue函數代碼示例

本文整理匯總了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()
}
開發者ID:yicaoyimuys,項目名稱:GoGameServer,代碼行數:31,代碼來源:main.go

示例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)
		}
	})
}
開發者ID:youxidev,項目名稱:GoGameServer,代碼行數:28,代碼來源:main.go

示例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")
}
開發者ID:yicaoyimuys,項目名稱:GoGameServer,代碼行數:9,代碼來源:main.go

示例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 + "]"
}
開發者ID:youxidev,項目名稱:GoGameServer,代碼行數:12,代碼來源:main.go

示例5: init

func init() {
	if cfg.GetValue("debug") == "true" {
		debug_open = true
	}

	logs = make(map[string]int64)
}
開發者ID:yicaoyimuys,項目名稱:GoGameServer,代碼行數:7,代碼來源:debug.go

示例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)
}
開發者ID:yicaoyimuys,項目名稱:GoGameServer,代碼行數:21,代碼來源:main.go

示例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()
}
開發者ID:youxidev,項目名稱:GoGameServer,代碼行數:28,代碼來源:main.go

示例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")
}
開發者ID:yicaoyimuys,項目名稱:GoGameServer,代碼行數:26,代碼來源:mysql.go

示例9: init

func init() {
	if cfg.GetValue("debug") == "true" {
		debug_open = true
	}
}
開發者ID:yicaoyimuys,項目名稱:GoGameServer,代碼行數:5,代碼來源:export.go

示例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)
				}
			}

//.........這裏部分代碼省略.........
開發者ID:youxidev,項目名稱:GoGameServer,代碼行數:101,代碼來源:gw_test.go


注:本文中的tools/cfg.GetValue函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。