Documentation ¶
Index ¶
- func NewReadConn(connection ConnWithDuplexShutdown, upstream io.Reader) (io.ReadCloser, error)
- func NewReaderToWriterAdapter(writerFactory func(io.Writer) (io.Writer, error), upstream io.Reader) (io.ReadCloser, error)
- func NewWriteConn(connection ConnWithShutdown, downstream io.Writer) (io.WriteCloser, error)
- func NewWriterToReaderAdapter(toBeAdapted func(io.Reader) (io.Reader, error), output io.Writer, ...) io.WriteCloser
- func PipelinedCopy(dest io.Writer, src io.Reader, numBuffers int, bufferSize int, minRead int) (written int64, err error)
- type ConnWithDuplexShutdown
- type ConnWithShutdown
- type ReadConn
- type ReadSubprocess
- type ReaderToWriterAdapter
- type WriteConn
- type WriteSubprocess
- type WriterToReaderAdapter
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 ReadSubprocess ¶
type ReadSubprocess struct {
// contains filtered or unexported fields
}
func NewReadSubprocess ¶
func (*ReadSubprocess) Close ¶
func (readSubprocess *ReadSubprocess) Close() 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
type WriteSubprocess ¶
type WriteSubprocess struct {
// contains filtered or unexported fields
}
func NewWriteSubprocess ¶
func (*WriteSubprocess) Close ¶
func (writeSubprocess *WriteSubprocess) Close() 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