github.com/portworx/docker@v1.12.1/api/server/router/container/backend.go (about)

     1  package container
     2  
     3  import (
     4  	"io"
     5  	"time"
     6  
     7  	"golang.org/x/net/context"
     8  
     9  	"github.com/docker/docker/api/types/backend"
    10  	"github.com/docker/docker/pkg/archive"
    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(name string, config *types.ExecConfig) (string, error)
    18  	ContainerExecInspect(id string) (*backend.ExecInspect, error)
    19  	ContainerExecResize(name string, height, width int) error
    20  	ContainerExecStart(ctx context.Context, 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(config types.ContainerCreateConfig, validateHostname bool) (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, validateHostname bool) error
    43  	ContainerStop(name string, seconds int) error
    44  	ContainerUnpause(name string) error
    45  	ContainerUpdate(name string, hostConfig *container.HostConfig, validateHostname bool) ([]string, error)
    46  	ContainerWait(name string, timeout time.Duration) (int, error)
    47  }
    48  
    49  // monitorBackend includes functions to implement to provide containers monitoring functionality.
    50  type monitorBackend interface {
    51  	ContainerChanges(name string) ([]archive.Change, error)
    52  	ContainerInspect(name string, size bool, version string) (interface{}, error)
    53  	ContainerLogs(ctx context.Context, name string, config *backend.ContainerLogsConfig, started chan struct{}) error
    54  	ContainerStats(ctx context.Context, name string, config *backend.ContainerStatsConfig) error
    55  	ContainerTop(name string, psArgs string) (*types.ContainerProcessList, error)
    56  
    57  	Containers(config *types.ContainerListOptions) ([]*types.Container, error)
    58  }
    59  
    60  // attachBackend includes function to implement to provide container attaching functionality.
    61  type attachBackend interface {
    62  	ContainerAttach(name string, c *backend.ContainerAttachConfig) error
    63  }
    64  
    65  // Backend is all the methods that need to be implemented to provide container specific functionality.
    66  type Backend interface {
    67  	execBackend
    68  	copyBackend
    69  	stateBackend
    70  	monitorBackend
    71  	attachBackend
    72  }