This commit is contained in:
aozhiwei 2023-08-12 13:36:51 +08:00
parent 43b1271606
commit 8d07e15209
6 changed files with 22 additions and 13 deletions

View File

@ -26,9 +26,10 @@ func (this *App_) Init() {
this.App_.Init(this.Update) this.App_.Init(this.Update)
this.msgList.Init(nil) this.msgList.Init(nil)
this.workList.Init(nil) this.workList.Init(nil)
f5.LoadMetaTable(mt.Table)
HandlerMgr.Init() HandlerMgr.Init()
WSPListener.Init() WSPListener.Init()
go this.goReportServerState(); go this.goReportServerState()
} }
func (this *App_) UnInit() { func (this *App_) UnInit() {
@ -86,10 +87,7 @@ func (this *App_) addNetMsg(hdr *f5.MsgHdr) {
this.msgList.AddTail(&hdr.Entry); this.msgList.AddTail(&hdr.Entry);
} }
{ {
v := mt.ServerIdTable{} mt.Table.Server.GetById(0)
v.Traverse(func (*mt.Server) {
})
} }
this.NotifyLoopCond() this.NotifyLoopCond()
} }

View File

@ -2,5 +2,9 @@ module mt
go 1.20 go 1.20
require mtb v1.0.0
require ( require (
) )
replace mtb => ../mtb

View File

@ -1,6 +1,5 @@
package mtb package mtb
type Server struct { type Server struct {
listen_port int32 listen_port int32
} }
@ -8,3 +7,4 @@ type Server struct {
func (this *Server) GetListenPort() int32 { func (this *Server) GetListenPort() int32 {
return this.listen_port return this.listen_port
} }

2
third_party/f5 vendored

@ -1 +1 @@
Subproject commit 0cea5671752bc0753d61aae993b8aa2b0df0ae18 Subproject commit 2282591789752dfad7522c2c5068ff9d8d7cc9df

2
third_party/q5 vendored

@ -1 +1 @@
Subproject commit 6a998e6eea5c11ebc57df5b35d1d5a6fc122d0f8 Subproject commit 490774a7a352b1209d40346bb254556ea194814e

View File

@ -175,7 +175,9 @@ func init() {
async genMtbAutoGen() { async genMtbAutoGen() {
let data = `package mtb let data = `package mtb
import (
"f5"
)
`; `;
this.mtPb.nested.mt.nestedArray.forEach( this.mtPb.nested.mt.nestedArray.forEach(
(item) => { (item) => {
@ -183,7 +185,7 @@ func init() {
item.fieldsArray.forEach item.fieldsArray.forEach
( (
(item2, index) => { (item2, index) => {
data += ` f5.BaseMetaTableElement\n`;
data += ` ${item2.name} ` + this.dumpClassField(item, item2, index) + `\n`; data += ` ${item2.name} ` + this.dumpClassField(item, item2, index) + `\n`;
} }
); );
@ -196,7 +198,7 @@ func init() {
item.fieldsArray.forEach item.fieldsArray.forEach
( (
(item2, index) => { (item2, index) => {
const newName = this.converCaseName(item2.name); const newName = this.converUpperCamelCaseName(item2.name);
data += `func (this *${item.name}) Get${newName}() ` + data += `func (this *${item.name}) Get${newName}() ` +
this.dumpClassField(item, item2, index) + ` {\n`; this.dumpClassField(item, item2, index) + ` {\n`;
data += ` return this.${item2.name}\n`; data += ` return this.${item2.name}\n`;
@ -233,7 +235,12 @@ func init() {
); );
this.mtPb.nested.mt.nestedArray.forEach( this.mtPb.nested.mt.nestedArray.forEach(
(item) => { (item) => {
data += `func (this *${item.name}RawTable) Traverse(cb func (*${item.name})) {\n`; data += `func (this *${item.name}RawTable) Traverse(cb func (*${item.name}) bool) {\n`;
data += ` for _, val := range this.rawList {\n`;
data += ` if !cb(val) {\n`;
data += ` break\n`;
data += ` }\n`;
data += ` }\n`;
data += '}\n\n'; data += '}\n\n';
data += `func (this *${item.name}IdTable) GetById(id int64) *${item.name} {\n`; data += `func (this *${item.name}IdTable) GetById(id int64) *${item.name} {\n`;
data += ` if v, ok := this.idHash[id]; ok {\n`; data += ` if v, ok := this.idHash[id]; ok {\n`;
@ -297,7 +304,7 @@ func init() {
} }
} }
converCaseName(name) { converUpperCamelCaseName(name) {
let newName = ''; let newName = '';
let preIs_ = false; let preIs_ = false;
for (let i = 0; i < name.length; ++i) { for (let i = 0; i < name.length; ++i) {