Vik.Authority (Vik v0.0.1-rc1)
View SourceActs as the central authority for active @codemirror/collab
sessions. Holds the authoritative master copy of every shard.
This enables real-time collaborative editing across multiple browser windows or devices.
Summary
Types
Session identifiers uniquely identify a collaborative session.
User identifiers uniquely identify every participant in a collaborative session.
Functions
Returns a specification to start this module under a supervisor.
Pulls any changes made since version
.
Returns the session with all relevant data for constructing the current CodeMirror document.
Joins a collaboration session.
Pushes new changes starting from version
.
Starts the authority.
Types
@opaque state()
@type suid() :: Vik.slug()
Session identifiers uniquely identify a collaborative session.
For convience, Shard slugs double as valid session identifiers as well.
@type uid() :: term()
User identifiers uniquely identify every participant in a collaborative session.
@type version() :: non_neg_integer()
Functions
Returns a specification to start this module under a supervisor.
See Supervisor
.
@spec fetch_changes(suid(), version()) :: [Vik.Authority.Update.t()] | :error
Pulls any changes made since version
.
@spec get_document(suid()) :: Vik.Authority.Session.t() | :error
Returns the session with all relevant data for constructing the current CodeMirror document.
Joins a collaboration session.
If not initialised yet, this will create a new session. When empty, the collaboration session will automatically close.
@spec push_changes(suid(), version(), [Vik.Authority.Update.t()]) :: :ok | :rejected
Pushes new changes starting from version
.
@spec start_link([]) :: :ok
Starts the authority.