This commit is contained in:
azw 2023-08-20 15:36:53 +08:00
parent dd20317307
commit c0fb80dd05
2 changed files with 6 additions and 1 deletions

4
app.go
View File

@ -52,6 +52,7 @@ type app struct {
imMsgHandlers [1024]func(q5.Args) imMsgHandlers [1024]func(q5.Args)
maxRunDelay int64 maxRunDelay int64
maxScheduleTime int64 maxScheduleTime int64
uuid q5.Uuid
userApp UserApp userApp UserApp
} }
@ -81,6 +82,7 @@ func (this *app) init(userApp UserApp) {
this.instanceId = int32(tmpInstanceId) this.instanceId = int32(tmpInstanceId)
flag.Parse() flag.Parse()
} }
this.uuid.SetMachineId((this.nodeId - 1) * MAX_NODE_ID + this.instanceId)
this.loopCond = sync.NewCond(new(sync.Mutex)) this.loopCond = sync.NewCond(new(sync.Mutex))
this.chGoLoopTimerExit = make(chan int) this.chGoLoopTimerExit = make(chan int)
this.chGoLoopWait = make(chan int64) this.chGoLoopWait = make(chan int64)
@ -124,7 +126,7 @@ func (this *app) run() {
} }
func (this *app) NewUuid() int64 { func (this *app) NewUuid() int64 {
return 0 return this.uuid.Generate()
} }
func (this *app) GetInstanceId() int32 { func (this *app) GetInstanceId() int32 {

View File

@ -7,3 +7,6 @@ const (
const ( const (
WSP_SS_MAX_MSGID = 100 WSP_SS_MAX_MSGID = 100
) )
const MAX_NODE_ID = 8
const MAX_INSTANCE_ID = 500