2024-08-21 14:36:01 +08:00

116 lines
2.9 KiB
Go

package app
import (
"f5"
"jccommon"
"main/constant"
"main/mt"
"q5"
)
type app struct {
initCb func()
unInitCb func()
}
func (this *app) GetPkgName() string {
return "marketserver"
}
func (this *app) GetHttpListenPort() int32 {
return mt.Table.MarketServerCluster.GetHttpListenPort()
}
func (this *app) Run(initCb func(), unInitCb func()) {
this.initCb = initCb
this.unInitCb = unInitCb
f5.Run(this)
}
func (this *app) Init() {
f5.LoadMetaTable(mt.Table)
this.registerDataSources()
this.initCb()
transId := jccommon.NewTransId()
transId.Init(11, q5.ToInt32(f5.GetApp().GetRealSeconds()), 1234567, [3]int64{
1000000000123456789,
1000000000123456789,
1000000000123456789})
idStr, _ := transId.ToString()
transId2 := jccommon.NewTransId()
transId2.ParseString(idStr)
f5.GetSysLog().Info("transId1:%s", idStr)
{
idStr2, _ := transId2.ToString()
f5.GetSysLog().Info("transId2:%s", idStr2)
}
}
func (this *app) UnInit() {
this.unInitCb()
}
func (this *app) Update() {
}
func (this *app) registerDataSources() {
f5.GetGoStyleDb().RegisterDataSource(
constant.BCNFT_DB,
mt.Table.NftDb.GetById(0).GetHost(),
mt.Table.NftDb.GetById(0).GetPort(),
mt.Table.NftDb.GetById(0).GetUser(),
mt.Table.NftDb.GetById(0).GetPasswd(),
mt.Table.NftDb.GetById(0).GetDatabase(),
1,
mt.Table.NftDb.GetById(0).GetMaxOpenConns(),
mt.Table.NftDb.GetById(0).GetMaxIdleConns())
f5.GetGoStyleDb().RegisterDataSource(
constant.BCEVENT_DB,
mt.Table.NftEventDb.GetById(0).GetHost(),
mt.Table.NftEventDb.GetById(0).GetPort(),
mt.Table.NftEventDb.GetById(0).GetUser(),
mt.Table.NftEventDb.GetById(0).GetPasswd(),
mt.Table.NftEventDb.GetById(0).GetDatabase(),
1,
mt.Table.NftEventDb.GetById(0).GetMaxOpenConns(),
mt.Table.NftEventDb.GetById(0).GetMaxIdleConns())
f5.GetGoStyleDb().RegisterDataSource(
constant.GAME_DB,
mt.Table.GameDb.GetById(0).GetHost(),
mt.Table.GameDb.GetById(0).GetPort(),
mt.Table.GameDb.GetById(0).GetUser(),
mt.Table.GameDb.GetById(0).GetPasswd(),
mt.Table.GameDb.GetById(0).GetDatabase(),
1,
mt.Table.GameDb.GetById(0).GetMaxOpenConns(),
mt.Table.GameDb.GetById(0).GetMaxIdleConns())
f5.GetGoStyleDb().RegisterDataSource(
constant.ACCOUNT_DB,
mt.Table.AccountDb.GetById(0).GetHost(),
mt.Table.AccountDb.GetById(0).GetPort(),
mt.Table.AccountDb.GetById(0).GetUser(),
mt.Table.AccountDb.GetById(0).GetPasswd(),
mt.Table.AccountDb.GetById(0).GetDatabase(),
1,
mt.Table.AccountDb.GetById(0).GetMaxOpenConns(),
mt.Table.AccountDb.GetById(0).GetMaxIdleConns())
f5.GetGoStyleDb().RegisterDataSource(
constant.CONF_DB,
mt.Table.ConfDb.GetById(0).GetHost(),
mt.Table.ConfDb.GetById(0).GetPort(),
mt.Table.ConfDb.GetById(0).GetUser(),
mt.Table.ConfDb.GetById(0).GetPasswd(),
mt.Table.ConfDb.GetById(0).GetDatabase(),
1,
mt.Table.ConfDb.GetById(0).GetMaxOpenConns(),
mt.Table.ConfDb.GetById(0).GetMaxIdleConns())
}
func (this *app) HasTask() bool {
return false
}