Skip to content

docs: Server-Sent Events how-to + built-in SSE marshaler references#91

Open
ankurs wants to merge 1 commit into
mainfrom
feat/sse-docs
Open

docs: Server-Sent Events how-to + built-in SSE marshaler references#91
ankurs wants to merge 1 commit into
mainfrom
feat/sse-docs

Conversation

@ankurs
Copy link
Copy Markdown
Member

@ankurs ankurs commented May 18, 2026

Summary

Documents the auto-registered SSE marshaler shipped in core#92, which makes every server-streaming gateway RPC browser-EventSource-consumable out of the box.

New pagehowto/server-sent-events.md:

  • When to reach for SSE vs. native gRPC, WebSocket, or unary.
  • Wire format (data: <json>\n\n) + the gateway {"result": ...} wrapping behaviour.
  • EventSource and curl examples (covers the GET-only browser API caveat and the microsoft/fetch-event-source workaround for POST streams).
  • Handler patterns: context-cancellation propagation into LLM SDKs, TTFT as a distinct metric, per-outcome counters with OutcomeCanceled.
  • Opt-out via DISABLE_SSE_MARSHALER=true, plus how to register a custom text/event-stream marshaler that wins over the default.
  • Pitfalls — compression, reverse-proxy buffering, mid-stream errors, gateway envelope.

Cross-cutting updates:

  • config-reference.mdDISABLE_SSE_MARSHALER row added in the HTTP Gateway section.
  • howto/streaming-rpcs.md — gateway-shape table now lists SSE alongside NDJSON; a new bullet calls out the default behaviour and links to the new page; Related section gains the cross-link.
  • howto/gateway-extensions.md — built-ins list mentions the auto-registered text/event-stream marshaler and the override path.

Nav + tests:

  • nav_order: 22 for server-sent-events.md; database/cache/messaging each bumped by one (now 23/24/25) to keep streaming and SSE adjacent in the sidebar.
  • tests/pages.ts updated to match.

Test plan

  • cd docs.coldbrew.cloud && bundle exec jekyll serve — verify the new page renders, nav order is correct, internal links resolve.
  • npx playwright test against a local Jekyll server — tests/navigation.spec.ts walks every entry in allHowtoPages and asserts a 200 + visible heading on each, so the new page is covered automatically.
  • Confirm cross-references render correctly: /howto/streaming-rpcs//howto/server-sent-events/, and vice versa; /howto/gateway-extensions/ and /config-reference/ both link to the new page.

Adds howto/server-sent-events.md as a dedicated page for browser-consumable
streaming over the gateway — covers wire format, EventSource and curl
usage, handler patterns for AI/LLM workloads (context cancellation, TTFT),
opt-out via DISABLE_SSE_MARSHALER, custom marshaler registration, and
common pitfalls (compression, proxy buffering, EventSource GET-only,
gateway message wrapping).

Updates cross-cutting pages:

- config-reference.md gains a DISABLE_SSE_MARSHALER row in HTTP Gateway.
- streaming-rpcs.md gateway section now lists SSE as a default behaviour
  alongside NDJSON, with a Related link to the new page.
- gateway-extensions.md built-ins list calls out the auto-registered
  text/event-stream marshaler and how to override it.

Nav order shifts: server-sent-events at 22, database/cache/messaging
bumped one each. Playwright pages.ts updated to match.
Copilot AI review requested due to automatic review settings May 18, 2026 03:12
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 18, 2026

Warning

Rate limit exceeded

@ankurs has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 59 minutes and 22 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ce50d7ee-729a-443e-b966-16c714fecb96

📥 Commits

Reviewing files that changed from the base of the PR and between 141b516 and 0b19a80.

📒 Files selected for processing (8)
  • config-reference.md
  • howto/cache.md
  • howto/database.md
  • howto/gateway-extensions.md
  • howto/messaging.md
  • howto/server-sent-events.md
  • howto/streaming-rpcs.md
  • tests/pages.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/sse-docs

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds documentation for ColdBrew’s built-in Server-Sent Events (SSE) gateway marshaler (Accept-driven text/event-stream), including a new how-to page and cross-references from related docs, plus updates to Playwright’s How To page list and nav ordering.

