2015-12-17 16:07:04 -08:00
|
|
|
package supervisor
|
2015-11-30 15:34:01 -08:00
|
|
|
|
2015-12-14 14:43:00 -08:00
|
|
|
type StatsEvent struct {
|
|
|
|
s *Supervisor
|
|
|
|
}
|
|
|
|
|
|
|
|
type UnsubscribeStatsEvent struct {
|
|
|
|
s *Supervisor
|
|
|
|
}
|
|
|
|
|
2015-12-16 09:39:28 -08:00
|
|
|
type StopStatsEvent struct {
|
|
|
|
s *Supervisor
|
|
|
|
}
|
|
|
|
|
2015-12-14 14:43:00 -08:00
|
|
|
func (h *StatsEvent) Handle(e *Event) error {
|
|
|
|
i, ok := h.s.containers[e.ID]
|
|
|
|
if !ok {
|
|
|
|
return ErrContainerNotFound
|
|
|
|
}
|
|
|
|
e.Stats = h.s.statsCollector.collect(i.container)
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (h *UnsubscribeStatsEvent) Handle(e *Event) error {
|
|
|
|
i, ok := h.s.containers[e.ID]
|
|
|
|
if !ok {
|
|
|
|
return ErrContainerNotFound
|
|
|
|
}
|
|
|
|
h.s.statsCollector.unsubscribe(i.container, e.Stats)
|
|
|
|
return nil
|
|
|
|
}
|
2015-12-16 09:39:28 -08:00
|
|
|
|
|
|
|
func (h *StopStatsEvent) Handle(e *Event) error {
|
|
|
|
i, ok := h.s.containers[e.ID]
|
|
|
|
if !ok {
|
|
|
|
return ErrContainerNotFound
|
|
|
|
}
|
|
|
|
h.s.statsCollector.stopCollection(i.container)
|
|
|
|
return nil
|
|
|
|
}
|