client

package
v0.1.0-M4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 24, 2023 License: Apache-2.0, EPL-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxBufSize is the maximum buffer size (in bytes) received in a read chunk or sent in a write chunk.
	MaxBufSize = 2 * 1024 * 1024
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	// Create a new container.
	Create(ctx context.Context, config *types.Container) (*types.Container, error)

	// Get the detailed information of container.
	Get(ctx context.Context, id string) (*types.Container, error)

	// List returns the list of containers matching the optional filters provided.
	List(ctx context.Context, filters ...Filter) ([]*types.Container, error)

	// Start a container.
	Start(ctx context.Context, id string) error

	// Stop a container.
	Stop(ctx context.Context, id string, stopOpts *types.StopOpts) error

	// Update a container.
	Update(ctx context.Context, id string, updateOpts *types.UpdateOpts) error

	// Attach to a container
	Attach(ctx context.Context, id string, stdin bool) (io.Writer, io.ReadCloser, error)

	// Restart restart a running container.
	Restart(ctx context.Context, id string, timeout int64) error

	// Pause a container.
	Pause(ctx context.Context, id string) error

	// Resumes a container.
	Resume(ctx context.Context, id string) error

	// Rename renames a container.
	Rename(ctx context.Context, id string, name string) error

	// Remove removes a container, it may be running or stopped and so on.
	Remove(ctx context.Context, id string, force bool) error

	ProjectInfo(ctx context.Context) (sysinfotypes.ProjectInfo, error)

	// Logs prints the logs for a container
	Logs(ctx context.Context, id string, tail int32) error

	// Dispose the client instance
	Dispose() error
}

Client is the client API for gRPC API of the engine.

func New

func New(connectionAddress string, timeout time.Duration) (Client, error)

New creates a new containers client.

type Filter

type Filter func(container *types.Container) bool

Filter returns if the container matches the defined filter.

func WithName

func WithName(name string) Filter

WithName filters the containers that match a given name

type Reader

type Reader struct {
	// contains filtered or unexported fields
}

Reader reads from a byte stream.

func NewReader

func NewReader(ctx context.Context, containerID string, stdIn bool, ctrClient pbcontainers.Containers_AttachClient) (*Reader, error)

NewReader creates a new Reader to read a resource.

func NewReaderAt

func NewReaderAt(ctx context.Context, containerID string, stdIn bool, offset int64, ctrClient pbcontainers.Containers_AttachClient) (*Reader, error)

NewReaderAt creates a new Reader to read a resource from the given offset.

func (*Reader) Close

func (r *Reader) Close() error

Close implements io.Closer.

func (*Reader) ContainerID

func (r *Reader) ContainerID() string

ContainerID gets the container id of the IO this Reader is reading.

func (*Reader) Read

func (r *Reader) Read(p []byte) (int, error)

Read implements io.Reader. Read buffers received bytes that do not fit in p.

func (*Reader) StdIn

func (r *Reader) StdIn() bool

StdIn gets whether the IO should be Interactive.

type Writer

type Writer struct {
	// contains filtered or unexported fields
}

Writer writes to a byte stream.

func NewWriter

func NewWriter(ctx context.Context, containerID string, stdIn bool, ctrClient pbcontainers.Containers_AttachClient) (*Writer, error)

NewWriter creates a new Writer to write a resource.

resourceName specifies the name of the resource. The resource will be available after Close has been called.

It is the caller's responsibility to call Close when writing is done.

Note: There is currently no way to resume a writer. Maybe NewWriter should begin with a call to QueryWriteStatus.

func (*Writer) Close

func (w *Writer) Close() error

Close implements io.Closer. It is the caller's responsibility to call Close() when writing is done.

func (*Writer) ContainerID

func (w *Writer) ContainerID() string

ContainerID gets the resource name this Writer is writing.

func (*Writer) StdIn

func (w *Writer) StdIn() bool

StdIn gets the resource name this Writer is writing.

func (*Writer) Write

func (w *Writer) Write(p []byte) (int, error)

Write implements io.Writer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL