pub fn split_stream(
data_stream: BoxSourceStream,
) -> Pin<Box<dyn Stream<Item = Result<Vec<SourceMessage>, ConnectorError>> + Send>>
Expand description
This function splits a byte stream by the newline separator “(\r)\n” into a message stream. It can be difficult to split and compute offsets correctly when the bytes are received in chunks. There are two cases to consider:
- When a bytes chunk does not end with “(\r)\n”, we should not treat the last segment as a new line message, but keep it for the next chunk, and prepend it to the first line of the next chunk.
- When a bytes chunk ends with “(\r)\n”, there is no additional action required.