Public facade for collaborative editing sessions.
open/1 seeds the snapshot and starts a supervised per-document session.
Writes (apply_op/2) are serialized through the session GenServer; reads
(fetch/1) bypass it entirely and read the CacheOwner-held ETS snapshot.
Summary
Functions
Applies an op to the session (server-serialized write). For OT-mediated concurrent edits use submit_op/2.
Stops the session and drops its cached snapshot.
Reads the current document snapshot directly from the cache (bypasses the server).
Seeds the snapshot and starts a supervised session. Returns its doc_id (pass :id to choose one).
Submits an OT Pending op; it is transformed against concurrent edits, applied, and the new version returned (:noop if dropped).
Returns the session's current version counter.
Returns the session GenServer pid for doc_id, or nil if none is running.
Types
@type doc_id() :: term()
Functions
@spec apply_op(doc_id(), PdfEx.Op.t()) :: {:ok, PdfEx.Op.t()} | {:error, PdfEx.Error.t()}
Applies an op to the session (server-serialized write). For OT-mediated concurrent edits use submit_op/2.
@spec close(doc_id()) :: :ok
Stops the session and drops its cached snapshot.
@spec fetch(doc_id()) :: {:ok, PdfEx.Document.t()} | {:error, :no_session}
Reads the current document snapshot directly from the cache (bypasses the server).
@spec open(PdfEx.Document.t(), [{:id, doc_id()}]) :: {:ok, doc_id()} | {:error, term()}
Seeds the snapshot and starts a supervised session. Returns its doc_id (pass :id to choose one).
@spec submit_op(doc_id(), PdfEx.OT.Pending.t()) :: {:ok, PdfEx.Op.t() | :noop, non_neg_integer()} | {:error, PdfEx.Error.t()}
Submits an OT Pending op; it is transformed against concurrent edits, applied, and the new version returned (:noop if dropped).
@spec version(doc_id()) :: non_neg_integer()
Returns the session's current version counter.
Returns the session GenServer pid for doc_id, or nil if none is running.