Documentation ¶
Index ¶
- type DefaultLogger
- type Fields
- type HTTPServer
- func (httpServer *HTTPServer) GINLogger(ctx *gin.Context)
- func (httpServer *HTTPServer) GINRecovery(ctx *gin.Context)
- func (httpServer *HTTPServer) Handler(handler func(router *gin.Engine))
- func (httpServer *HTTPServer) Name() string
- func (httpServer *HTTPServer) OnChange(viper *viper.Viper)
- func (httpServer *HTTPServer) PidSavePath() string
- func (httpServer *HTTPServer) Restart() error
- func (httpServer *HTTPServer) Run()
- func (httpServer *HTTPServer) SetLogger(logger ILogger)
- func (httpServer *HTTPServer) Start()
- func (httpServer *HTTPServer) Stop() error
- type Handler
- type ILogger
- type Prometheus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DefaultLogger ¶
type DefaultLogger struct {
// contains filtered or unexported fields
}
DefaultLogger default logger
func NewDefaultLogger ¶
func NewDefaultLogger(args Fields) *DefaultLogger
NewDefaultLogger default logger
func (*DefaultLogger) Fatalln ¶
func (d *DefaultLogger) Fatalln(args ...interface{})
Fatalln fatalln
func (*DefaultLogger) Println ¶
func (d *DefaultLogger) Println(args ...interface{})
Println println...
func (DefaultLogger) WithFields ¶
func (d DefaultLogger) WithFields(fields Fields) ILogger
WithFields Set other information to be recorded in the log, and a new object will be returned
type HTTPServer ¶
type HTTPServer struct { PID string `mapstructure:"pid"` ServiceName string `mapstructure:"name"` Addr string `mapstructure:"addr"` ShutdownWaitDuration string `mapstructure:"shutdown_wait_duration"` GinMode string `mapstructure:"gin_mode"` // contains filtered or unexported fields }
HTTPServer default http server
func NewHTTPServer ¶
func NewHTTPServer(logger ILogger) *HTTPServer
NewHTTPServer simply initialize the HTTP server
func (*HTTPServer) GINLogger ¶
func (httpServer *HTTPServer) GINLogger(ctx *gin.Context)
GINLogger 自定义的GIN日志处理中间件
func (*HTTPServer) GINRecovery ¶
func (httpServer *HTTPServer) GINRecovery(ctx *gin.Context)
GINRecovery gin recovery handler
func (*HTTPServer) Handler ¶
func (httpServer *HTTPServer) Handler(handler func(router *gin.Engine))
Handler use this method to register the handler of gin
func (*HTTPServer) OnChange ¶
func (httpServer *HTTPServer) OnChange(viper *viper.Viper)
OnChange When the configuration file changes, the service will be listened again
func (*HTTPServer) PidSavePath ¶
func (httpServer *HTTPServer) PidSavePath() string
PidSavePath get pid save path
func (*HTTPServer) Run ¶
func (httpServer *HTTPServer) Run()
Run start server listen, In fact, it is directly called globally daemon.Run() is an effect
func (*HTTPServer) SetLogger ¶
func (httpServer *HTTPServer) SetLogger(logger ILogger)
SetLogger set custom logger
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler router
func NewHandler ¶
func NewHandler(mode string, recovery, ginLogger gin.HandlerFunc) *Handler
NewHandler init handler
func (*Handler) Group ¶
func (*Handler) Group(relativePath string, handlers ...func(router gin.IRouter)) func(router gin.IRouter)
Group router group
type ILogger ¶
type ILogger interface { Println(args ...interface{}) Error(args ...interface{}) Info(args ...interface{}) Fatalln(args ...interface{}) WithFields(fields Fields) ILogger }
ILogger methods to be implemented for loggers injected into HTTPServer
type Prometheus ¶
type Prometheus struct{}
Prometheus 服务指标统计
var ( // Metrics 指标统计 Metrics Prometheus )
func (Prometheus) HTTPRequestURICounter ¶
func (Prometheus) HTTPRequestURICounter(uri string)
HTTPRequestURICounter http 请求资源计数
func (Prometheus) HTTPResponseStatusCounter ¶
func (Prometheus) HTTPResponseStatusCounter(uri string, status int)
HTTPResponseStatusCounter http 响应状态码统计
func (Prometheus) RequestPanicCounter ¶
func (Prometheus) RequestPanicCounter(uri string)
RequestPanicCounter http 发生崩溃的统计