proxy.rs

Overview

This file contains the main entry point for the proxy server application. It initializes tracing for logging and diagnostics and then runs the proxy server. The main function handles startup errors by logging them and ensures a graceful shutdown message is recorded upon successful termination. Its primary responsibility is to bootstrap the proxy server component and manage its lifecycle within the application.


Function Details

main() -> anyhow::Result<()>

fn main() -> anyhow::Result<()> {
    proxy::tracing::init_tracing();
    if let Err(error) = proxy::server::run() {
        tracing::error!("{:#?}", error);
        return Err(error);
    }
    tracing::info!("Server stopped gracefully.");
    Ok(())
}

Implementation Details


Interactions with Other Components

The file acts as a coordinator between the tracing setup and server runtime, serving as the application bootstrapper.


Mermaid Diagram

flowchart TD
A["main()"] --> B["proxy::tracing::init_tracing()"]
A --> C["proxy::server::run()"]
C -->|Error| D[tracing::error!]
C -->|Success| E[tracing::info!]
D --> F["Return Err(error)"]
E --> G["Return Ok(())"]

This diagram represents the flow within the main() function, showing initialization, server running, error handling, and graceful shutdown logging.