Add journaling

This commit is contained in:
Michael Crosby 2015-11-10 14:24:34 -08:00
parent d34d482a5f
commit 6ff2239019
5 changed files with 115 additions and 86 deletions

View file

@ -1,59 +1,36 @@
package containerd
import "os"
import (
"os"
"time"
)
type Event interface {
String() string
type EventType string
const (
ExitEventType EventType = "exit"
StartContainerEventType EventType = "startContainer"
ContainerStartErrorEventType EventType = "startContainerError"
GetContainerEventType EventType = "getContainer"
SignalEventType EventType = "signal"
)
func NewEvent(t EventType) *Event {
return &Event{
Type: t,
Timestamp: time.Now(),
Err: make(chan error, 1),
}
}
type CallbackEvent interface {
Event() Event
Callback() chan Event
}
type ExitEvent struct {
Pid int
Status int
}
func (e *ExitEvent) String() string {
return "exit event"
}
type StartContainerEvent struct {
ID string
BundlePath string
Err chan error
}
func (c *StartContainerEvent) String() string {
return "create container"
}
type ContainerStartErrorEvent struct {
ID string
}
func (c *ContainerStartErrorEvent) String() string {
return "container start error"
}
type GetContainersEvent struct {
Containers []Container
Err chan error
}
func (c *GetContainersEvent) String() string {
return "get containers"
}
type SignalEvent struct {
ID string
Pid int
Signal os.Signal
Err chan error
}
func (s *SignalEvent) String() string {
return "signal event"
type Event struct {
Type EventType `json:"type"`
Timestamp time.Time `json:"timestamp"`
ID string `json:"id,omitempty"`
BundlePath string `json:"bundlePath,omitempty"`
Pid int `json:"pid,omitempty"`
Status int `json:"status,omitempty"`
Signal os.Signal `json:"signal,omitempty"`
Containers []Container `json:"-"`
Err chan error `json:"-"`
}