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.
Functions ¶
This section is empty.
Types ¶
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.