cio

package
v1.5.5 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2021 License: Apache-2.0 Imports: 14 Imported by: 1,535

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LogURIGenerator added in v1.4.0

func LogURIGenerator(scheme string, path string, args map[string]string) (*url.URL, error)

LogURIGenerator is the helper to generate log uri with specific scheme.

func WithStdio added in v1.1.0

func WithStdio(opt *Streams)

WithStdio sets stream options to the standard input/output streams

func WithTerminal added in v1.1.0

func WithTerminal(opt *Streams)

WithTerminal sets the terminal option

Types

type Attach

type Attach func(*FIFOSet) (IO, error)

Attach allows callers to reattach to running tasks

There should only be one reader for a task's IO set because fifo's can only be read from one reader or the output will be sent only to the first reads

func NewAttach added in v1.1.0

func NewAttach(opts ...Opt) Attach

NewAttach attaches the existing io for a task to the provided io.Reader/Writers

type Config

type Config struct {
	// Terminal is true if one has been allocated
	Terminal bool
	// Stdin path
	Stdin string
	// Stdout path
	Stdout string
	// Stderr path
	Stderr string
}

Config holds the IO configurations.

type Creator added in v1.1.0

type Creator func(id string) (IO, error)

Creator creates new IO sets for a task

func BinaryIO added in v1.3.0

func BinaryIO(binary string, args map[string]string) Creator

BinaryIO forwards container STDOUT|STDERR directly to a logging binary

func LogFile added in v1.2.0

func LogFile(path string) Creator

LogFile creates a file on disk that logs the task's STDOUT,STDERR. If the log file already exists, the logs will be appended to the file.

func LogURI added in v1.3.0

func LogURI(uri *url.URL) Creator

LogURI provides the raw logging URI

func NewCreator added in v1.1.0

func NewCreator(opts ...Opt) Creator

NewCreator returns an IO creator from the options

func TerminalBinaryIO added in v1.5.0

func TerminalBinaryIO(binary string, args map[string]string) Creator

TerminalBinaryIO forwards container STDOUT|STDERR directly to a logging binary It also sets the terminal option to true

type DirectIO

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

DirectIO allows task IO to be handled externally by the caller

func NewDirectIO

func NewDirectIO(ctx context.Context, fifos *FIFOSet) (*DirectIO, error)

NewDirectIO returns an IO implementation that exposes the IO streams as io.ReadCloser and io.WriteCloser.

func (*DirectIO) Cancel

func (c *DirectIO) Cancel()

func (*DirectIO) Close

func (c *DirectIO) Close() error

func (*DirectIO) Config

func (c *DirectIO) Config() Config

func (*DirectIO) Wait

func (c *DirectIO) Wait()

type FIFOSet

type FIFOSet struct {
	Config
	// contains filtered or unexported fields
}

FIFOSet is a set of file paths to FIFOs for a task's standard IO streams

func NewFIFOSet added in v1.1.0

func NewFIFOSet(config Config, close func() error) *FIFOSet

NewFIFOSet returns a new FIFOSet from a Config and a close function

func NewFIFOSetInDir added in v1.1.0

func NewFIFOSetInDir(root, id string, terminal bool) (*FIFOSet, error)

NewFIFOSetInDir returns a new FIFOSet with paths in a temporary directory under root

func (*FIFOSet) Close added in v1.1.0

func (f *FIFOSet) Close() error

Close the FIFOSet

type IO

type IO interface {
	// Config returns the IO configuration.
	Config() Config
	// Cancel aborts all current io operations.
	Cancel()
	// Wait blocks until all io copy operations have completed.
	Wait()
	// Close cleans up all open io resources. Cancel() is always called before
	// Close()
	Close() error
}

IO holds the io information for a task or process

func Load added in v1.1.1

func Load(set *FIFOSet) (IO, error)

Load the io for a container but do not attach

Allows io to be loaded on the task for deletion without starting copy routines

func NullIO

func NullIO(_ string) (IO, error)

NullIO redirects the container's IO into /dev/null

type Opt added in v1.1.0

type Opt func(*Streams)

Opt customize options for creating a Creator or Attach

func WithFIFODir added in v1.1.0

func WithFIFODir(dir string) Opt

WithFIFODir sets the fifo directory. e.g. "/run/containerd/fifo", "/run/users/1001/containerd/fifo"

func WithStreams added in v1.1.0

func WithStreams(stdin io.Reader, stdout, stderr io.Writer) Opt

WithStreams sets the stream options to the specified Reader and Writers

type Streams added in v1.1.0

type Streams struct {
	Stdin    io.Reader
	Stdout   io.Writer
	Stderr   io.Writer
	Terminal bool
	FIFODir  string
}

Streams used to configure a Creator or Attach

Jump to

Keyboard shortcuts

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