github.com/ncdc/docker@v0.10.1-0.20160129113957-6c6729ef5b74/api/server/router/container/backend.go (about)

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