This commit is contained in:
aozhiwei 2020-10-22 10:56:22 +08:00
parent 5f48088648
commit 9a4e4cea17
6 changed files with 136 additions and 0 deletions

32
server/analyseapi/app.go Normal file
View File

@ -0,0 +1,32 @@
package main
import "q5"
import "f5"
import "fmt"
import "time"
type App_ struct {
f5.App_
}
var App *App_
func (this *App_) Init() {
f5.App = &this.App_
this.App_.Init()
G.MetaMgr = &MetaMgr{}
G.MetaMgr.Init()
f5.Timer().AddRepeatTimer(
1000 * 5,
func (params *q5.XParams) {
},
func (params *q5.XParams) {
fmt.Println("hello", time.Now())
})
}
func (this *App_) UnInit() {
G.MetaMgr.UnInit()
this.App_.UnInit()
}

23
server/analyseapi/go.mod Normal file
View File

@ -0,0 +1,23 @@
module analyseapi
go 1.11
require q5 v1.0.0
require f5 v1.0.0
require mt v1.0.0
require (
github.com/golang/protobuf v1.4.2
google.golang.org/protobuf v1.23.0
im v1.0.0
)
replace q5 => ../../third_party/q5
replace f5 => ../../third_party/f5
replace im => ../../third_party/f5/im
replace mt => ./mt

View File

@ -0,0 +1,11 @@
compile:
@. /etc/profile
protoc --proto_path=../tools/protobuild --go_out=./mt ../tools/protobuild/mt.proto
@export GOPROXY=https://goproxy.io
@go build -gcflags=all="-N -l" -o ../bin/analyseapi
@echo "compile done"
clean:
@rm -f ../bin/analyseapi
@echo "clean done"

View File

@ -0,0 +1,50 @@
package main
import "f5"
import "mt"
//import "fmt"
//import "reflect"
const (
MT_SERVER_INFO = 0
MT_MAX
)
type MetaMgr struct {
f5.MetaMgr
}
func (this *MetaMgr) Init() {
this.MetaMgr.Init()
metaClasses := &[]f5.MetaClass{
f5.MetaClass{
PrimKey: "InstanceId",
FileName: "/var/data/conf_test/mail/mail.cluster.json",
Idx: MT_SERVER_INFO,
RawMeta: (*mt.ServerInfoMetas)(nil),
WrapMeta: (*MtwServerInfo)(nil)},
}
this.MetaMgr.RegisterMetaClasses(metaClasses)
}
func (this *MetaMgr) UnInit() {
this.MetaMgr.UnInit()
}
func (this *MetaMgr) GetServer(instance_id int32) *MtwServerInfo {
v, ok := this.MetaMgr.GetMetaById(MT_SERVER_INFO, instance_id).(*MtwServerInfo)
if ok {
return v
} else {
return nil
}
}
func (this *MetaMgr) GetServerList() []*MtwServerInfo {
v, ok := this.MetaMgr.GetMetaList(MT_SERVER_INFO).([]*MtwServerInfo)
if ok {
return v
} else {
return nil
}
}

View File

@ -0,0 +1,7 @@
package main
import "mt"
type MtwServerInfo struct {
*mt.ServerInfo
}

View File

@ -0,0 +1,13 @@
package mt;
message ServerInfo
{
optional int32 instance_id = 1;
optional string listen_ip = 2;
optional int32 listen_port = 3;
}
message ServerInfoMetas
{
repeated ServerInfo values = 1;
}