containerd/supervisor/stats.go
Michael Crosby 4e05bf491a Remove eventloop package
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2016-02-19 13:21:21 -08:00

34 lines
528 B
Go

package supervisor
import (
"time"
"github.com/docker/containerd/runtime"
)
type StatsTask struct {
baseTask
ID string
Stat chan *runtime.Stat
Err chan error
}
func (s *Supervisor) stats(t *StatsTask) error {
start := time.Now()
i, ok := s.containers[t.ID]
if !ok {
return ErrContainerNotFound
}
// TODO: use workers for this
go func() {
s, err := i.container.Stats()
if err != nil {
t.Err <- err
return
}
t.Err <- nil
t.Stat <- s
ContainerStatsTimer.UpdateSince(start)
}()
return nil
}