-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Labels
enhancementNew feature or requestNew feature or request
Milestone
Description
Objective
Implement a Server-Sent Events (SSE) endpoint that streams real-time health and queue updates to the dashboard.
Tasks
- Add
sse-starlettedependency to requirements - Create
/health/streamendpoint for SSE streaming - Implement async generator for streaming responses
- Add connection management for multiple concurrent clients
- Handle client disconnections gracefully
- Implement heartbeat/keepalive messages
Technical Requirements
- Use FastAPI's StreamingResponse or sse-starlette's EventSourceResponse
- Support multiple concurrent SSE connections
- Implement proper error handling and connection cleanup
- Add rate limiting to prevent abuse
- Include authentication/authorization checks
Example Implementation
from sse_starlette.sse import EventSourceResponse
@router.get('/health/stream')
async def health_stream(request: Request):
async def event_generator():
while True:
if await request.is_disconnected():
break
data = await get_health_update()
yield {"data": json.dumps(data)}
await asyncio.sleep(1)
return EventSourceResponse(event_generator())Dependencies
- Requires ASGI server (Uvicorn) for proper async support
- May need to adjust CORS settings for SSE
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request