diff --git a/supervisor/add_process.go b/supervisor/add_process.go index e76077f..93678dd 100644 --- a/supervisor/add_process.go +++ b/supervisor/add_process.go @@ -35,7 +35,7 @@ func (s *Supervisor) addProcess(t *AddProcessTask) error { t.StartResponse <- StartResponse{} s.notifySubscribers(Event{ Timestamp: time.Now(), - Type: "start-process", + Type: StateStartProcess, PID: t.PID, ID: t.ID, }) diff --git a/supervisor/delete.go b/supervisor/delete.go index ba5fbb8..fd46f38 100644 --- a/supervisor/delete.go +++ b/supervisor/delete.go @@ -23,7 +23,7 @@ func (s *Supervisor) delete(t *DeleteTask) error { } if !t.NoEvent { s.notifySubscribers(Event{ - Type: "exit", + Type: StateExit, Timestamp: time.Now(), ID: t.ID, Status: t.Status, diff --git a/supervisor/exit.go b/supervisor/exit.go index ef0b314..8f19eee 100644 --- a/supervisor/exit.go +++ b/supervisor/exit.go @@ -73,7 +73,7 @@ func (s *Supervisor) execExit(t *ExecExitTask) error { s.notifySubscribers(Event{ Timestamp: time.Now(), ID: t.ID, - Type: "exit", + Type: StateExit, PID: t.PID, Status: t.Status, }) diff --git a/supervisor/oom.go b/supervisor/oom.go index 58eb094..e204696 100644 --- a/supervisor/oom.go +++ b/supervisor/oom.go @@ -16,7 +16,7 @@ func (s *Supervisor) oom(t *OOMTask) error { s.notifySubscribers(Event{ Timestamp: time.Now(), ID: t.ID, - Type: "oom", + Type: StateOOM, }) return nil } diff --git a/supervisor/supervisor.go b/supervisor/supervisor.go index 6c582e0..665ef5b 100644 --- a/supervisor/supervisor.go +++ b/supervisor/supervisor.go @@ -207,7 +207,7 @@ func (s *Supervisor) Events(from time.Time) chan Event { } // Notify the client that from now on it's live events c <- Event{ - Type: "live", + Type: StateLive, Timestamp: time.Now(), } } diff --git a/supervisor/types.go b/supervisor/types.go new file mode 100644 index 0000000..2e36fce --- /dev/null +++ b/supervisor/types.go @@ -0,0 +1,12 @@ +package supervisor + +// State constants used in Event types +const ( + StateStart = "start-container" + StatePause = "pause" + StateResume = "resume" + StateExit = "exit" + StateStartProcess = "start-process" + StateOOM = "oom" + StateLive = "live" +) diff --git a/supervisor/update.go b/supervisor/update.go index 803d025..fe2f477 100644 --- a/supervisor/update.go +++ b/supervisor/update.go @@ -27,7 +27,7 @@ func (s *Supervisor) updateContainer(t *UpdateTask) error { } s.notifySubscribers(Event{ ID: t.ID, - Type: "resume", + Type: StateResume, Timestamp: time.Now(), }) case runtime.Paused: @@ -36,7 +36,7 @@ func (s *Supervisor) updateContainer(t *UpdateTask) error { } s.notifySubscribers(Event{ ID: t.ID, - Type: "pause", + Type: StatePause, Timestamp: time.Now(), }) default: diff --git a/supervisor/worker.go b/supervisor/worker.go index c4493ac..f41818d 100644 --- a/supervisor/worker.go +++ b/supervisor/worker.go @@ -68,7 +68,7 @@ func (w *worker) Start() { w.s.notifySubscribers(Event{ Timestamp: time.Now(), ID: t.Container.ID(), - Type: "start-container", + Type: StateStart, }) } }