Documentation ¶
Index ¶
- type HTTPServer
- type MuxServer
- func (ms *MuxServer) Handle(pattern string, handler http.Handler)
- func (ms *MuxServer) HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request))
- func (ms *MuxServer) RegisterLogControl(handler http.Handler)
- func (ms *MuxServer) RegisterMetrics(g prometheus.Gatherer)
- func (ms *MuxServer) RegisterProber(p *prober.HTTPProbe)
- func (ms *MuxServer) RegisterProfiler()
- func (ms *MuxServer) RunGroup(g *run.Group)
- type Option
- type OptionFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HTTPServer ¶ added in v0.2.0
type HTTPServer struct {
// contains filtered or unexported fields
}
HTTPServer is our exthttp server.
func NewHTTPServer ¶ added in v0.2.0
func NewHTTPServer(handler http.Handler, logger *log.Logger, opts ...OptionFunc) *HTTPServer
NewHTTPServer create a new HTTPServer instance.
func (*HTTPServer) Run ¶ added in v0.2.0
func (hs *HTTPServer) Run(g *run.Group, statusProber prober.Probe)
Run start http server with run group.
func (*HTTPServer) Shutdown ¶ added in v0.2.0
func (hs *HTTPServer) Shutdown(err error)
Shutdown shutdown the http server if gracePeriod set, it will shutdown gracefully.
func (*HTTPServer) Start ¶ added in v0.2.0
func (hs *HTTPServer) Start() error
Start listen and serve http server.
type MuxServer ¶
type MuxServer struct { *HTTPServer // contains filtered or unexported fields }
MuxServer 简单的 http mux server 一般用来挂载 prometheus 和 pprof. MuxServer is a simple http mux server.
func NewMuxServer ¶
func NewMuxServer(logger *log.Logger, opts ...OptionFunc) *MuxServer
NewMuxServer crate a new MuxServer instance.
func (*MuxServer) HandleFunc ¶
HandleFunc add handle function to mux server.
func (*MuxServer) RegisterLogControl ¶
RegisterLogControl register log level control routes.
func (*MuxServer) RegisterMetrics ¶
func (ms *MuxServer) RegisterMetrics(g prometheus.Gatherer)
RegisterMetrics register metrics route.
func (*MuxServer) RegisterProber ¶
RegisterProber register liveness(healthy) and readiness(ready) routes.
func (*MuxServer) RegisterProfiler ¶
func (ms *MuxServer) RegisterProfiler()
RegisterProfiler register pprof routes.
type Option ¶
type Option struct {
// contains filtered or unexported fields
}
Option is server options.
type OptionFunc ¶
type OptionFunc func(option *Option)
OptionFunc is option handler type.
func WithGracePeriod ¶
func WithGracePeriod(gracePeriod time.Duration) OptionFunc
WithGracePeriod set grace shutdown period option.
func WithServiceName ¶
func WithServiceName(name string) OptionFunc
WithServiceName set the service option.