View Source Lightning.Runtime.LogAgent.StringBuffer (Lightning v2.10.4)

Internal datastructure to hold and process new bytes for a list of characters.

By checking the if the buffer is a complete grapheme, emitting the buffer once valid and returning nil otherwise.

In the case of emojis and other language character sets, a character (in UTF-8) can be between 1-4 bytes - when streaming logs for example it's quite easy to receive less than the whole character which can result in crashes or corrupt text.

Summary

Types

@type t() :: {buffer :: buffer(), chunk_state :: chunk_state()}

Functions

@spec buffer(state :: t()) :: [binary()]
@spec new() :: t()
Link to this function

process_chunk(data, arg)

View Source
@spec process_chunk(data :: any(), state :: t()) :: {binary() | nil, t()}
@spec reduce_chunk(data :: any(), chunk_state :: chunk_state()) ::
  {binary() | nil, chunk_state()}