Skip to content

Server sent events implementation in go using redis as broker between backend instances.

Notifications You must be signed in to change notification settings

bluebrown/go-sse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go SSE

Server Sent Events backend written in go. Redis is used to distribute published messages across all backends so that the backend can be scaled horizontally.

The backend is stateless in that it doesn't matter to which instance the message is published, since it will be distributed to all other instances and them sent to the connected clients of the respective instance using event-stream.

Docker Compose

Start the compose stack, then visit the webpage at http://localhost:8080. It is a basic chat page. Open it multiple times to see real time events published from one client on all other client pages.

docker-compose up

Example Output

backend_2  | client connected: 192.168.16.2:37712
backend_1  | client connected: 192.168.16.2:47996
backend_2  | 2022/01/23 23:01:44 publishing message: {"user":"John","message":"Hi"}
backend_2  | 2022/01/23 23:01:44 receiving message: {"user":"John","message":"Hi"}
backend_1  | 2022/01/23 23:01:44 receiving message: {"user":"John","message":"Hi"}
backend_2  | 2022/01/23 23:01:53 publishing message: {"user":"Maria","message":"Hello :)"}
backend_1  | 2022/01/23 23:01:53 receiving message: {"user":"Maria","message":"Hello :)"}
backend_2  | 2022/01/23 23:01:53 receiving message: {"user":"Maria","message":"Hello :)"}

About

Server sent events implementation in go using redis as broker between backend instances.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published