util

package
v0.1.0-rc4 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2019 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const IOCommandStderrBufSize = 1024

Variables

View Source
var ChunkBufSize uint32 = 32 * 1024
View Source
var ChunkHeaderByteOrder = binary.LittleEndian

Functions

func ContextWithOptionalDeadline

func ContextWithOptionalDeadline(pctx context.Context) (ctx context.Context, enforceDeadline func(deadline time.Time))

Types

type ByteCounterReader

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

func NewByteCounterReader

func NewByteCounterReader(reader io.ReadCloser) *ByteCounterReader

func (*ByteCounterReader) Bytes

func (b *ByteCounterReader) Bytes() int64

func (*ByteCounterReader) Close

func (b *ByteCounterReader) Close() error

func (*ByteCounterReader) Read

func (b *ByteCounterReader) Read(p []byte) (n int, err error)

func (*ByteCounterReader) SetCallback

func (b *ByteCounterReader) SetCallback(every time.Duration, cb func(full int64))

type ChainedReader

type ChainedReader struct {
	Readers []io.Reader
	// contains filtered or unexported fields
}

func NewChainedReader

func NewChainedReader(reader ...io.Reader) *ChainedReader

func (*ChainedReader) Read

func (c *ChainedReader) Read(buf []byte) (n int, err error)

type Chunker

type Chunker struct {
	ChunkCount int
	// contains filtered or unexported fields
}

func NewChunker

func NewChunker(conn io.Reader) Chunker

func NewChunkerSized

func NewChunkerSized(conn io.Reader, chunkSize uint32) Chunker

func (*Chunker) Read

func (c *Chunker) Read(b []byte) (n int, err error)

type IOCommand

type IOCommand struct {
	Cmd *exec.Cmd

	Stdin      io.WriteCloser
	Stdout     io.ReadCloser
	StderrBuf  *bytes.Buffer
	ExitResult *IOCommandExitResult
	// contains filtered or unexported fields
}

An IOCommand exposes a forked process's std(in|out|err) through the io.ReadWriteCloser interface.

func NewIOCommand

func NewIOCommand(ctx context.Context, command string, args []string, stderrBufSize int) (c *IOCommand, err error)

func RunIOCommand

func RunIOCommand(ctx context.Context, command string, args ...string) (c *IOCommand, err error)

func (*IOCommand) Close

func (c *IOCommand) Close() (err error)

Terminate the child process and collect its exit status It is safe to call Close() multiple times.

func (*IOCommand) Read

func (c *IOCommand) Read(buf []byte) (n int, err error)

Read from process's stdout. The behavior after Close()ing is undefined

func (*IOCommand) Start

func (c *IOCommand) Start() (err error)

func (*IOCommand) Write

func (c *IOCommand) Write(buf []byte) (n int, err error)

Write to process's stdin. The behavior after Close()ing is undefined

type IOCommandError

type IOCommandError struct {
	WaitErr error
	Stderr  []byte
}

func (IOCommandError) Error

func (e IOCommandError) Error() string

type IOCommandExitResult

type IOCommandExitResult struct {
	Error      error
	WaitStatus syscall.WaitStatus
}

type NetConnLogger

type NetConnLogger struct {
	net.Conn
	ReadFile  *os.File
	WriteFile *os.File
}

func NewNetConnLogger

func NewNetConnLogger(conn net.Conn, readlog, writelog string) (l *NetConnLogger, err error)

func (*NetConnLogger) Close

func (c *NetConnLogger) Close() (err error)

func (*NetConnLogger) Read

func (c *NetConnLogger) Read(buf []byte) (n int, err error)

func (*NetConnLogger) Write

func (c *NetConnLogger) Write(buf []byte) (n int, err error)

type Unchunker

type Unchunker struct {
	ChunkCount int
	// contains filtered or unexported fields
}

func NewUnchunker

func NewUnchunker(conn io.Reader) *Unchunker

func (*Unchunker) Close

func (c *Unchunker) Close() (err error)

func (*Unchunker) Read

func (c *Unchunker) Read(b []byte) (n int, err error)

Directories

Path Synopsis
package chainlock implements a mutex whose Lock and Unlock methods return the lock itself, to enable chaining.
package chainlock implements a mutex whose Lock and Unlock methods return the lock itself, to enable chaining.
package devnoop provides an io.ReadWriteCloser that never errors and always reports reads / writes to / from buffers as complete.
package devnoop provides an io.ReadWriteCloser that never errors and always reports reads / writes to / from buffers as complete.

Jump to

Keyboard shortcuts

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