Key changes:
- **src/config.rs** – `LiveVueConfig` (server host/port, brotli quality +
window size), loaded from `livevue.toml`. A notify-based file watcher
reloads the config on any file change; a SIGHUP handler does the same on
demand. Falls back to compiled-in defaults when the file is absent.
- **src/brotli_layer.rs** – `BrotliBody`, a custom `http_body::Body` wrapper
that streams brotli-compressed data through a single persistent
`brotli::CompressorWriter`. The encoder survives across SSE event flushes,
so its sliding window accumulates context from all prior events —
progressively better compression as the stream grows. Both quality (0–11)
and window size (lgwin 10–24, i.e. 1 KB – 16 MB) are taken from config.
`brotli_compression` is an axum `from_fn_with_state` middleware that
activates only when the client sends `Accept-Encoding: br`.
- **src/server.rs** – `AppState` gains a `config: SharedConfig` field.
`AppState::new` takes the config; `AppState::new_default` is a zero-config
convenience constructor.
- **livevue.toml** – documented example config with inline comments
explaining each field and the brotli window-size tradeoff table.
- **examples/todo** – loads config via `load_and_watch_config`, derives the
bind address from `config.server`, and applies `brotli_compression` as a
router layer.
https://claude.ai/code/session_01UnQQkkwts64FPUsSzFfdQb
Implements a PostgreSQL logical replication module that streams WAL
changes, buffers them per XID for transaction atomicity, and publishes
CacheKey invalidation events to the existing framework broadcast channel.
Key design choices:
- Transaction atomicity: changes are buffered until COMMIT so the fanout
always receives a consistent view. A 1000-row bulk-insert emits one
table-level CacheKey, not 1000 row events.
- Native protocol: uses a self-contained raw TCP + postgres-protocol
implementation for the replication connection (tokio-postgres 0.7 does
not expose copy_both_simple publicly).
- Corrected pgoutput v1 parser: original maybe_sql_integration code
incorrectly read XID from DML messages; DML messages carry no XID in
proto v1 — only Begin does.
- Clean integration: publishes CacheKey::Channel events to store.events
so the existing fanout task picks them up with zero changes to the
fanout loop.
- New cx.subscribe(key) API on RenderContext for manually registering
subscription keys (needed when queries go through PgPool, not cx.run).
New files:
src/pg_replication/mod.rs — PgReplicationListener, key helpers
src/pg_replication/wal_parser.rs — pgoutput v1 binary protocol parser
src/pg_replication/emitter.rs — WalEmitter (tx-buffering + CacheKey emit)
src/pg_replication/proto.rs — raw TCP PG wire-protocol connection
examples/pg_replication/main.rs — live message board example
docker-compose.yml — PG 16 container with wal_level=logical
Run the example:
docker compose up -d
cargo run --example pg_replication --features pg_replication
https://claude.ai/code/session_01SLGgXeqKV2o7KTmCaQZZPg