2015-12-18 00:07:04 +00:00
|
|
|
package supervisor
|
2015-11-30 23:34:01 +00:00
|
|
|
|
2015-12-14 22:43:00 +00:00
|
|
|
type StatsEvent struct {
|
|
|
|
s *Supervisor
|
|
|
|
}
|
|
|
|
|
|
|
|
type UnsubscribeStatsEvent struct {
|
|
|
|
s *Supervisor
|
|
|
|
}
|
|
|
|
|
2015-12-16 17:39:28 +00:00
|
|
|
type StopStatsEvent struct {
|
|
|
|
s *Supervisor
|
|
|
|
}
|
|
|
|
|
2015-12-14 22:43:00 +00: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 17:39:28 +00: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
|
|
|
|
}
|