Challenge 3: Build a broadcast system! Starting with single node - just need to receive "broadcast" messages and respond with "broadcast_ok", plus handle "read" requests that return all messages seen so far.
What it Does
- Receives broadcast messages and stores them locally
- Responds with broadcast_ok to confirm receipt
- Handles read requests returning all stored messages
- Simple state management with a slice
The Approach
Pretty straightforward for single node:
- Keep a slice of all received messages
- On broadcast: add to slice, reply with broadcast_ok
- On read: return the current slice
No coordination needed since it's just one node. This is the foundation we'll build on for multi-node scenarios.
Key Learnings
- Message handling patterns in Maelstrom
- State management in distributed systems
- Request/response cycles for different message types
Simple start, but the complexity ramps up quickly in the next challenges when we add multiple nodes!