Skip to content

Draft: feat: migrate from Socket.IO/WebSockets to SSE for real-time updates

Ahlad Pataparla requested to merge sse into develop

BREAKING CHANGE: Replaces Socket.IO and WebSocket-based real-time updates with Server-Sent Events (SSE).

Changes:

  • Remove Socket.IO dependencies and WebSocket managers
  • Add SSE managers for consultation queue and medicine dispatch
  • Create SSE routes at /api/v1/sse/queue/{public,doctors,coordinators}
  • Create SSE routes at /api/v1/sse/medicine/{volunteers,doctors}
  • Update services to broadcast via SSE instead of Socket.IO
  • Fix test infrastructure (conftest.py) for SSE migration

New SSE Endpoints:

  • GET /api/v1/sse/queue/public - Public queue display (waiting patients only)
  • GET /api/v1/sse/queue/doctors - Full queue view for doctors
  • GET /api/v1/sse/queue/coordinators - Full queue view with management fields
  • GET /api/v1/sse/medicine/volunteers - Medicine dispatch view for volunteers
  • GET /api/v1/sse/medicine/doctors - Medicine dispatch view for doctors

Testing:

  • Add 48 new SSE tests with 98% code coverage
  • Tests cover connection management, broadcasting, and event generation
  • All SSE tests passing

Migration Notes: Clients should migrate from Socket.IO to EventSource API: const eventSource = new EventSource('/api/v1/sse/queue/public'); eventSource.onmessage = (event) => { const queueData = JSON.parse(event.data); // Handle update };

Merge request reports

Loading