How ixpantia/faucet works
Main Components
• CLI/Entry Point: Represented by src/main.rs and src/cli.rs, this component parses command-line arguments (such as choosing the deployment directory, specifying the type—Plumber/Shiny/Quarto—and setting options for host, port, workers, and load balancing strategy).
• Server Core: The main server process (found in src/server) handles incoming HTTP requests. Inside this, include subcomponents such as:
• The Router (src/server/router/) which detects the type of application based on the provided directory and dispatches requests.
• A logging module (src/server/logging.rs) that captures events and error messages.
• Possibly the “onion” module (src/server/onion.rs) if it plays a role in multi-layered routing.
• Client Module: This module (inside src/client) handles communication between the server and application replicas, including:
• Load balancing submodules (e.g., Round Robin, IP Hash found in src/client/load_balancing) which decide how to distribute requests.
• Worker management (e.g., src/client/worker.rs) and connection pooling (src/client/pool.rs).
• Websockets support (src/client/websockets.rs) for real-time or persistent connections.
• Telemetry Module: (Located in src/telemetry) captures HTTP events and integrates with an external PostgreSQL database to record metrics and usage statistics.
• External Database Integration: Although not part of the codebase, include an external PostgreSQL node that stores telemetry data (using the FAUCET_TELEMETRY_POSTGRES_STRING).
• Supporting Scripts and Configurations: Incorporate configuration files (Cargo.toml, Dockerfile, GitHub workflows, etc.) that indicate build, deployment, and CI/CD pipelines.
• Inside the Server Core, illustrate how the Router determines the type of deployed application and hands off requests to the Client Module for load balancing.
Architectural Patterns and Design Principles
• Modular Separation: Clearly delineate modules for CLI, server, client, routing, logging, and telemetry.
• Asynchronous & Concurrent Processing: Annotate that the server utilizes asynchronous processing (leveraging Rust’s async ecosystem) to handle concurrent requests.
• Load Balancing Strategies: Represent the two main load balancing mechanisms (Round Robin and IP Hash) as alternative branches within the Client Module.
• Scalability & Replication: Indicate the possibility to spawn multiple workers (replicas) and show data flows that reflect decision-making by the load balancer.
• External Integration: Emphasize that the telemetry module interacts with an external PostgreSQL database, making it easier to trace performance metrics.
Relevant Technologies and Frameworks
• Rust (the programming language) and Cargo (Rust’s build tool) for the core application.
• Docker (via the Dockerfile and container examples) to containerize deployments.
• Nginx/Reverse Proxy (as shown in the README for routing requests properly).
• PostgreSQL (for HTTP telemetry storage).
• R-based application frameworks (Plumber APIs, Shiny, and Quarto as referenced in the usage examples).