feat: 支持对 HTTP 服务器通过 server.WithPprof 开启 pprof

This commit is contained in:
kercylan98
2023-07-08 18:09:07 +08:00
parent 1ad657799a
commit 53e91d1fce
3 changed files with 38 additions and 0 deletions

View File

@@ -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...)
}
}