1
This commit is contained in:
parent
f38d0d1419
commit
2b5498f808
41
app.go
41
app.go
@ -9,8 +9,18 @@ import (
|
||||
"q5"
|
||||
)
|
||||
|
||||
type F5App interface {
|
||||
type App interface {
|
||||
GetPkgName() string
|
||||
NewUuid() int64
|
||||
GetInstanceId() int32
|
||||
GetNodeId() int32
|
||||
GetZoneId() int32
|
||||
HasFlag(int32) bool
|
||||
AddIMMsg(uint16, q5.Args)
|
||||
RegisterIMMsgHandle(uint16, func(uint16,q5.Args))
|
||||
NotifyLoopCond()
|
||||
NowUnix() int64
|
||||
NowUnixMilli() int64
|
||||
}
|
||||
|
||||
type UserApp interface {
|
||||
@ -21,8 +31,9 @@ type UserApp interface {
|
||||
}
|
||||
|
||||
type app struct {
|
||||
nodeId int
|
||||
instanceId int
|
||||
zoneId int32
|
||||
nodeId int32
|
||||
instanceId int32
|
||||
terminated bool
|
||||
pkgName string
|
||||
flags map[int32]int32
|
||||
@ -37,7 +48,7 @@ type app struct {
|
||||
chGoLoopWait chan int64
|
||||
nowTime time.Time
|
||||
nowUnixNano int64
|
||||
imMsgHandlers [1024]func(int16, q5.Args)
|
||||
imMsgHandlers [1024]func(uint16, q5.Args)
|
||||
maxRunDelay int64
|
||||
maxScheduleTime int64
|
||||
userApp UserApp
|
||||
@ -59,8 +70,8 @@ func (this *app) init(userApp UserApp) {
|
||||
_SysLog.Init()
|
||||
_TgLog = new(TGLog_)
|
||||
_TgLog.Init()
|
||||
flag.IntVar(&this.nodeId, "n", 0, "node id")
|
||||
flag.IntVar(&this.instanceId, "i", 0, "instance id")
|
||||
//flag.IntVar(&this.nodeId, "n", 0, "node id")
|
||||
//flag.IntVar(&this.instanceId, "i", 0, "instance id")
|
||||
flag.Parse()
|
||||
this.loopCond = sync.NewCond(new(sync.Mutex))
|
||||
this.chGoLoopTimerExit = make(chan int)
|
||||
@ -104,19 +115,23 @@ func (this *app) NewUuid() int64 {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (this *app) GetInstanceId() uint32 {
|
||||
return uint32(this.instanceId)
|
||||
func (this *app) GetInstanceId() int32 {
|
||||
return this.instanceId
|
||||
}
|
||||
|
||||
func (this *app) GetNodeId() uint32 {
|
||||
return uint32(this.nodeId)
|
||||
func (this *app) GetNodeId() int32 {
|
||||
return this.nodeId
|
||||
}
|
||||
|
||||
func (this *app) GetZoneId() int32 {
|
||||
return this.nodeId
|
||||
}
|
||||
|
||||
func (this *app) GetPkgName() string {
|
||||
return this.pkgName
|
||||
}
|
||||
|
||||
func (this *app) SetPkgName(pkgName string) {
|
||||
func (this *app) setPkgName(pkgName string) {
|
||||
this.pkgName = pkgName
|
||||
}
|
||||
|
||||
@ -125,7 +140,7 @@ func (this *app) HasFlag(flag int32) bool {
|
||||
return ok
|
||||
}
|
||||
|
||||
func (this *app) AddIMMsg(msgId int16, params q5.Args) {
|
||||
func (this *app) AddIMMsg(msgId uint16, params q5.Args) {
|
||||
p := new(IMMsgNode)
|
||||
p.msgId = msgId
|
||||
p.params = params
|
||||
@ -143,7 +158,7 @@ func (this *app) AddIMMsg(msgId int16, params q5.Args) {
|
||||
this.loopCond.Broadcast()
|
||||
}
|
||||
|
||||
func (this *app) RegisterIMMsgHandle(msgId int16, handle func(int16,q5.Args)) {
|
||||
func (this *app) RegisterIMMsgHandle(msgId uint16, handle func(uint16,q5.Args)) {
|
||||
this.imMsgHandlers[msgId] = handle
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ func TgLog() *TGLog_ {
|
||||
return _TgLog
|
||||
}
|
||||
|
||||
func GetApp() F5App {
|
||||
func GetApp() App {
|
||||
return _app
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user