io2

package
v0.0.0-...-436d200 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2023 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewReadConn

func NewReadConn(connection ConnWithDuplexShutdown, upstream io.Reader) (io.ReadCloser, error)

func NewReaderToWriterAdapter

func NewReaderToWriterAdapter(writerFactory func(io.Writer) (io.Writer, error),
	upstream io.Reader) (io.ReadCloser, error)

This makes a new ReaderToWriterAdapter it requires a factory to generate the writer-to-be-wrapped The reason is that the writer will require another "downstream" writer to be bound with. Each type of writer (eg zlib.NewWriter) may have a slightly different way of being bound with a downstream writer so here, the user must provide a factory function into this constructor and then the constructor will be invoked with an implementation-defined downstream writer, which will allow the writer to act as a reader from the outside

func NewWriteConn

func NewWriteConn(connection ConnWithShutdown, downstream io.Writer) (io.WriteCloser, error)

func NewWriterToReaderAdapter

func NewWriterToReaderAdapter(toBeAdapted func(io.Reader) (io.Reader, error),
	output io.Writer,
	shouldCloseDownstream bool) io.WriteCloser

This makes a io.Writer from a io.Reader and begins reading and writing data The returned class is not thread safe and public methods must be called from a single thread

func PipelinedCopy

func PipelinedCopy(
	dest io.Writer,
	src io.Reader,
	numBuffers int,
	bufferSize int,
	minRead int) (written int64, err error)

This is similar to io.CopyBuffer, except this uses circular buffer and goroutines to pipeline copying (When numBuffers is 1, this simply uses io.CopyBuffer).

PipelinedCopy copy will always fill a buffer until it has at least minRead bytes in buffer before forwarding the buffer. PipelinedCopy flushes dest after each write if it implements http.Flusher interface.

Types

type ConnWithDuplexShutdown

type ConnWithDuplexShutdown interface {
	ConnWithShutdown
	CloseRead() error
}

type ConnWithShutdown

type ConnWithShutdown interface {
	net.Conn
	CloseWrite() error
}

type ReadConn

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

func (*ReadConn) Close

func (wcself *ReadConn) Close() error

func (*ReadConn) Read

func (wcself *ReadConn) Read(data []byte) (int, error)

type ReadSubprocess

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

func NewReadSubprocess

func NewReadSubprocess(
	cmd *exec.Cmd,
	upstream io.Reader) (ReadSubprocess, error)

func (*ReadSubprocess) Close

func (readSubprocess *ReadSubprocess) Close() error

func (*ReadSubprocess) Read

func (readSubprocess *ReadSubprocess) Read(data []byte) (int, error)

type ReaderToWriterAdapter

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

This class adapts an io.Writer into a io.Reader It allows anyone to structure a zlib compression as a read operation, rather than a write, making it more convenient to fit into a pipeline

func (*ReaderToWriterAdapter) Close

func (rwaself *ReaderToWriterAdapter) Close() error

interrupt the read by closing all resources

func (*ReaderToWriterAdapter) Read

func (rwaself *ReaderToWriterAdapter) Read(data []byte) (int, error)

implements the Read interface by wrapping the Writer with some buffers

type WriteConn

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

func (*WriteConn) Close

func (wcself *WriteConn) Close() error

func (*WriteConn) Write

func (wcself *WriteConn) Write(data []byte) (int, error)

type WriteSubprocess

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

func NewWriteSubprocess

func NewWriteSubprocess(
	cmd *exec.Cmd,
	downstream io.Writer) (WriteSubprocess, error)

func (*WriteSubprocess) Close

func (writeSubprocess *WriteSubprocess) Close() error

func (*WriteSubprocess) Write

func (writeSubprocess *WriteSubprocess) Write(data []byte) (int, error)

type WriterToReaderAdapter

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

This class adapts an io.Reader into a io.WriteCloser It allows anyone to structure a zlib decompression as a write operation, rather than a read, making it more convenient to fit into a pipeline

func (*WriterToReaderAdapter) Close

func (wrself *WriterToReaderAdapter) Close() error

Close must be called, even if there's an error during Write, to clean up all goroutines and resources This function shuts down the Writer, which will deliver an io.EOF to the reader class. It then blocks until the downstream writer has been passed a close and returns any errors from the downstream Close (or any pending errors from final reads that were triggered by the io.Reader to be adapted)

func (*WriterToReaderAdapter) Write

func (wrself *WriterToReaderAdapter) Write(data []byte) (int, error)

this is the public Write interface that presents any data to the companion goroutine (copyDataToOutput) This function is unbuffered and blocks until the companion goroutine consumes the data and returns a receipt. This means that there are no extraneous allocations since the receipt is the data that was consumed (sent) and the Write can now return

Directories

Path Synopsis
Package ioutil2 provides extra functionality along similar lines to io/ioutil.
Package ioutil2 provides extra functionality along similar lines to io/ioutil.

Jump to

Keyboard shortcuts

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