Terminus v0.0.2 Terminus.Chunker View Source

Module for reducing data chunks from streaming HTTP requests into structured data messages.

Link to this section Summary

Functions

Handles the conversion of the given binary data chunk into a list of one or more structured types.

Link to this section Functions

Link to this function

handle_chunk(data, atom)

View Source
handle_chunk(binary(), atom()) :: {list(), binary()}

Handles the conversion of the given binary data chunk into a list of one or more structured types.

Returns a tuple containing a list of events and a binary of any remaining data.

Examples

iex> "{\"foo\":\"bar\"}\n{\"foo\":\"bar\"}\n{\"fo"
...> |> Terminus.Chunker.handle_chunk(:ndjson)
{[%{"foo" => "bar"}, %{"foo" => "bar"}], "{\"fo"}