Slap.Streams.Offset (slap_streams v0.3.0)

Copy Markdown View Source

Offsets on the wire, in the official server's format and accounting, so that offsets stay valid for streams migrated from it.

A token is "0000000000000000_" <> byte_offset zero-padded to 16 decimal digits. Each stored message advances the offset by 4 + byte_size(message), the official file store's framing (a 4-byte length prefix), although the prefix is not stored here.

Summary

Functions

The offset after a message of size bytes stored at offset.

The token for byte_offset.

Parses a client offset. "-1" (and an absent offset, nil or "") is :start, the earliest data the stream still has (after a trim, not 0); "now" is :now.

Types

t()

@type t() :: non_neg_integer()

Functions

advance(offset, size)

@spec advance(t(), non_neg_integer()) :: t()

The offset after a message of size bytes stored at offset.

encode(byte_offset)

@spec encode(t()) :: String.t()

The token for byte_offset.

parse(arg1)

@spec parse(String.t() | nil) :: {:ok, t() | :start | :now} | {:error, :bad_offset}

Parses a client offset. "-1" (and an absent offset, nil or "") is :start, the earliest data the stream still has (after a trim, not 0); "now" is :now.