How wrongbyte/rust-paxos works
Based on our analysis of the file tree and README, this project is a simplified Paxos algorithm simulation written in Rust. It essentially implements a consensus protocol with a “leader” (the proposer that also plays the role of the learner) and a set of acceptor nodes. The goal is to simulate the message-passing steps of the Paxos algorithm (prepare, promise, accept, accepted, learn) in a distributed environment, even though—for simplicity—the simulation is run on a single machine with multiple actors.
• Main Application/Entry Point: Represented by paxos/src/main.rs. This is the starting point that sets up simulated nodes and launches the Paxos negotiation.
• Domain Models: Create a component for the domain logic (paxos/src/domain) that defines the types for messages, nodes, proposals, etc.
• Actors/Node Roles: Show two main actor types:
– Proposer Actor: Implemented in paxos/src/actors/proposer.rs (which also doubles as a Learner per the simplified implementation).
– Acceptor Actor: Found in paxos/src/actors/acceptor.rs.
• Network Communication Layer: Outline the network layer with separate modules for proposers and acceptors under paxos/src/network. This layer manages channels and message routing (note channels and submodules in both proposer and acceptor directories).
• Repository & Utility Modules: Optionally include a component for data persistence or state management (even if currently minimal) from paxos/src/repository.rs.
Relationships & Interactions
• That the network module acts as a messaging “bus” that interconnects the actors (e.g., channels in the network modules).
Architectural Patterns & Design Principles
• Separation of Concerns: Clearly separate the domain/business rules (in the domain directory), the actors (in the actors directory), and the network communication layer.
• Layered Architecture: The system can be visually grouped into layers – the “Application” layer (main and configuration), “Business Logic” (actors performing Paxos roles), and “Infrastructure” (network & messaging).