github.com/jwhonce/docker@v0.6.7-0.20190327063223-da823cf3a5a3/libcontainerd/types/types.go (about) 1 package types // import "github.com/docker/docker/libcontainerd/types" 2 3 import ( 4 "context" 5 "time" 6 7 "github.com/containerd/containerd" 8 "github.com/containerd/containerd/cio" 9 "github.com/opencontainers/runtime-spec/specs-go" 10 ) 11 12 // EventType represents a possible event from libcontainerd 13 type EventType string 14 15 // Event constants used when reporting events 16 const ( 17 EventUnknown EventType = "unknown" 18 EventExit EventType = "exit" 19 EventOOM EventType = "oom" 20 EventCreate EventType = "create" 21 EventStart EventType = "start" 22 EventExecAdded EventType = "exec-added" 23 EventExecStarted EventType = "exec-started" 24 EventPaused EventType = "paused" 25 EventResumed EventType = "resumed" 26 ) 27 28 // Status represents the current status of a container 29 type Status string 30 31 // Possible container statuses 32 const ( 33 // Running indicates the process is currently executing 34 StatusRunning Status = "running" 35 // Created indicates the process has been created within containerd but the 36 // user's defined process has not started 37 StatusCreated Status = "created" 38 // Stopped indicates that the process has ran and exited 39 StatusStopped Status = "stopped" 40 // Paused indicates that the process is currently paused 41 StatusPaused Status = "paused" 42 // Pausing indicates that the process is currently switching from a 43 // running state into a paused state 44 StatusPausing Status = "pausing" 45 // Unknown indicates that we could not determine the status from the runtime 46 StatusUnknown Status = "unknown" 47 ) 48 49 // EventInfo contains the event info 50 type EventInfo struct { 51 ContainerID string 52 ProcessID string 53 Pid uint32 54 ExitCode uint32 55 ExitedAt time.Time 56 OOMKilled bool 57 Error error 58 } 59 60 // Backend defines callbacks that the client of the library needs to implement. 61 type Backend interface { 62 ProcessEvent(containerID string, event EventType, ei EventInfo) error 63 } 64 65 // Client provides access to containerd features. 66 type Client interface { 67 Version(ctx context.Context) (containerd.Version, error) 68 69 Restore(ctx context.Context, containerID string, attachStdio StdioCallback) (alive bool, pid int, err error) 70 71 Create(ctx context.Context, containerID string, spec *specs.Spec, runtimeOptions interface{}) error 72 Start(ctx context.Context, containerID, checkpointDir string, withStdin bool, attachStdio StdioCallback) (pid int, err error) 73 SignalProcess(ctx context.Context, containerID, processID string, signal int) error 74 Exec(ctx context.Context, containerID, processID string, spec *specs.Process, withStdin bool, attachStdio StdioCallback) (int, error) 75 ResizeTerminal(ctx context.Context, containerID, processID string, width, height int) error 76 CloseStdin(ctx context.Context, containerID, processID string) error 77 Pause(ctx context.Context, containerID string) error 78 Resume(ctx context.Context, containerID string) error 79 Stats(ctx context.Context, containerID string) (*Stats, error) 80 ListPids(ctx context.Context, containerID string) ([]uint32, error) 81 Summary(ctx context.Context, containerID string) ([]Summary, error) 82 DeleteTask(ctx context.Context, containerID string) (uint32, time.Time, error) 83 Delete(ctx context.Context, containerID string) error 84 Status(ctx context.Context, containerID string) (Status, error) 85 86 UpdateResources(ctx context.Context, containerID string, resources *Resources) error 87 CreateCheckpoint(ctx context.Context, containerID, checkpointDir string, exit bool) error 88 } 89 90 // StdioCallback is called to connect a container or process stdio. 91 type StdioCallback func(io *cio.DirectIO) (cio.IO, error) 92 93 // InitProcessName is the name given to the first process of a container 94 const InitProcessName = "init"