feat: 支持对 HTTP 服务器通过 server.WithPprof 开启 pprof
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"github.com/gin-contrib/pprof"
|
||||
"github.com/kercylan98/minotaur/utils/log"
|
||||
"github.com/kercylan98/minotaur/utils/timer"
|
||||
"go.uber.org/zap"
|
||||
@@ -170,3 +171,13 @@ func WithMessageBufferSize(size int) Option {
|
||||
srv.messagePoolSize = size
|
||||
}
|
||||
}
|
||||
|
||||
// WithPprof 通过性能分析工具PProf创建服务器
|
||||
func WithPprof(pattern ...string) Option {
|
||||
return func(srv *Server) {
|
||||
if srv.network != NetworkHttp {
|
||||
return
|
||||
}
|
||||
pprof.Register(srv.ginServer, pattern...)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user