Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Reader ¶
Reader reads from another io.Reader and de-multiplexes line-oriented data into different io.Reader streams.
Lines are delimited with the '\n' character.
When `Read` is called, any data that doesn't currently have a prefix registered will be discarded. Data won't start being discarded until the first Read is called on a prefix. Once the first Read is called, data is read until EOF. Therefore, be sure to request all prefix readers before issuing any Read calls on any prefixes.
Reads will block if all the readers aren't routinely draining their buffers. Therefore, be sure to be actively reading from all registered prefixes, otherwise you can encounter deadlock scenarios.
func (*Reader) Prefix ¶
Prefix returns a new io.Reader that will read data that is prefixed with the given prefix.
The read data is line-oriented so calling Read will result in a full line of output (including the line separator), but is exposed as an io.Reader for useful utility interoperating with other Go libraries.
The data read has the prefix stripped, but contains the line delimiter.
An empty prefix "" will read the data before any other prefix match is found, allowing you to have a default reader before a prefix is matched.