The last limit lines of a stream, kept as they arrive.
tail = ETee.Tail.new(1000)
tail = ETee.Tail.push(tail, "some output\n")
ETee.Tail.to_binary(tail)The limit is a line count. A limit of 0 keeps nothing and discards every push;
:infinity keeps everything. Bytes are stored exactly as pushed, so a line split
across pushes is still one line and carriage returns do not end one.
Pushing appends and does not touch what is already held. The buffer is trimmed back to
limit lines once it has grown well past the limit, and again on every read, so
to_binary/1, lines/1 and bytes/1 all report the trimmed buffer.
Summary
Functions
How many bytes are held.
Whether the buffer has reached its limit and is dropping lines.
How many lines are held, counting an unfinished one.
An empty buffer keeping at most limit lines.
Append bytes, discarding them entirely when the limit is 0.
Everything held, oldest first.
Types
@type t() :: %ETee.Tail{ bytes: non_neg_integer(), chunks: [binary()], limit: non_neg_integer() | :infinity, newlines: non_neg_integer() }
Functions
@spec bytes(t()) :: non_neg_integer()
How many bytes are held.
Whether the buffer has reached its limit and is dropping lines.
@spec lines(t()) :: non_neg_integer()
How many lines are held, counting an unfinished one.
@spec new(non_neg_integer() | :infinity) :: t()
An empty buffer keeping at most limit lines.
Append bytes, discarding them entirely when the limit is 0.
Everything held, oldest first.