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). Includes a hash of the sorted roles so users with different role sets don’t share a group.
- Change
- A database change event.
- Delta
- Delta format for subscription updates.
- Query
Group - Coalesces subscriptions sharing the same query+args+auth_scope. 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 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
Key - Opaque dedup key for subscriptions sharing the same query+args+auth_scope.
- 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.