Move to a single Event type

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
This commit is contained in:
Kenfe-Mickael Laventure 2017-02-06 08:46:37 -08:00
parent 8fbdf1c0d7
commit 31f26fed18
2 changed files with 17 additions and 13 deletions

View file

@ -50,8 +50,8 @@ var runCommand = cli.Command{
} }
defer nec.Close() defer nec.Close()
evCh := make(chan *execEvents.ContainerExitEvent, 64) evCh := make(chan *execEvents.ContainerEvent, 64)
sub, err := nec.Subscribe(execEvents.ContainersEventsSubjectSubscriber, func(e *execEvents.ContainerExitEvent) { sub, err := nec.Subscribe(execEvents.ContainersEventsSubjectSubscriber, func(e *execEvents.ContainerEvent) {
evCh <- e evCh <- e
}) })
if err != nil { if err != nil {
@ -118,8 +118,8 @@ var runCommand = cli.Command{
break eventLoop break eventLoop
} }
if e.ID == cr.Container.ID && e.PID == cr.InitProcess.Pid { if e.ID == cr.Container.ID && e.Pid == cr.InitProcess.Pid {
ec = e.StatusCode ec = e.ExitStatus
break eventLoop break eventLoop
} }
case <-time.After(1 * time.Second): case <-time.After(1 * time.Second):

View file

@ -2,16 +2,20 @@ package execution
import "time" import "time"
type ContainerEvent struct { const (
Timestamp time.Time ExitEvent = "exit"
ID string OOMEvent = "oom"
Action string CreateEvent = "create"
} StartEvent = "start"
ExecEvent = "exec-added9"
)
type ContainerExitEvent struct { type ContainerEvent struct {
ContainerEvent Timestamp time.Time
PID uint32 ID string
StatusCode uint32 Type string
Pid uint32
ExitStatus uint32
} }
const ( const (