other: 修改 server.Server 慢消息检测的异步消息判定条件为 1 秒

This commit is contained in:
kercylan98 2023-07-11 19:38:50 +08:00
parent 47b8a333eb
commit 8917326a24
1 changed files with 4 additions and 4 deletions

View File

@ -479,9 +479,9 @@ func (slf *Server) pushMessage(message *Message) {
slf.messageChannel <- message slf.messageChannel <- message
} }
func (slf *Server) low(message *Message, present time.Time) { func (slf *Server) low(message *Message, present time.Time, expect time.Duration) {
cost := time.Since(present) cost := time.Since(present)
if cost > time.Millisecond*100 { if cost > expect {
log.Warn("Server", zap.String("LowExecCost", cost.String()), zap.Any("Message", message)) log.Warn("Server", zap.String("LowExecCost", cost.String()), zap.Any("Message", message))
slf.OnMessageLowExecEvent(message, cost) slf.OnMessageLowExecEvent(message, cost)
} }
@ -516,7 +516,7 @@ func (slf *Server) dispatchMessage(msg *Message) {
if msg.t != MessageTypeAsync { if msg.t != MessageTypeAsync {
super.Handle(cancel) super.Handle(cancel)
slf.low(msg, present) slf.low(msg, present, time.Millisecond*100)
if !slf.isShutdown.Load() { if !slf.isShutdown.Load() {
slf.messagePool.Release(msg) slf.messagePool.Release(msg)
} }
@ -555,7 +555,7 @@ func (slf *Server) dispatchMessage(msg *Message) {
} }
} }
super.Handle(cancel) super.Handle(cancel)
slf.low(msg, present) slf.low(msg, present, time.Second)
if !slf.isShutdown.Load() { if !slf.isShutdown.Load() {
slf.messagePool.Release(msg) slf.messagePool.Release(msg)
} }