| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
Free.Agent.Bus.Daemon
Description
The stamping office: a single-writer daemon for the bus.
The bus has two stamping regimes:
- Office off: writers self-stamp with
postLocal— the entangled case, where concurrent writers may race for ids. - Office on: writers send bare
Postlines to the daemon over a named pipe (root/bus.fifo); the daemon stamps them in arrival order and appends tolog.jsonl. This serialisation is the bus's ⅋ discipline made into a process.
The daemon is intentionally stateless: it assigns ids by counting lines in
the log under the same exclusive lock that postLocal uses, so the two
regimes can coexist during a transition without colliding.
Daemon
runDaemon :: PostBody a => FilePath -> IO () Source #
Run the stamping office forever.
Creates the bus directory, touches log.jsonl, creates the FIFO if absent,
then reads one bare Post line at a time. Malformed lines are reported on
stderr and skipped; valid lines are stamped and appended.
Client
postViaDaemon :: FilePath -> Post Text -> IO (Stamped Text) Source #
Submit a bare post to the daemon and wait for the receipt.