Changes:

  • Add a new howto/server-sent-events.md page covering SSE framing, client examples, operational pitfalls, and customization/opt-out (DISABLE_SSE_MARSHALER).
  • Update streaming and gateway-extension docs to mention SSE as a first-class gateway streaming shape and link to the new guide.
  • Update config reference and test page lists to include the new page and adjusted How To sidebar ordering.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tests/pages.ts Inserts the new SSE how-to page into allHowtoPages in nav order.
howto/streaming-rpcs.md Documents SSE as an alternative server-streaming HTTP shape and links to the new how-to.
howto/server-sent-events.md New end-to-end SSE how-to documentation (wire format, clients, ops pitfalls, customization).
howto/messaging.md Bumps nav_order to keep sidebar ordering consistent after inserting SSE.
howto/gateway-extensions.md Mentions the built-in SSE marshaler and links to the SSE how-to.
howto/database.md Bumps nav_order to keep sidebar ordering consistent after inserting SSE.
howto/cache.md Bumps nav_order to keep sidebar ordering consistent after inserting SSE.
config-reference.md Adds DISABLE_SSE_MARSHALER to the HTTP Gateway config table.
Comments suppressed due to low confidence (1)

howto/server-sent-events.md:58

  • The proto example exposes the stream as post: "/api/v1/stream/tokens", but the immediately-following browser EventSource example calls the same path (and EventSource can only GET). To keep the examples consistent, either add a GET mapping in the proto snippet, or update the browser section to demonstrate a POST-capable SSE client instead of EventSource for this endpoint.
```protobuf
rpc StreamTokens(StreamTokensRequest) returns (stream Token) {
  option (google.api.http) = {
    post: "/api/v1/stream/tokens"
    body: "*"
  };

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread howto/streaming-rpcs.md

Practical things to know:

- **Server-Sent Events work out of the box.** ColdBrew registers a `text/event-stream` marshaler by default so any server-streaming RPC is consumable by a browser `EventSource(...)` without extra code. See [Server-Sent Events](/howto/server-sent-events/) for the framing, opt-out, and AI/LLM patterns; set `DISABLE_SSE_MARSHALER=true` to suppress.

---

ColdBrew exposes every server-streaming gRPC method as Server-Sent Events for free. A browser `EventSource(...)` can consume any `rpc Foo(Req) returns (stream Resp)` endpoint directly — no per-service wiring, no proto changes, no custom HTTP handler. This is the path of least resistance for AI/LLM token streams, progress feeds, change notifications, and any other server → client push that benefits from staying on plain HTTP.
Comment thread config-reference.md
| `DISABLE_DEBUG` | bool | `false` | Disable pprof debug endpoints at `/debug/` |
| `USE_JSON_BUILTIN_MARSHALLER` | bool | `false` | Use `encoding/json` instead of the default protojson marshaller for `application/json` |
| `JSON_BUILTIN_MARSHALLER_MIME` | string | `application/json` | Content-Type for the JSON builtin marshaller |
| `DISABLE_SSE_MARSHALER` | bool | `false` | Disable the auto-registered `text/event-stream` marshaler. When `false` (default), server-streaming RPCs are consumable as Server-Sent Events by clients that send `Accept: text/event-stream` — see [Server-Sent Events](/howto/server-sent-events/) |
Comment on lines +151 to +156
## Related

- [Streaming RPCs](/howto/streaming-rpcs/) — Proto definitions, handler patterns, deadline propagation, and the gateway's behavior for every gRPC method shape.
- [HTTP Gateway Extensions](/howto/gateway-extensions/) — Registering custom marshalers, error handlers, middleware, and additional routes on the gateway.
- [Configuration Reference](/config-reference/) — `DISABLE_SSE_MARSHALER` and related HTTP gateway options.
- [Metrics](/howto/Metrics/) — Where to surface TTFT and per-stream counters alongside ColdBrew's default Prometheus metrics.
- The incoming-header matcher derived from `HTTP_HEADER_PREFIXES`
- Marshalers for `application/proto` and `application/protobuf`
- The internal `spanRouteMiddleware` (sets the OTEL span name + `http.route` attribute)
- A `text/event-stream` marshaler (`core.SSEMarshaler`) so server-streaming RPCs are browser `EventSource`-consumable out of the box. Set `DISABLE_SSE_MARSHALER=true` to suppress, or register your own marshaler for `text/event-stream` to override the default. See [Server-Sent Events](/howto/server-sent-events/) for the framing details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants