github.com/marunai/moby@v1.13.1/libcontainerd/types.go (about)

     1  package libcontainerd
     2  
     3  import (
     4  	"io"
     5  
     6  	containerd "github.com/docker/containerd/api/grpc/types"
     7  	"github.com/opencontainers/runtime-spec/specs-go"
     8  	"golang.org/x/net/context"
     9  )
    10  
    11  // State constants used in state change reporting.
    12  const (
    13  	StateStart       = "start-container"
    14  	StatePause       = "pause"
    15  	StateResume      = "resume"
    16  	StateExit        = "exit"
    17  	StateRestore     = "restore"
    18  	StateExitProcess = "exit-process"
    19  	StateOOM         = "oom" // fake state
    20  )
    21  
    22  // CommonStateInfo contains the state info common to all platforms.
    23  type CommonStateInfo struct { // FIXME: event?
    24  	State     string
    25  	Pid       uint32
    26  	ExitCode  uint32
    27  	ProcessID string
    28  }
    29  
    30  // Backend defines callbacks that the client of the library needs to implement.
    31  type Backend interface {
    32  	StateChanged(containerID string, state StateInfo) error
    33  }
    34  
    35  // Client provides access to containerd features.
    36  type Client interface {
    37  	GetServerVersion(ctx context.Context) (*ServerVersion, error)
    38  	Create(containerID string, checkpoint string, checkpointDir string, spec specs.Spec, attachStdio StdioCallback, options ...CreateOption) error
    39  	Signal(containerID string, sig int) error
    40  	SignalProcess(containerID string, processFriendlyName string, sig int) error
    41  	AddProcess(ctx context.Context, containerID, processFriendlyName string, process Process, attachStdio StdioCallback) (int, error)
    42  	Resize(containerID, processFriendlyName string, width, height int) error
    43  	Pause(containerID string) error
    44  	Resume(containerID string) error
    45  	Restore(containerID string, attachStdio StdioCallback, options ...CreateOption) error
    46  	Stats(containerID string) (*Stats, error)
    47  	GetPidsForContainer(containerID string) ([]int, error)
    48  	Summary(containerID string) ([]Summary, error)
    49  	UpdateResources(containerID string, resources Resources) error
    50  	CreateCheckpoint(containerID string, checkpointID string, checkpointDir string, exit bool) error
    51  	DeleteCheckpoint(containerID string, checkpointID string, checkpointDir string) error
    52  	ListCheckpoints(containerID string, checkpointDir string) (*Checkpoints, error)
    53  }
    54  
    55  // CreateOption allows to configure parameters of container creation.
    56  type CreateOption interface {
    57  	Apply(interface{}) error
    58  }
    59  
    60  // StdioCallback is called to connect a container or process stdio.
    61  type StdioCallback func(IOPipe) error
    62  
    63  // IOPipe contains the stdio streams.
    64  type IOPipe struct {
    65  	Stdin    io.WriteCloser
    66  	Stdout   io.ReadCloser
    67  	Stderr   io.ReadCloser
    68  	Terminal bool // Whether stderr is connected on Windows
    69  }
    70  
    71  // ServerVersion contains version information as retrieved from the
    72  // server
    73  type ServerVersion struct {
    74  	containerd.GetServerVersionResponse
    75  }