Summary
I've built fibersse — a production-grade SSE library built natively for Fiber v3. I'd like to propose adding it (or a version of it) to gofiber/contrib as the official SSE package.
The Problem
There is no SSE package in gofiber/contrib today. Every Fiber project that needs Server-Sent Events hand-rolls the same SendStreamWriter + w.Flush() pattern. Existing Go SSE libraries (r3labs/sse, tmaxmax/go-sse) are built on net/http and break on Fiber because:
What fibersse Provides
| Feature |
Status |
Fiber v3 native (SendStreamWriter) |
✅ |
Client disconnect via w.Flush() error + heartbeat |
✅ |
| Hub pattern (single goroutine, topic-based routing) |
✅ |
| Event coalescing (last-writer-wins per key) |
✅ |
| 3 priority lanes (Instant / Batched / Coalesced) |
✅ |
NATS-style topic wildcards (* and >) |
✅ |
| Adaptive per-connection throttling |
✅ |
| Connection groups (publish by metadata) |
✅ |
| Built-in JWT + ticket auth helpers |
✅ |
| Prometheus metrics endpoint |
✅ |
| Last-Event-ID replay (pluggable) |
✅ |
| Graceful Kubernetes-style drain |
✅ |
| Event TTL |
✅ |
| Auto fan-out from Redis/NATS |
✅ |
| Zero deps beyond Fiber v3 |
✅ |
| 29 tests, MIT license |
✅ |
Links
Usage Example
hub := fibersse.New(fibersse.HubConfig{
FlushInterval: 2 * time.Second,
OnConnect: func(c fiber.Ctx, conn *fibersse.Connection) error {
conn.Topics = []string{"notifications", "live"}
return nil
},
})
app.Get("/events", hub.Handler())
hub.Publish(fibersse.Event{
Type: "notification",
Data: map[string]string{"title": "Hello"},
Topics: []string{"notifications"},
})
Proposal
I'm happy to:
- Contribute
fibersse directly to gofiber/contrib as a new sse package
- Adapt the API to match contrib conventions
- Maintain it as part of the contrib ecosystem
Would love to hear from the maintainers on whether this fits the contrib vision and what changes would be needed.
cc @efectn @ReneWerner87
Summary
I've built fibersse — a production-grade SSE library built natively for Fiber v3. I'd like to propose adding it (or a version of it) to
gofiber/contribas the official SSE package.The Problem
There is no SSE package in gofiber/contrib today. Every Fiber project that needs Server-Sent Events hand-rolls the same
SendStreamWriter+w.Flush()pattern. Existing Go SSE libraries (r3labs/sse,tmaxmax/go-sse) are built onnet/httpand break on Fiber because:fasthttp.RequestCtx.Done()only fires on server shutdown, not per-client disconnectfasthttpadaptorcreates zombie subscribers that leak memory foreverWhat fibersse Provides
SendStreamWriter)w.Flush()error + heartbeat*and>)Links
go get github.com/vinod-morya/fibersse@v0.1.0Usage Example
Proposal
I'm happy to:
fiberssedirectly togofiber/contribas a newssepackageWould love to hear from the maintainers on whether this fits the contrib vision and what changes would be needed.
cc @efectn @ReneWerner87