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
37 lines
1.3 KiB
Rust
37 lines
1.3 KiB
Rust
pub mod signal;
|
|
pub mod query;
|
|
pub mod store;
|
|
pub mod context;
|
|
pub mod connection;
|
|
pub mod sse;
|
|
pub mod server;
|
|
pub mod config;
|
|
pub mod brotli_layer;
|
|
|
|
/// PostgreSQL logical replication module.
|
|
///
|
|
/// Enabled via the `pg_replication` Cargo feature:
|
|
/// ```toml
|
|
/// livevue-rs = { features = ["pg_replication"] }
|
|
/// ```
|
|
#[cfg(feature = "pg_replication")]
|
|
pub mod pg_replication;
|
|
|
|
/// PostgreSQL query trait and macros (`pg_query_one!`, `pg_query_all!`).
|
|
///
|
|
/// Use `cx.run_pg(pool, query)` in render functions to execute a `PgQuery`
|
|
/// and auto-subscribe to its cache key, exactly like `cx.run()` for SQLite.
|
|
#[cfg(feature = "pg_replication")]
|
|
pub mod pg_query;
|
|
|
|
pub use signal::{Signal, SignalStore, SignalOpts, mangle, client_only, global, data_signals};
|
|
pub use query::{CacheKey, Query};
|
|
pub use store::{Store, KVStore};
|
|
#[cfg(feature = "pg_replication")]
|
|
pub use pg_query::PgQuery;
|
|
pub use context::{RenderContext, ComponentTree, ComponentNode};
|
|
pub use connection::{ConnectionManager, ConnectionState, SubscriptionRegistry};
|
|
pub use sse::{format_patch_elements, format_patch_signals};
|
|
pub use server::{AppState, SharedState, RenderFn, sse_handler, spawn_fanout, ingest_signals, ActionParams, SseParams};
|
|
pub use config::{LiveVueConfig, ServerConfig, BrotliConfig, SharedConfig, load_config, load_and_watch_config};
|
|
pub use brotli_layer::brotli_compression; |