Merge pull request #210 from WeiZhang555/event-types-constant
Move event types constants into single file
This commit is contained in:
commit
c0295fac04
8 changed files with 20 additions and 8 deletions
|
@ -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,
|
||||
})
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
})
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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(),
|
||||
}
|
||||
}
|
||||
|
|
12
supervisor/types.go
Normal file
12
supervisor/types.go
Normal file
|
@ -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"
|
||||
)
|
|
@ -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:
|
||||
|
|
|
@ -68,7 +68,7 @@ func (w *worker) Start() {
|
|||
w.s.notifySubscribers(Event{
|
||||
Timestamp: time.Now(),
|
||||
ID: t.Container.ID(),
|
||||
Type: "start-container",
|
||||
Type: StateStart,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue