Skip to content

Add Client.EventStream for reconnecting SSE through the pipeline#18

Merged
OmarAlJarrah merged 3 commits into
mainfrom
feat/client-eventstream
Jun 16, 2026
Merged

Add Client.EventStream for reconnecting SSE through the pipeline#18
OmarAlJarrah merged 3 commits into
mainfrom
feat/client-eventstream

Conversation

@OmarAlJarrah

Copy link
Copy Markdown
Member

Summary

Adds Client.EventStream(ctx, req, opts...), a one-call reconnecting Server-Sent Events stream that runs through the client pipeline. Previously a caller had to write their own sse.ConnectFunc; now the common case — "stream this endpoint through my configured client" — is a single method that returns the same iter.Seq2[sse.Event, error] shape as the rest of the streaming APIs.

Each connection clones the request, sets Accept: text/event-stream (unless the caller set their own), replays the Last-Event-ID header after a mid-stream interruption, and sends it through Do — so auth, logging, tracing, and retry all run per connection. A non-2xx response or a transport failure on connect ends the stream with that error; a mid-stream interruption reconnects transparently. Requests with a body must be replayable (SSE is normally a bodyless GET).

Also adds the header.LastEventID constant.

Test plan

  • Events flatten across reconnects in order; a terminal connect error ends the stream
  • Last-Event-ID is replayed with the most recent event id on each reconnect
  • Accept: text/event-stream is set on every connection
  • A non-2xx connect ends the stream with an error and yields no events
  • gofmt -l . clean, go vet ./... clean, go test -race ./... green across all packages

🤖 Generated with Claude Code

@OmarAlJarrah OmarAlJarrah merged commit 8839cd8 into main Jun 16, 2026
1 of 2 checks passed
@OmarAlJarrah OmarAlJarrah deleted the feat/client-eventstream branch June 16, 2026 19:52
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.

1 participant