summaryrefslogtreecommitdiff
path: root/Network/Wai/Middleware/Braid/DESIGN.md
diff options
context:
space:
mode:
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.