github.com/hustcat/docker@v1.3.3-0.20160314103604-901c67a8eeab/api/server/router/container/backend.go (about) 1 package container 2 3 import ( 4 "io" 5 "time" 6 7 "github.com/docker/docker/api/types/backend" 8 "github.com/docker/docker/pkg/archive" 9 "github.com/docker/docker/pkg/version" 10 "github.com/docker/engine-api/types" 11 "github.com/docker/engine-api/types/container" 12 ) 13 14 // execBackend includes functions to implement to provide exec functionality. 15 type execBackend interface { 16 ContainerExecCreate(config *types.ExecConfig) (string, error) 17 ContainerExecInspect(id string) (*backend.ExecInspect, error) 18 ContainerExecResize(name string, height, width int) error 19 ContainerExecStart(name string, stdin io.ReadCloser, stdout io.Writer, stderr io.Writer) error 20 ExecExists(name string) (bool, error) 21 } 22 23 // copyBackend includes functions to implement to provide container copy functionality. 24 type copyBackend interface { 25 ContainerArchivePath(name string, path string) (content io.ReadCloser, stat *types.ContainerPathStat, err error) 26 ContainerCopy(name string, res string) (io.ReadCloser, error) 27 ContainerExport(name string, out io.Writer) error 28 ContainerExtractToDir(name, path string, noOverwriteDirNonDir bool, content io.Reader) error 29 ContainerStatPath(name string, path string) (stat *types.ContainerPathStat, err error) 30 } 31 32 // stateBackend includes functions to implement to provide container state lifecycle functionality. 33 type stateBackend interface { 34 ContainerCreate(types.ContainerCreateConfig) (types.ContainerCreateResponse, error) 35 ContainerKill(name string, sig uint64) error 36 ContainerPause(name string) error 37 ContainerRename(oldName, newName string) error 38 ContainerResize(name string, height, width int) error 39 ContainerRestart(name string, seconds int) error 40 ContainerRm(name string, config *types.ContainerRmConfig) error 41 ContainerStart(name string, hostConfig *container.HostConfig) error 42 ContainerStop(name string, seconds int) error 43 ContainerUnpause(name string) error 44 ContainerUpdate(name string, hostConfig *container.HostConfig) ([]string, error) 45 ContainerWait(name string, timeout time.Duration) (int, error) 46 } 47 48 // monitorBackend includes functions to implement to provide containers monitoring functionality. 49 type monitorBackend interface { 50 ContainerChanges(name string) ([]archive.Change, error) 51 ContainerInspect(name string, size bool, version version.Version) (interface{}, error) 52 ContainerLogs(name string, config *backend.ContainerLogsConfig, started chan struct{}) error 53 ContainerStats(name string, config *backend.ContainerStatsConfig) error 54 ContainerTop(name string, psArgs string) (*types.ContainerProcessList, error) 55 56 Containers(config *types.ContainerListOptions) ([]*types.Container, error) 57 } 58 59 // attachBackend includes function to implement to provide container attaching functionality. 60 type attachBackend interface { 61 ContainerAttach(name string, c *backend.ContainerAttachConfig) error 62 } 63 64 // Backend is all the methods that need to be implemented to provide container specific functionality. 65 type Backend interface { 66 execBackend 67 copyBackend 68 stateBackend 69 monitorBackend 70 attachBackend 71 }