godropbox: github.com/dropbox/godropbox/io2 Index | Files | Directories

package io2

import "github.com/dropbox/godropbox/io2"

Index

Package Files

doc.go pipelined_copy.go read_from_conn.go read_from_subprocess.go reader_to_writer_adapter.go write_to_conn.go write_to_subprocess.go writer_to_reader_adapter.go

func NewReadConn Uses

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

func NewReaderToWriterAdapter Uses

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 Uses

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

func NewWriterToReaderAdapter Uses

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 Uses

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.

type ConnWithDuplexShutdown Uses

type ConnWithDuplexShutdown interface {
    ConnWithShutdown
    CloseRead() error
}

type ConnWithShutdown Uses

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

type ReadConn Uses

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

func (*ReadConn) Close Uses

func (wcself *ReadConn) Close() error

func (*ReadConn) Read Uses

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

type ReadSubprocess Uses

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

func NewReadSubprocess Uses

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

func (*ReadSubprocess) Close Uses

func (readSubprocess *ReadSubprocess) Close() error

func (*ReadSubprocess) Read Uses

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

type ReaderToWriterAdapter Uses

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 Uses

func (rwaself *ReaderToWriterAdapter) Close() error

interrupt the read by closing all resources

func (*ReaderToWriterAdapter) Read Uses

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

implements the Read interface by wrapping the Writer with some buffers

type WriteConn Uses

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

func (*WriteConn) Close Uses

func (wcself *WriteConn) Close() error

func (*WriteConn) Write Uses

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

type WriteSubprocess Uses

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

func NewWriteSubprocess Uses

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

func (*WriteSubprocess) Close Uses

func (writeSubprocess *WriteSubprocess) Close() error

func (*WriteSubprocess) Write Uses

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

type WriterToReaderAdapter Uses

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 Uses

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 Uses

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

PathSynopsis
ioutil2Package ioutil2 provides extra functionality along similar lines to io/ioutil.

Package io2 imports 10 packages (graph). Updated 2019-02-06. Refresh now. Tools for package owners.