github.com/demonoid81/moby@v0.0.0-20200517203328-62dd8e17c460/libcontainerd/types/types.go (about) 1 package types // import "github.com/demonoid81/moby/libcontainerd/types" 2 3 import ( 4 "context" 5 "time" 6 7 "github.com/containerd/containerd" 8 "github.com/containerd/containerd/cio" 9 specs "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 // EventInfo contains the event info 29 type EventInfo struct { 30 ContainerID string 31 ProcessID string 32 Pid uint32 33 ExitCode uint32 34 ExitedAt time.Time 35 OOMKilled bool 36 Error error 37 } 38 39 // Backend defines callbacks that the client of the library needs to implement. 40 type Backend interface { 41 ProcessEvent(containerID string, event EventType, ei EventInfo) error 42 } 43 44 // Process of a container 45 type Process interface { 46 Delete(context.Context) (uint32, time.Time, error) 47 } 48 49 // Client provides access to containerd features. 50 type Client interface { 51 Version(ctx context.Context) (containerd.Version, error) 52 53 Restore(ctx context.Context, containerID string, attachStdio StdioCallback) (alive bool, pid int, p Process, err error) 54 55 Create(ctx context.Context, containerID string, spec *specs.Spec, runtimeOptions interface{}, opts ...containerd.NewContainerOpts) error 56 Start(ctx context.Context, containerID, checkpointDir string, withStdin bool, attachStdio StdioCallback) (pid int, err error) 57 SignalProcess(ctx context.Context, containerID, processID string, signal int) error 58 Exec(ctx context.Context, containerID, processID string, spec *specs.Process, withStdin bool, attachStdio StdioCallback) (int, error) 59 ResizeTerminal(ctx context.Context, containerID, processID string, width, height int) error 60 CloseStdin(ctx context.Context, containerID, processID string) error 61 Pause(ctx context.Context, containerID string) error 62 Resume(ctx context.Context, containerID string) error 63 Stats(ctx context.Context, containerID string) (*Stats, error) 64 ListPids(ctx context.Context, containerID string) ([]uint32, error) 65 Summary(ctx context.Context, containerID string) ([]Summary, error) 66 DeleteTask(ctx context.Context, containerID string) (uint32, time.Time, error) 67 Delete(ctx context.Context, containerID string) error 68 Status(ctx context.Context, containerID string) (containerd.ProcessStatus, error) 69 70 UpdateResources(ctx context.Context, containerID string, resources *Resources) error 71 CreateCheckpoint(ctx context.Context, containerID, checkpointDir string, exit bool) error 72 } 73 74 // StdioCallback is called to connect a container or process stdio. 75 type StdioCallback func(io *cio.DirectIO) (cio.IO, error) 76 77 // InitProcessName is the name given to the first process of a container 78 const InitProcessName = "init"