From c0fb80dd05911db0551491cc71a798e70ccb675c Mon Sep 17 00:00:00 2001 From: azw Date: Sun, 20 Aug 2023 15:36:53 +0800 Subject: [PATCH] 1 --- app.go | 4 +++- constant.go | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app.go b/app.go index 1f0fb83..ed0c647 100644 --- a/app.go +++ b/app.go @@ -52,6 +52,7 @@ type app struct { imMsgHandlers [1024]func(q5.Args) maxRunDelay int64 maxScheduleTime int64 + uuid q5.Uuid userApp UserApp } @@ -81,6 +82,7 @@ func (this *app) init(userApp UserApp) { this.instanceId = int32(tmpInstanceId) flag.Parse() } + this.uuid.SetMachineId((this.nodeId - 1) * MAX_NODE_ID + this.instanceId) this.loopCond = sync.NewCond(new(sync.Mutex)) this.chGoLoopTimerExit = make(chan int) this.chGoLoopWait = make(chan int64) @@ -124,7 +126,7 @@ func (this *app) run() { } func (this *app) NewUuid() int64 { - return 0 + return this.uuid.Generate() } func (this *app) GetInstanceId() int32 { diff --git a/constant.go b/constant.go index 15ba654..65f4069 100644 --- a/constant.go +++ b/constant.go @@ -7,3 +7,6 @@ const ( const ( WSP_SS_MAX_MSGID = 100 ) + +const MAX_NODE_ID = 8 +const MAX_INSTANCE_ID = 500