Chronicle. Group
(chronicle v0.1.2)
Copy Markdown
The durable envelope for a larger audited unit of work.
A group has its own identity and outcome and contains zero or more ordered
Chronicle.Events. Events in a group may come from unrelated mechanisms—for
example an Ecto update, an authorization decision, and a message publish.
A group is stored as a record row alongside its events rather than in a separate table: it shares their identity, actor, subject, and correlation columns, and adds only the child count. One signed ledger entry covers the group and all of its children.
Summary
Functions
Derives the end of a unit from its start and monotonic duration.
Types
@type t() :: %Chronicle.Group{ actor: map() | nil, correlation_id: String.t() | nil, data: map(), duration_us: non_neg_integer() | nil, ended_at: DateTime.t() | nil, error: map() | nil, event_count: non_neg_integer() | nil, id: String.t(), metadata: map(), outcome: Chronicle.Event.outcome(), started_at: DateTime.t(), subject: map() | nil, tenant: map() | nil, type: String.t() }
Functions
@spec complete( t(), Chronicle.Event.outcome(), non_neg_integer(), non_neg_integer(), map() | nil ) :: t()
@spec ended_at(DateTime.t(), non_neg_integer() | nil) :: DateTime.t() | nil
Derives the end of a unit from its start and monotonic duration.
duration_us is measured monotonically, so deriving the end from it is
consistent by construction. A second wall-clock reading could disagree with
it, or move backwards across a clock adjustment.