ExAthena.Sessions.Stores.Jsonl (ExAthena v0.4.6)

Copy Markdown View Source

ETS-buffered JSONL session store.

Hot-path appends go to an in-memory ETS table keyed by monotonic time so writes never block the loop. A background process flushes buffered events to JSONL files every 250ms (or immediately when forced via flush/1).

Path: <root>/<session_id>.jsonl. root defaults to <cwd>/.exathena/sessions/; configurable via the :root option passed to start_link/1.

Each JSONL line is one event: {"ts": "...", "event": "...", "data": {...}, "uuid": "..."}.

Summary

Functions

Returns a specification to start this module under a supervisor.

Force a synchronous flush (for tests + clean shutdown).

Resolved storage path for a session id (for tests + tooling).

Test helper: clear all buffered events + storage root.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

flush(server \\ __MODULE__)

@spec flush(GenServer.server()) :: :ok

Force a synchronous flush (for tests + clean shutdown).

path_for(session_id)

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

Resolved storage path for a session id (for tests + tooling).

reset(root \\ nil)

@spec reset(String.t() | nil) :: :ok

Test helper: clear all buffered events + storage root.

start_link(opts \\ [])

@spec start_link(keyword()) :: GenServer.on_start()

Options:

  • :root (default: Path.join(File.cwd!(), ".exathena/sessions"))
  • :flush_interval_ms (default 250).
  • :name (default __MODULE__).