This commit is contained in:
aozhiwei 2024-04-28 15:49:07 +08:00
parent 9c2949041a
commit 85cacf770e

14
app.go
View File

@ -19,6 +19,7 @@ type App interface {
GetPkgName() string GetPkgName() string
NewGlobalUuid() string NewGlobalUuid() string
NewNodeUuid() int64 NewNodeUuid() int64
NewLockNodeUuid() int64
GetInstanceId() int32 GetInstanceId() int32
GetNodeId() int32 GetNodeId() int32
GetZoneId() int32 GetZoneId() int32
@ -29,6 +30,7 @@ type App interface {
GetNowSeconds() int64 GetNowSeconds() int64
GetNowMillis() int64 GetNowMillis() int64
GetNowNano() int64 GetNowNano() int64
GetRealSeconds() int64
GetTimeOffset() int32 GetTimeOffset() int32
SetTimeOffset(int32) SetTimeOffset(int32)
GetLocation() *time.Location GetLocation() *time.Location
@ -74,6 +76,8 @@ type app struct {
maxRunDelay int64 maxRunDelay int64
maxScheduleTime int64 maxScheduleTime int64
uuid q5.Uuid uuid q5.Uuid
lockUuid q5.Uuid
uuidMutex sync.RWMutex
userApp UserApp userApp UserApp
ginEngine *gin.Engine ginEngine *gin.Engine
ormDbLock sync.Mutex ormDbLock sync.Mutex
@ -195,6 +199,12 @@ func (this *app) NewNodeUuid() int64 {
return this.uuid.Generate() return this.uuid.Generate()
} }
func (this *app) NewLockNodeUuid() int64 {
defer this.uuidMutex.Unlock()
this.uuidMutex.Lock()
return this.lockUuid.Generate()
}
func (this *app) GetInstanceId() int32 { func (this *app) GetInstanceId() int32 {
return this.instanceId return this.instanceId
} }
@ -287,6 +297,10 @@ func (this *app) GetNowNano() int64 {
return this.nowUnixNano return this.nowUnixNano
} }
func (this *app) GetRealSeconds() int64 {
return time.Now().UnixNano() / int64(time.Millisecond)
}
func (this *app) GetTimeOffset() int32 { func (this *app) GetTimeOffset() int32 {
return this.timeOffset return this.timeOffset
} }