Skip to content

feat: typed Server-Sent Events (ctx.sse + SseEvent) - #173

Merged
ruslan-primesec merged 9 commits into
mainfrom
feat/typed-sse
Aug 16, 2026
Merged

feat: typed Server-Sent Events (ctx.sse + SseEvent)#173
ruslan-primesec merged 9 commits into
mainfrom
feat/typed-sse

Conversation

@ruslan-primesec

Copy link
Copy Markdown
Collaborator

Summary

Adds a first-class Server-Sent Events API, built entirely on the ctx.stream primitive (v0.9.0). Closes most of #2.

  • SseEvent — typed events: SseEvent::new(&payload) serializes any Serialize value to the data: field; .event/.id/.retry + comment; multi-line-safe wire encoding.
  • ctx.sse(stream)text/event-stream response with Cache-Control: no-cache, X-Accel-Buffering: no, no Content-Length.
  • ctx.sse_keep_alive(stream, interval) — injects : ping when idle; terminates with the event stream.
  • sse_channel() -> (SseSender, Stream) — mpsc push/broadcast helper; SseSender: Clone + Send.
  • ctx.last_event_id() — surfaces the Last-Event-ID header for app-driven resume.
  • app.sse(path, handler) — GET route sugar.

Design

No new dependency (reuses futures-util, tokio mpsc, serde_json) and no Cargo feature — always available, like streaming. Additive only → patch (0.9.1).

Scoped to the SSE transport (layer A). The tRPC-style ts-rs-derived typed subscriptions (layer B) remain a separate roadmap item — the roadmap row is split accordingly.

Tests

  • Unit: SseEvent encoding (data/event/id/retry lines, multi-line split, comment).
  • Integration (tests/sse.rs): headers + no Content-Length + wire frames; sse_channel delivery; keep-alive passthrough + idle ping; last_event_id; app.sse route.

Docs

New sse.mdx + sidebar, api-reference entries, README, roadmap split, runnable examples/sse (browser EventSource + documented TS wrapper).

🤖 Generated with Claude Code

creotip and others added 9 commits August 16, 2026 14:42
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ple)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added type: test Tests area: core Core framework area: examples Examples area: docs Documentation site labels Aug 16, 2026
@vercel

vercel Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs-site Ready Ready Preview Aug 16, 2026 12:01pm
ultimo-website Ready Ready Preview Aug 16, 2026 12:01pm

@ruslan-primesec
ruslan-primesec merged commit f7e810e into main Aug 16, 2026
19 checks passed
@ruslan-primesec
ruslan-primesec deleted the feat/typed-sse branch August 16, 2026 12:05
This was referenced Aug 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: core Core framework area: docs Documentation site area: examples Examples size: XL type: test Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants