Documentation ¶
Overview ¶
Package multiplexio exposes structs implementing and wrapping canonical I/O interfaces to tokenize, process and aggregate them with custom functions.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ByStringLess ¶
Implementation of Options.Less using the alphabetical string ordering.
func NewReader ¶
func NewReader(options Options, sources ...Source) io.ReadCloser
NewReader returns an io.ReadCloser aggregating, according to a given ordering, tokens extracted concurrently from a set of io.Reader wrapped in a set of Source. Tokens of a given io.Reader go through the Write function passed together in the Source struct, or WriteNewLine if it is not set.
If the corresponding functions are not passed in Options, bufio.ScanLines is used for scanning and extracting tokens from the wrapped io.Reader objects, and ByStringLess is invoked for defining the order of these onto the aggregated stream.
Types ¶
type Options ¶
type Options struct { Split bufio.SplitFunc // function used for scanning and extracting tokens Less func(i, j []byte) bool // function used for ordering extracted tokens, with sort.Interface.Less semantics }
Options are the options for creating a new Reader.
type Source ¶
type Source struct { Reader io.Reader // incoming stream Write func(dest io.Writer, token []byte) (n int, err error) // function used for formatting and dumping extracted tokens }
Source combines an io.Reader from which tokens will be extracted with the Write function that will format them and dump them into the aggregated stream.