Bounded admission owner for the durable agent-session event log.
record/4 synchronously performs only queue admission. Accepted critical events receive a receipt and later deliver {:event_log_commit, receipt, event_type, result} to the admitting process. The result is {:persisted, event_id} only after SQLite reports the insert committed, or {:error, {:persistence_failed, reason}} when durability cannot be established.
A separately monitored MingaAgent.EventLog.Writer owns the SQLite connection and executes inserts and retention serially. SQLite stalls therefore do not prevent EventLog from admitting work up to its configured bound or rejecting excess work explicitly.
Summary
Functions
Waits for the durability result associated with a critical-event receipt.
Waits until all currently outstanding event-log work has completed.
Returns a specification to start this module under a supervisor.
Returns the configured event-log database path.
Queries events for a session after the given cursor.
Returns the latest event id for a session.
Opens an independent read connection to the agent event database.
Admits a durability-critical event to the bounded ordered queue.
Admits a high-rate event without requesting a durability acknowledgment.
Requests an immediate writer restart when admission is unavailable.
Starts the bounded event-log admission owner and its monitored writer.
Returns one session's durably admitted file touches, most recent first.
Returns the current monitored writer pid, primarily for operational inspection.
Types
@type admission_error() ::
{:error, :overloaded | :unavailable | :payload_too_large | :invalid_payload}
@type admission_result() :: {:queued, receipt()} | admission_error()
@type best_effort_admission_result() :: :queued | admission_error()
@type persistence_result() :: {:persisted, pos_integer()} | {:error, {:persistence_failed, term()}}
@type receipt() :: reference()
Functions
@spec await(receipt(), timeout()) :: persistence_result() | {:error, :timeout}
Waits for the durability result associated with a critical-event receipt.
@spec await_idle(GenServer.server(), timeout()) :: :ok | {:error, :timeout | :unavailable}
Waits until all currently outstanding event-log work has completed.
Returns a specification to start this module under a supervisor.
See Supervisor.
Returns the configured event-log database path.
@spec events_after( MingaAgent.EventLog.Store.db(), String.t(), non_neg_integer(), pos_integer() ) :: {:ok, [MingaAgent.EventLog.EventRecord.t()]} | {:error, term()}
Queries events for a session after the given cursor.
@spec latest_id(MingaAgent.EventLog.Store.db(), String.t()) :: {:ok, non_neg_integer()} | {:error, term()}
Returns the latest event id for a session.
@spec open_read_connection(keyword()) :: {:ok, MingaAgent.EventLog.Store.db()} | {:error, term()}
Opens an independent read connection to the agent event database.
@spec record( String.t(), MingaAgent.EventLog.EventRecord.event_type(), map(), GenServer.server() ) :: admission_result()
Admits a durability-critical event to the bounded ordered queue.
This call performs no SQLite work. {:queued, receipt} means admission only; the caller later receives the documented {:event_log_commit, receipt, event_type, result} message after the writer reports success or failure.
@spec record_best_effort( String.t(), MingaAgent.EventLog.EventRecord.event_type(), map(), GenServer.server() ) :: best_effort_admission_result()
Admits a high-rate event without requesting a durability acknowledgment.
The return value reports queue admission only. Accepted events share the same ordered queue as critical events, may be rejected under pressure, and never send a durability acknowledgment.
@spec restart_writer(GenServer.server()) :: :ok | {:error, :unavailable}
Requests an immediate writer restart when admission is unavailable.
@spec start_link(keyword()) :: GenServer.on_start()
Starts the bounded event-log admission owner and its monitored writer.
@spec touched_files(String.t(), GenServer.server()) :: {:ok, [MingaAgent.EventLog.TouchedFiles.touch()]} | {:error, :unavailable}
Returns one session's durably admitted file touches, most recent first.
@spec writer_pid(GenServer.server()) :: pid() | nil
Returns the current monitored writer pid, primarily for operational inspection.