containerd/supervisor/stats.go
Michael Crosby bdeb87a090 Implement stats for containerd
This is a single endpoint that clients will poll

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2016-02-11 14:36:32 -08:00

27 lines
447 B
Go

package supervisor
import "time"
type StatsEvent struct {
s *Supervisor
}
func (h *StatsEvent) Handle(e *Event) error {
start := time.Now()
i, ok := h.s.containers[e.ID]
if !ok {
return ErrContainerNotFound
}
// TODO: use workers for this
go func() {
s, err := i.container.Stats()
if err != nil {
e.Err <- err
return
}
e.Err <- nil
e.Stat <- s
ContainerStatsTimer.UpdateSince(start)
}()
return errDeferedResponse
}