Expand description
Hot-reload of TOML rule packs.
ProviderRegistry is constructed once at boot today; adding
a new vendor TOML requires a process restart. Production
deployments hate restarts, especially when the only thing that
changed is data (a new [[provider]] block), not code.
HotReloadRegistry wraps an Arc<ProviderRegistry> behind
an arc-swap style atomic load + a background polling task.
Operators drop a new TOML into the watched directory; the
background task notices the mtime change, re-loads + re-builds
the registry, and atomically swaps the pointer. In-flight
detects see whichever version was current at the start of their
call; concurrent solves never observe a partially-loaded
registry.
§Pure-Rust polling watcher
No notify crate dependency — that would pull in OS-specific
inotify/kqueue/ReadDirectoryChangesW bindings + their build
infrastructure. A 2-second mtime poll is sufficient for the
“ops drops a TOML” use case (we don’t need millisecond
reactions; minutes-scale config rollouts are the norm). The
poller skips when no file in the watched dir changed, so the
steady-state cost is one stat() per file every 2 seconds.
§What this module does NOT ship
- Schema-validation feedback. If a new TOML has bad syntax,
the load fails + we log; the previously-loaded registry stays
active. Operators want a
validate-rulespre-flight before dropping the file in production — that’s [captchaforge cli validate-rules]. - Per-file change tracking. We re-scan the whole dir on any change; cheap because rule packs are <100KB total.
Structs§
- HotReload
Registry - Hot-reloadable provider registry.