From bfff40dccd63824d33340e8ccb14bc98109cee20 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 30 Aug 2024 15:52:55 +0800 Subject: [PATCH] 1 --- bin/gamesapi/config/confdb.mysql.json | 9 +++ server/gamesapi/mt/ConfDb.go | 15 +++++ server/gamesapi/mt/export.go | 7 +++ server/gamesapi/mtb/mtb.auto_gen.go | 79 +++++++++++++++++++++++++++ server/gamesapi/proto/mt.proto | 11 ++++ 5 files changed, 121 insertions(+) create mode 100644 bin/gamesapi/config/confdb.mysql.json create mode 100644 server/gamesapi/mt/ConfDb.go diff --git a/bin/gamesapi/config/confdb.mysql.json b/bin/gamesapi/config/confdb.mysql.json new file mode 100644 index 00000000..c3477c54 --- /dev/null +++ b/bin/gamesapi/config/confdb.mysql.json @@ -0,0 +1,9 @@ +{ + "host": "mysql-test.kingsome.cn", + "port": 3306, + "user": "root", + "passwd": "keji178", + "database": "confdb_dev_1", + "max_open_conns": 1, + "max_idle_conns": 1 +} diff --git a/server/gamesapi/mt/ConfDb.go b/server/gamesapi/mt/ConfDb.go new file mode 100644 index 00000000..ab948bf7 --- /dev/null +++ b/server/gamesapi/mt/ConfDb.go @@ -0,0 +1,15 @@ +package mt + +import ( + "f5" + "main/mtb" +) + +type ConfDb struct { + mtb.ConfDb +} + +type ConfDbTable struct { + f5.IdMetaTable[ConfDb] + selfConf *ConfDb +} diff --git a/server/gamesapi/mt/export.go b/server/gamesapi/mt/export.go index 36b98790..c23badaa 100644 --- a/server/gamesapi/mt/export.go +++ b/server/gamesapi/mt/export.go @@ -7,6 +7,7 @@ import ( type table struct { GamesapiCluster *GamesapiClusterTable Config *ConfigTable + ConfDb *ConfDbTable } var Table = f5.New(func(this *table) { @@ -19,4 +20,10 @@ var Table = f5.New(func(this *table) { this.FileName = "../config/config.json" this.PrimKey = "" }) + + this.ConfDb = f5.New(func(this *ConfDbTable) { + this.FileName = "../config/confdb.mysql.json" + this.PrimKey = "" + }) + }) diff --git a/server/gamesapi/mtb/mtb.auto_gen.go b/server/gamesapi/mtb/mtb.auto_gen.go index 5e7f8578..337b9e43 100644 --- a/server/gamesapi/mtb/mtb.auto_gen.go +++ b/server/gamesapi/mtb/mtb.auto_gen.go @@ -27,6 +27,19 @@ type Config struct { _flags2_ uint64 } +type ConfDb struct { + host string + port int32 + user string + passwd string + database string + max_open_conns int32 + max_idle_conns int32 + + _flags1_ uint64 + _flags2_ uint64 +} + func (this *GamesapiCluster) GetInstanceId() int32 { return this.instance_id } @@ -115,6 +128,62 @@ func (this *Config) HasRedirectSecretKey() bool { return (this._flags1_ & (uint64(1) << 8)) > 0 } +func (this *ConfDb) GetHost() string { + return this.host +} + +func (this *ConfDb) HasHost() bool { + return (this._flags1_ & (uint64(1) << 1)) > 0 +} + +func (this *ConfDb) GetPort() int32 { + return this.port +} + +func (this *ConfDb) HasPort() bool { + return (this._flags1_ & (uint64(1) << 2)) > 0 +} + +func (this *ConfDb) GetUser() string { + return this.user +} + +func (this *ConfDb) HasUser() bool { + return (this._flags1_ & (uint64(1) << 3)) > 0 +} + +func (this *ConfDb) GetPasswd() string { + return this.passwd +} + +func (this *ConfDb) HasPasswd() bool { + return (this._flags1_ & (uint64(1) << 4)) > 0 +} + +func (this *ConfDb) GetDatabase() string { + return this.database +} + +func (this *ConfDb) HasDatabase() bool { + return (this._flags1_ & (uint64(1) << 5)) > 0 +} + +func (this *ConfDb) GetMaxOpenConns() int32 { + return this.max_open_conns +} + +func (this *ConfDb) HasMaxOpenConns() bool { + return (this._flags1_ & (uint64(1) << 6)) > 0 +} + +func (this *ConfDb) GetMaxIdleConns() int32 { + return this.max_idle_conns +} + +func (this *ConfDb) HasMaxIdleConns() bool { + return (this._flags1_ & (uint64(1) << 7)) > 0 +} + func (this *GamesapiCluster) LoadFromKv(kv map[string]interface{}) { f5.ReadMetaTableField(&this.instance_id, "instance_id", &this._flags1_, 1, kv) @@ -132,3 +201,13 @@ func (this *Config) LoadFromKv(kv map[string]interface{}) { f5.ReadMetaTableField(&this.request_over_time, "request_over_time", &this._flags1_, 7, kv) f5.ReadMetaTableField(&this.redirect_secret_key, "redirect_secret_key", &this._flags1_, 8, kv) } + +func (this *ConfDb) LoadFromKv(kv map[string]interface{}) { + f5.ReadMetaTableField(&this.host, "host", &this._flags1_, 1, kv) + f5.ReadMetaTableField(&this.port, "port", &this._flags1_, 2, kv) + f5.ReadMetaTableField(&this.user, "user", &this._flags1_, 3, kv) + f5.ReadMetaTableField(&this.passwd, "passwd", &this._flags1_, 4, kv) + f5.ReadMetaTableField(&this.database, "database", &this._flags1_, 5, kv) + f5.ReadMetaTableField(&this.max_open_conns, "max_open_conns", &this._flags1_, 6, kv) + f5.ReadMetaTableField(&this.max_idle_conns, "max_idle_conns", &this._flags1_, 7, kv) +} diff --git a/server/gamesapi/proto/mt.proto b/server/gamesapi/proto/mt.proto index f5392619..2dfd5885 100644 --- a/server/gamesapi/proto/mt.proto +++ b/server/gamesapi/proto/mt.proto @@ -20,3 +20,14 @@ message Config optional int32 request_over_time = 7; optional string redirect_secret_key = 8; } + +message ConfDb +{ + optional string host = 1; + optional int32 port = 2; + optional string user = 3; + optional string passwd = 4; + optional string database = 5; + optional int32 max_open_conns = 6; + optional int32 max_idle_conns = 7; +}