Mercurial
comparison seobeo/README.md @ 257:609d3c6aff4e
[seobeo] Add persistent SSE streams
Co-authored-by: Copilot <[email protected]>
| author | MrJuneJune <me@mrjunejune.com> |
|---|---|
| date | Tue, 04 Aug 2026 16:49:11 -0700 |
| parents | 745fd127b2a1 |
| children |
comparison
equal
deleted
inserted
replaced
| 256:30c2196d03d4 | 257:609d3c6aff4e |
|---|---|
| 6 | 6 |
| 7 - HTTP/HTTPS client | 7 - HTTP/HTTPS client |
| 8 - SSL/TLS support | 8 - SSL/TLS support |
| 9 - Async networking with libuv | 9 - Async networking with libuv |
| 10 - Joinable/detached tasks and bounded worker pools | 10 - Joinable/detached tasks and bounded worker pools |
| 11 - Server-Sent Events routes and event framing | |
| 11 - Snapshot testing utilities | 12 - Snapshot testing utilities |
| 12 | 13 |
| 13 ## Files | 14 ## Files |
| 14 | 15 |
| 15 | File | Description | | 16 | File | Description | |
| 16 |------|-------------| | 17 |------|-------------| |
| 17 | `seobeo.h` | Public API header | | 18 | `seobeo.h` | Public API header | |
| 18 | `seobeo_internal.h` | Internal declarations | | 19 | `seobeo_internal.h` | Internal declarations | |
| 19 | `s_http_client.c` | HTTP client implementation | | 20 | `s_http_client.c` | HTTP client implementation | |
| 20 | `s_network.c` | Network utilities | | 21 | `s_network.c` | Network utilities | |
| 22 | `s_sse.c` | Server-Sent Events framing and stream lifecycle | | |
| 21 | `s_ssl.c` | SSL/TLS handling | | 23 | `s_ssl.c` | SSL/TLS handling | |
| 22 | `s_logging.c` | Logging utilities | | 24 | `s_logging.c` | Logging utilities | |
| 23 | `s_worker.c` | Thread and worker-pool implementation | | 25 | `s_worker.c` | Thread and worker-pool implementation | |
| 24 | `seobeo_worker.h` | Public worker API | | 26 | `seobeo_worker.h` | Public worker API | |
| 25 | `snapshot_creator.c/h` | Snapshot testing | | 27 | `snapshot_creator.c/h` | Snapshot testing | |
| 86 Submitting transfers context ownership only when it returns | 88 Submitting transfers context ownership only when it returns |
| 87 `SEOBEO_WORKER_OK`. Cleanup runs after successful work and for queued tasks | 89 `SEOBEO_WORKER_OK`. Cleanup runs after successful work and for queued tasks |
| 88 discarded by a non-draining shutdown. User callbacks never run while the pool | 90 discarded by a non-draining shutdown. User callbacks never run while the pool |
| 89 mutex is held. | 91 mutex is held. |
| 90 | 92 |
| 93 ## Server-Sent Events | |
| 94 | |
| 95 Register an SSE route separately from ordinary response and stream handlers: | |
| 96 | |
| 97 ```c | |
| 98 static void Build_Events( | |
| 99 Seobeo_SSE_Stream *p_stream, | |
| 100 Seobeo_Request_Entry *p_request, | |
| 101 Dowa_Arena *p_arena) | |
| 102 { | |
| 103 (void)p_request; | |
| 104 (void)p_arena; | |
| 105 Seobeo_SSE_Event event = { | |
| 106 .event = "build", | |
| 107 .id = "42", | |
| 108 .data = "started\ncompiling", | |
| 109 .retry_ms = 2000, | |
| 110 }; | |
| 111 Seobeo_SSE_Send(p_stream, &event); | |
| 112 Seobeo_SSE_Send_Comment(p_stream, "heartbeat"); | |
| 113 } | |
| 114 | |
| 115 Seobeo_Router_Register_SSE("/events/builds", Build_Events); | |
| 116 ``` | |
| 117 | |
| 118 SSE handlers run once when a client connects and must return promptly so edge | |
| 119 workers remain available. Call `Seobeo_SSE_Retain` before storing a stream for | |
| 120 later work and pair it with `Seobeo_SSE_Release`; use | |
| 121 `Seobeo_SSE_Is_Open` before sending. Do not retain the request map or arena | |
| 122 after the handler returns. A return value of `1` means the record was retained | |
| 123 behind socket backpressure and `Seobeo_SSE_Flush` should be retried later. | |
| 124 `SEOBEO_SSE_BACKPRESSURE` means the bounded pending queue is full and the new | |
| 125 record was not accepted. Events are bounded by the handle write-buffer | |
| 126 capacity so one record is queued atomically; larger records return | |
| 127 `SEOBEO_SSE_EVENT_TOO_LARGE`. | |
| 128 | |
| 91 ## Dependencies | 129 ## Dependencies |
| 92 | 130 |
| 93 - libuv (via //third_party/libuv) | 131 - libuv (via //third_party/libuv) |
| 94 - OpenSSL | 132 - OpenSSL |