MingaAgent.EventLog.TouchedFiles (Minga v0.1.0)

Copy Markdown View Source

Projects the latest admitted file edit for each path in an agent session.

Durable event ids define recency. Replaying the same event or an older event cannot replace a newer touch for the same path.

Summary

Types

How the latest admitted edit changed a file.

Why a file-edit event cannot enter the projection.

t()

Extension-facing summary of one touched file.

Functions

Lists one session's latest file touches, most recent first.

Creates an empty touched-file projection.

Rebuilds the projection from persisted events in durable order.

Applies one durably identified event to the projection.

Validates fields required to project a file-edit event.

Types

action()

@type action() :: :created | :modified | :deleted

How the latest admitted edit changed a file.

rejection()

@type rejection() ::
  {:invalid_file_edit, :event_id | :path | :before_content | :after_content}

Why a file-edit event cannot enter the projection.

t()

@type t() :: %MingaAgent.EventLog.TouchedFiles{
  by_session: %{required(String.t()) => session_entries()}
}

touch()

@type touch() :: %{path: String.t(), action: action(), timestamp: integer()}

Extension-facing summary of one touched file.

Functions

list(projection, session_id)

@spec list(t(), String.t()) :: [touch()]

Lists one session's latest file touches, most recent first.

new()

@spec new() :: t()

Creates an empty touched-file projection.

rebuild(events)

@spec rebuild([MingaAgent.EventLog.EventRecord.t()]) ::
  {:ok, t()} | {:error, rejection()}

Rebuilds the projection from persisted events in durable order.

record(projection, event, event_id)

@spec record(t(), MingaAgent.EventLog.EventRecord.t(), pos_integer()) ::
  {:ok, t()} | {:error, rejection()}

Applies one durably identified event to the projection.

validate(event_record)

@spec validate(MingaAgent.EventLog.EventRecord.t()) :: :ok | {:error, rejection()}

Validates fields required to project a file-edit event.