service library
A journal's one writer, which other processes send entries to over a Unix socket. It checks two things before it adds anything: that the sender's user may write the entry's kind, and that the entry names the tip of its chain as previous.
A request is the bytes to record, which start with a header the service reads and keeps:
<kind>\n<previous>\n<the rest>
<kind> is a name the sender table lists for the sender's user, and
<previous> is the hash of the entry before this one in its chain, or
- to start a chain. The sender closes its side when it has sent the request, and the
service answers one line: ok <entry hash>, or refused <why>, which
for an entry that is not its chain's tip names the tip, so the sender can
read it and try again. What it refuses it does not add.
The service reads the sender's user from the socket, as the kernel
reports it, never from the request. On every start it adds an entry of
kind started holding the sender table in force, so the record shows
who was allowed to write what. Which names exist is the table's to say,
and every kind means nothing to the service but two.
A journey path's chain is owned. An entry of kind Kind.assigned starts it and names the one user who may extend it, its loop user, and the user that wears its suit. No path is assigned twice, and no user is in use by two open paths. An entry of kind Kind.ended closes every chain of its journey. A kind the table lists as attaching starts a chain that names its parent entry on its first body line, and belongs to that entry's path. Every other chain takes an entry from any user the table lets send its kind. Who owns what is read back from the journal on every start, so a restart refuses exactly what the live service did.
Classes
- JournalService
-
The writer of journal, listening on
socket. - Kind
-
The kind of an entry: a name of letters, digits,
.,_and-. Not-, which reads as "no previous entry", and not started, which only the service writes. - SenderTable
-
Which kinds each user may send: a line per user, the user's name or id
and then the kinds, separated by spaces. Blank lines and lines starting
with
#are skipped.