github.com/dpiddy/docker@v1.12.2-rc1/libcontainerd/types.go (about)

     1  package libcontainerd
     2  
     3  import (
     4  	"io"
     5  
     6  	"golang.org/x/net/context"
     7  )
     8  
     9  // State constants used in state change reporting.
    10  const (
    11  	StateStart        = "start-container"
    12  	StatePause        = "pause"
    13  	StateResume       = "resume"
    14  	StateExit         = "exit"
    15  	StateRestart      = "restart"
    16  	StateRestore      = "restore"
    17  	StateStartProcess = "start-process"
    18  	StateExitProcess  = "exit-process"
    19  	StateOOM          = "oom" // fake state
    20  	stateLive         = "live"
    21  )
    22  
    23  // CommonStateInfo contains the state info common to all platforms.
    24  type CommonStateInfo struct { // FIXME: event?
    25  	State     string
    26  	Pid       uint32
    27  	ExitCode  uint32
    28  	ProcessID string
    29  }
    30  
    31  // Backend defines callbacks that the client of the library needs to implement.
    32  type Backend interface {
    33  	StateChanged(containerID string, state StateInfo) error
    34  	AttachStreams(processFriendlyName string, io IOPipe) error
    35  }
    36  
    37  // Client provides access to containerd features.
    38  type Client interface {
    39  	Create(containerID string, spec Spec, options ...CreateOption) error
    40  	Signal(containerID string, sig int) error
    41  	SignalProcess(containerID string, processFriendlyName string, sig int) error
    42  	AddProcess(ctx context.Context, containerID, processFriendlyName string, process Process) error
    43  	Resize(containerID, processFriendlyName string, width, height int) error
    44  	Pause(containerID string) error
    45  	Resume(containerID string) error
    46  	Restore(containerID string, options ...CreateOption) error
    47  	Stats(containerID string) (*Stats, error)
    48  	GetPidsForContainer(containerID string) ([]int, error)
    49  	Summary(containerID string) ([]Summary, error)
    50  	UpdateResources(containerID string, resources Resources) error
    51  }
    52  
    53  // CreateOption allows to configure parameters of container creation.
    54  type CreateOption interface {
    55  	Apply(interface{}) error
    56  }
    57  
    58  // IOPipe contains the stdio streams.
    59  type IOPipe struct {
    60  	Stdin    io.WriteCloser
    61  	Stdout   io.Reader
    62  	Stderr   io.Reader
    63  	Terminal bool // Whether stderr is connected on Windows
    64  }