How abinash4567/pub-sub works
Main components
• Server Component (server.go): This is the central hub that handles incoming websocket connections. It listens on the /sender endpoint for the sender connection and on the /receiver endpoint for multiple receiver connections.
• Sender Component (sender_go directory): Contains the sender code (sender.go) which connects to the server’s /sender endpoint to broadcast messages.
• Receiver Component (client_go directory): Contains the receiver code (client.go) which connects to the server’s /receiver endpoint in order to receive broadcast messages.
Understand the relationships and interactions
• The sender establishes a websocket connection at "ws://localhost:8000/sender". Once connected, it sends messages to the server.
• The server receives these messages and, leveraging Go’s concurrency and epoll features, efficiently forwards the messages to all connected receivers.
• Multiple receivers connect to "ws://localhost:8000/receiver" and get the broadcasted messages in real time.
Architectural patterns and design principles
• Microservice Architecture: The project is built as a small, focused microservice for message broadcasting.
• Pub-Sub Pattern: The design follows a publish–subscribe model where a single sender’s messages are broadcast to many receivers.
• Concurrency and Efficiency: The system leverages Go’s built-in concurrency and optimized event handling (via epoll) to serve potentially millions of receivers with minimal resources.
Relevant technologies
• Programming Language: Go
• WebSocket Library: ws (as referenced in the README)
• System Calls: sysCall (golang.org/x/sys/unix), which is used for efficient OS level event handling.
Instructing the principal software engineer on key elements
• Optionally, include annotations to note that the Server uses efficient concurrency (via Go’s routines and epoll) and is designed for high scalability with minimal resource usage.
• At the center is the Server (server.go) acting as a hub.
• On one side, a Sender from the sender_go directory sends messages to the Server.
• On the opposite side, multiple Receiver Clients from the client_go directory connect to the Server.
• Communication flow: Sender → Server → Broad Collection of Receivers.