I am working on a project that captures Postgres CDC and forwards the changes to a NATS message broker.
It’s essentially a lightweightDezebiul-lik solution, but with a much smaller footprint (≈15 MB image, ≈7 MB RAM).
The project is already fairly advanced, though it likely still needs polishing and—most importantly—feedback and challenges from others.
While the project is not a pur Zig implementation. - I vendor the NATS client nats.c and libpq because pg.zig did not cover all my needs - but the architectural ideas might still be of interest.
Ah!! thks, I don’t know why I did not see this.. yours looks good. I still use a KV store though. Maybe I can just use a “singleton” stream instead? MaxMsgsPerSubject: 1, Discard: Old, MaxAge: 0
I use zig-messagepack library by default to encode to NATS if you connect a backend to NATS, but you can switch to JSON if you connect via a JS client so that you can populate a WASM db (SQLite or PGLIte directly).
EDIT
For the NATS client, I need more than a sync `nats.publish`, I need the non-blocking `nats.publishAsync` and then `nats.flush` to ensure delivery for PG to prune the WAL with the last LSN. I also need the reconnection mechanism.