Expand description
Real-time subscription system.
Forge provides automatic real-time updates via PostgreSQL LISTEN/NOTIFY. When tables change, affected subscriptions are invalidated and re-executed.
§Architecture
Client Gateway PostgreSQL
│ │ │
│─── Subscribe ───────>│ │
│ │── Execute query ───────>│
│<── Initial data ─────│<── Results ────────────│
│ │ │
│ │<── NOTIFY on change ───│
│ │── Re-execute query ───>│
│<── Delta update ─────│<── New results ────────│§Key Types
ReadSet- Tables a subscription depends onQueryGroup- Coalesced subscriptions sharing query+args+auth_scopeSubscriber- Lightweight subscriber within a query groupDelta- Change payload sent to clients
Structs§
- Auth
Scope - Authentication scope for query group identity. Two subscriptions with the same query+args but different auth scopes must be in different groups (different users see different data).
- Bloom
Filter - Bloom filter for probabilistic row-level tracking. False positives cause one unnecessary re-execution (caught by result hash comparison). False negatives never happen.
- Change
- A database change event.
- Delta
- Delta format for subscription updates.
- Query
Group - A query group is the primary unit of execution. Multiple subscribers watching the same query+args+auth_scope share a single group. On invalidation, the query executes once per group (not per subscriber).
- Query
Group Id - Compact identifier for query groups. u32 for cache-friendly storage.
- ReadSet
- Read set tracking tables and rows read during query execution.
- Session
Id - Unique session identifier.
- Session
Info - Information about a WebSocket session.
- Subscriber
- Lightweight subscriber within a query group. ~48 bytes.
- Subscriber
Id - Compact identifier for subscribers within a slab.
- Subscription
Id - Unique subscription identifier.
- Subscription
Info - Information about a server-side subscription (kept for backward compat).
- Subscription
State - Subscription state from the client’s perspective.
Enums§
- Change
Operation - Change operation type.
- Session
Status - Session status.
- Tracking
Mode - Tracking mode for read sets.