mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-08 19:16:35 +08:00
Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun
This commit is contained in:
@@ -37,3 +37,12 @@ type UserTokenResp struct {
|
||||
CommResp
|
||||
UserToken UserTokenInfo `json:"data"`
|
||||
}
|
||||
|
||||
type ParseTokenReq struct {
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
}
|
||||
|
||||
type ParseTokenResp struct {
|
||||
CommResp
|
||||
ExpireTime int64 `json:"token" binding:"required"`
|
||||
}
|
||||
|
||||
@@ -267,3 +267,5 @@ func GroupIsBanPrivateChat(status int32) bool {
|
||||
const BigVersion = "v3"
|
||||
|
||||
const LogFileName = "OpenIM.log"
|
||||
|
||||
const StatisticsTimeInterval = 10
|
||||
|
||||
@@ -135,9 +135,19 @@ func GetUserIDFromToken(token string, operationID string) (bool, string, string)
|
||||
log.Error(operationID, "ParseToken failed, ", err.Error(), token)
|
||||
return false, "", err.Error()
|
||||
}
|
||||
log.Debug(operationID, "token claims.ExpiresAt.Second() ", claims.ExpiresAt.Unix())
|
||||
return true, claims.UID, ""
|
||||
}
|
||||
|
||||
func GetUserIDFromTokenExpireTime(token string, operationID string) (bool, string, string, int64) {
|
||||
claims, err := ParseToken(token, operationID)
|
||||
if err != nil {
|
||||
log.Error(operationID, "ParseToken failed, ", err.Error(), token)
|
||||
return false, "", err.Error(), 0
|
||||
}
|
||||
return true, claims.UID, "", claims.ExpiresAt.Unix()
|
||||
}
|
||||
|
||||
func ParseTokenGetUserID(token string, operationID string) (error, string) {
|
||||
claims, err := ParseToken(token, operationID)
|
||||
if err != nil {
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
)
|
||||
|
||||
type Statistics struct {
|
||||
Count *uint64
|
||||
AllCount *uint64
|
||||
ModuleName string
|
||||
PrintArgs string
|
||||
SleepTime int
|
||||
@@ -17,16 +17,16 @@ func (s *Statistics) output() {
|
||||
defer t.Stop()
|
||||
var sum uint64
|
||||
for {
|
||||
sum = *s.Count
|
||||
sum = *s.AllCount
|
||||
select {
|
||||
case <-t.C:
|
||||
}
|
||||
log.NewWarn("", " system stat ", s.ModuleName, s.PrintArgs, *s.Count-sum, "total:", *s.Count)
|
||||
log.NewWarn("", " system stat ", s.ModuleName, s.PrintArgs, *s.AllCount-sum, "total:", *s.AllCount)
|
||||
}
|
||||
}
|
||||
|
||||
func NewStatistics(count *uint64, moduleName, printArgs string, sleepTime int) *Statistics {
|
||||
p := &Statistics{Count: count, ModuleName: moduleName, SleepTime: sleepTime, PrintArgs: printArgs}
|
||||
func NewStatistics(allCount *uint64, moduleName, printArgs string, sleepTime int) *Statistics {
|
||||
p := &Statistics{AllCount: allCount, ModuleName: moduleName, SleepTime: sleepTime, PrintArgs: printArgs}
|
||||
go p.output()
|
||||
return p
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user