mirror of
https://github.com/coredns/coredns.git
synced 2025-12-08 03:15:41 -05:00
Overloaded (#1364)
* plugin/health: add 'overloaded metrics' Query our on health endpoint and record (and export as a metric) the time it takes. The Get has a 5s timeout, that, when reached, will set the metric duration to 5s. The actually call "I'm I overloaded" is left to an external entity. * README * golint and govet * and the tests
This commit is contained in:
@@ -21,9 +21,11 @@ type health struct {
|
||||
h []Healther
|
||||
sync.RWMutex
|
||||
ok bool // ok is the global boolean indicating an all healthy plugin stack
|
||||
|
||||
stop chan bool
|
||||
}
|
||||
|
||||
func (h *health) Startup() error {
|
||||
func (h *health) OnStartup() error {
|
||||
if h.Addr == "" {
|
||||
h.Addr = defAddr
|
||||
}
|
||||
@@ -51,14 +53,20 @@ func (h *health) Startup() error {
|
||||
go func() {
|
||||
http.Serve(h.ln, h.mux)
|
||||
}()
|
||||
go func() {
|
||||
h.overloaded()
|
||||
}()
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
||||
func (h *health) Shutdown() error {
|
||||
func (h *health) OnShutdown() error {
|
||||
if h.ln != nil {
|
||||
return h.ln.Close()
|
||||
}
|
||||
|
||||
h.stop <- true
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user