Decree.Store.EventData (decree v0.1.0)

Copy Markdown View Source

EventData contains the data for a single event before being persisted to storage

tags are stored with the event, in the same transaction. A repeated tag is stored once. A tag that is not a string Postgres can hold refuses the append with {:error, :invalid_tag}, and one over 512 bytes with {:error, :tag_too_long}.

required_tag_kinds are the kinds this event may not be stored without. They are checked and not stored. An event lacking one refuses the append with {:error, :missing_required_tag}, and a list that is not kinds with {:error, :invalid_required_tag_kinds}. A kind is carried by a tag equal to it, or by a tag <kind>:<value> with a value, so "email:" does not carry "email".

Summary

Functions

The most bytes a tag can have.

Whether a value is a string Postgres can hold as a tag: a binary of valid UTF-8 with no NUL byte. Its length is max_tag_bytes/0's question.

Types

t()

@type t() :: %Decree.Store.EventData{
  causation_id: String.t() | nil,
  correlation_id: String.t() | nil,
  data: term(),
  event_id: uuid() | nil,
  event_type: String.t(),
  metadata: term() | nil,
  required_tag_kinds: list(),
  tags: [String.t()]
}

uuid()

@type uuid() :: String.t()

Functions

fetch(map, key)

get_and_update(map, key, fun)

max_tag_bytes()

The most bytes a tag can have.

valid_tag?(tag)

@spec valid_tag?(term()) :: boolean()

Whether a value is a string Postgres can hold as a tag: a binary of valid UTF-8 with no NUL byte. Its length is max_tag_bytes/0's question.