Download this file
| 1 | package home |
| 2 | |
| 3 | import ( |
| 4 | "log/slog" |
| 5 | |
| 6 | "amadan.net/rastrillo/rastrillo/db" |
| 7 | ) |
| 8 | |
| 9 | // OpenDatabase opens Home's database as cmd/home serves it. |
| 10 | // |
| 11 | // DurableCommits: synchronous(FULL), a WAL sync on every commit, which |
| 12 | // is what every rastrillo before v0.34.0 opened with (since v0.34.0 |
| 13 | // db.Open defaults to NORMAL). This database is credentials, the roster |
| 14 | // and the sealed link store, none of which rebuilds (AGENTS.md, |
| 15 | // Deploys), so a power cut must not undo a commit already answered; |
| 16 | // Home's write rate is far below what FULL costs. |
| 17 | // TestOpenDatabaseCommitsDurably holds it. |
| 18 | // |
| 19 | // Call RegisterSecureDelete first: Open pings, which opens the writer |
| 20 | // pool's one long-lived connection, and a hook registered after that |
| 21 | // misses it. |
| 22 | func OpenDatabase(path string, logger *slog.Logger) (*db.DB, error) { |
| 23 | return db.Open(path, logger, db.DurableCommits()) |
| 24 | } |
| 25 | |