summaryrefslogtreecommitdiff
path: root/Network/Wai/Middleware/Braid/DESIGN.md
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2025-11-20 19:11:00 -0500
committerBen Sima <ben@bsima.me>2025-11-20 19:11:00 -0500
commitb69682dd5e6ee374d066dcbfc90e96b47fe341cf (patch)
tree04af90d5e212c1d135c0fc5731d2b17943012f4b /Network/Wai/Middleware/Braid/DESIGN.md
parent0d554cc268343687406c1ea1a87d35d1595e2503 (diff)
doc: add design docs for open epics
- Omni/Task/DESIGN.md: Task manager improvements - Biz/PodcastItLater/DESIGN.md: Architecture and features - Biz/PodcastItLater/TESTING.md: Test strategy - Network/Wai/Middleware/Braid/DESIGN.md: Keep-alive design
Diffstat (limited to 'Network/Wai/Middleware/Braid/DESIGN.md')
-rw-r--r--Network/Wai/Middleware/Braid/DESIGN.md27
1 files changed, 27 insertions, 0 deletions
diff --git a/Network/Wai/Middleware/Braid/DESIGN.md b/Network/Wai/Middleware/Braid/DESIGN.md
new file mode 100644
index 0000000..90c6016
--- /dev/null
+++ b/Network/Wai/Middleware/Braid/DESIGN.md
@@ -0,0 +1,27 @@
+# Braid Middleware Design
+
+**Goal**: Implement HTTP Keep-Alive mechanism for Braid updates to support real-time streams.
+
+## Current State
+`Network/Wai/Middleware/Braid.hs` implements the Braid protocol headers but lacks a robust mechanism to keep the connection open and push updates.
+
+## Design Requirements
+
+1. **Connection Management**:
+ - Identify Braid subscriptions via headers.
+ - Keep the response body open (streaming response).
+ - Handle client disconnects gracefully.
+
+2. **Update Channel**:
+ - Use a `TChan` or `BroadcastChan` to signal updates to the connection handler.
+ - When a resource changes, push a new Braid frame to the open stream.
+
+3. **Frame Format**:
+ - Adhere to Braid spec for patch frames.
+ - `Content-Type: application/json` (or relevant type).
+ - `Merge-Type: braid`.
+
+## Implementation Plan
+1. Modify middleware to hijack response for Braid requests.
+2. Spawn a lightweight thread to listen on an update channel.
+3. Stream chunks to the client.