3dc59d565a
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
27 lines
444 B
Go
27 lines
444 B
Go
package supervisor
|
|
|
|
import "time"
|
|
|
|
type StatsTask struct {
|
|
s *Supervisor
|
|
}
|
|
|
|
func (h *StatsTask) Handle(e *Task) 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
|
|
}
|