Documentation
¶
Overview ¶
Package stream provides stream-processing utilities.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrMaximumBufferSizeExceeded = errors.New("maximum buffer size exceed")
ErrMaximumBufferSizeExceeded is returned when a write would exceed the maximum internal buffer size for a writer.
var ( // ErrWritePreempted indicates that a write operation was preempted. ErrWritePreempted = errors.New("write preempted") )
Functions ¶
func NewPreemptableWriter ¶
NewPreemptableWriter wraps an io.Writer and provides preemption capabilities for long copy operations. It takes an underlying writer, a channel that (once closed) indicates cancellation, and an interval that specifies the maximum number of Write calls that should be processed between cancellation checks. If interval is 0, a cancellation check will be performed before every write.
Types ¶
type CloseWriter ¶
type CloseWriter interface { io.Writer // CloseWrite closes the stream for writes and signals io.EOF to the // receiving end of the stream. It must unblock any pending calls to Write. CloseWrite() error }
CloseWriter represents a stream with half-closure functionality.
type DualModeReader ¶
type DualModeReader interface { io.ByteReader io.Reader }
DualModeReader represents a reader that can perform both regular and single-byte reads efficiently.
type LineProcessor ¶
type LineProcessor struct { // Callback is the line processing callback. Callback func(string) // MaximumBufferSize is the maximum allowed internal buffer size. If writes // to the writer exceed this size without incorporating a newline, then an // error will be raised. A value of 0 causes the writer to use a reasonable // default. A negative value indicates no limit. MaximumBufferSize int // contains filtered or unexported fields }
LineProcessor is an io.Writer that splits its input stream into lines and writes those lines to a callback function. Line splits are performed on any instance of '\n' or '\r\n', with the split character(s) removed from the callback value.
type ValveWriter ¶
type ValveWriter struct {
// contains filtered or unexported fields
}
ValveWriter is an io.Writer that wraps another io.Writer and performs writes to it until the valve is shut, after which writes will continue to succeed but not be written to the underlying writer.
func NewValveWriter ¶
func NewValveWriter(writer io.Writer) *ValveWriter
NewValveWriter creates a new ValveWriter instance using the specified writer. The write may be nil, in which case the writer will start pre-shut.
func (*ValveWriter) Shut ¶
func (w *ValveWriter) Shut()
Shut closes the valve and stops writes to the underlying writer.