Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ErrorHandlerFunc ¶
An error handler function that receives the index of the reader when the error occurred and the read object itself
type QueuedReader ¶
A reader that sequentially attempts to read from the list of io.Reader, similar to the io.MultiReader. A Pre-read handler function, on EOF handler and on timeout handler function can be provided which will be called accordingly. Note, that when an EOF or timeout occurs, the reader will attempt to read from the next io.Reader until a result is returned OR another error occurs (not EOF or timeout).
func NewQueuedReader ¶
func NewQueuedReader[R io.Reader](readers []R) QueuedReader[R]
NewQueuedReader creates a new QueuedReader from the provided slice of [io.Reader]s.
func (QueuedReader[R]) Read ¶
func (q QueuedReader[R]) Read(b []byte) (int, error)
Read will iterate over the stored [io.Reader]s and return the first that performs a successful read (without EOF), or on the first non-EOF and non-Timeout error, or io.EOF will be returned if all [io.Reader]s timeout or return io.EOF.
func (*QueuedReader[R]) SetEOFHandlerFunc ¶
func (q *QueuedReader[R]) SetEOFHandlerFunc(handler ErrorHandlerFunc[R])
SetEOFHandlerFunc sets the function called when EOF occurs (note that this will not stop the read in loop)
func (*QueuedReader[R]) SetPreReadHandlerFunc ¶
func (q *QueuedReader[R]) SetPreReadHandlerFunc(handler func(R))
SetPreReadHandlerFunc sets the function called before a read attempt (for network connections you can set deadline configuration or other things here)
func (*QueuedReader[R]) SetTimeoutHandlerFunc ¶
func (q *QueuedReader[R]) SetTimeoutHandlerFunc(handler ErrorHandlerFunc[R])
SetTimeoutHandlerFunc sets the function called when a timeout occurs (note that this will not stop the read in loop)