2015-11-05 23:29:53 +00:00
|
|
|
package containerd
|
|
|
|
|
2015-11-10 22:24:34 +00:00
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"time"
|
2015-11-10 22:57:10 +00:00
|
|
|
|
2015-12-01 19:56:08 +00:00
|
|
|
"github.com/docker/containerd/runtime"
|
2015-11-10 22:57:10 +00:00
|
|
|
"github.com/opencontainers/specs"
|
2015-11-10 22:24:34 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type EventType string
|
|
|
|
|
|
|
|
const (
|
2015-12-04 00:07:53 +00:00
|
|
|
ExecExitEventType EventType = "execExit"
|
|
|
|
ExitEventType EventType = "exit"
|
|
|
|
StartContainerEventType EventType = "startContainer"
|
|
|
|
DeleteEventType EventType = "deleteContainerEvent"
|
|
|
|
GetContainerEventType EventType = "getContainer"
|
|
|
|
SignalEventType EventType = "signal"
|
|
|
|
AddProcessEventType EventType = "addProcess"
|
|
|
|
UpdateContainerEventType EventType = "updateContainer"
|
|
|
|
CreateCheckpointEventType EventType = "createCheckpoint"
|
2015-12-04 22:00:07 +00:00
|
|
|
DeleteCheckpointEventType EventType = "deleteCheckpoint"
|
2015-11-10 22:24:34 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func NewEvent(t EventType) *Event {
|
|
|
|
return &Event{
|
|
|
|
Type: t,
|
|
|
|
Timestamp: time.Now(),
|
|
|
|
Err: make(chan error, 1),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
type Event struct {
|
2015-12-01 19:56:08 +00:00
|
|
|
Type EventType `json:"type"`
|
|
|
|
Timestamp time.Time `json:"timestamp"`
|
|
|
|
ID string `json:"id,omitempty"`
|
|
|
|
BundlePath string `json:"bundlePath,omitempty"`
|
|
|
|
Stdio *runtime.Stdio `json:"stdio,omitempty"`
|
|
|
|
Pid int `json:"pid,omitempty"`
|
|
|
|
Status int `json:"status,omitempty"`
|
|
|
|
Signal os.Signal `json:"signal,omitempty"`
|
|
|
|
Process *specs.Process `json:"process,omitempty"`
|
|
|
|
State *runtime.State `json:"state,omitempty"`
|
|
|
|
Containers []runtime.Container `json:"-"`
|
2015-12-04 00:07:53 +00:00
|
|
|
Checkpoint *runtime.Checkpoint `json:"checkpoint,omitempty"`
|
2015-12-01 19:56:08 +00:00
|
|
|
Err chan error `json:"-"`
|
2015-11-10 21:44:35 +00:00
|
|
|
}
|
2015-12-01 18:55:13 +00:00
|
|
|
|
|
|
|
type Handler interface {
|
|
|
|
Handle(*Event) error
|
|
|
|
}
|