Write the routing table every second and read it at startup (part of #122)
check / check (push) Canceled after 0s

The prefix handler applies each update to the routing table in memory as
it handles it, sorted into announcements and withdrawals as for the live
route tables. Each flush writes the table's changes first. A failed write
puts its changes and new peers back in the table, so the next write takes
them with each pair's content then. Stop writes the last changes, and
logs those left when its deadline passes.

Startup reads the table before the streamer connects, and logs its pairs,
peers and time. The per-peer counts are a slice, so the read takes about
a third less time. The health check's start period is 60 seconds, so a
full table's read fits before upaas looks.

Model: opus-5-5
This commit is contained in:
2026-10-27 08:40:57 +00:00
parent eda37da369
commit 267a8153cf
14 changed files with 829 additions and 98 deletions
+8 -2
View File
@@ -285,6 +285,8 @@ routewatch/
2. **Initialization** (`internal/routewatch/app.go`)
- Database created with SQLite schema (WAL mode, page caches as in "Memory")
- The routing table read from the database into memory, before the streamer
connects
- Message handlers registered with the streamer
- HTTP server started on configured port
@@ -311,7 +313,9 @@ routewatch/
holds AS 0 anywhere, deletes all of a peer's routes when its BGP session
goes down). Routes are kept per peer IP, so when one peer IP has sessions
on two collectors, a session going down on one also removes the routes the
other still carries, until they are announced again.
other still carries, until they are announced again. It also applies each
update to the routing table in memory, and writes the table's changes to
the database every second.
- **PeeringHandler**: Extracts AS peering relationships from AS paths
5. **HTTP Request Flow**
@@ -495,7 +499,9 @@ What the [upaas](https://git.eeqj.de/sneak/upaas) app needs:
- Health check: the image's `HEALTHCHECK` requests
`/.well-known/healthcheck.json` on the container port. upaas reads the
container's health 60 seconds after a deploy and fails the deploy unless it is
`healthy`.
`healthy`. For the first 60 seconds, Docker 25 and later runs the check every
5 seconds, and the first pass makes the container healthy. Startup first reads
the routing table, which takes about 25 seconds when the table is full.
- Stop grace: the container needs 9 seconds between SIGTERM and SIGKILL. upaas
gives 10 (`stopTimeoutSeconds` in its `internal/docker/client.go`), as
`docker stop` does by default. The daemon allows 8 seconds for the handlers to