Skip to content

Conversation

josecelano
Copy link
Member

Documentation for the crate::servers::http module. The HTTP tracker.

@josecelano josecelano added the Documentation Improves Instructions, Guides, and Notices label Mar 30, 2023
@josecelano josecelano linked an issue Mar 30, 2023 that may be closed by this pull request
@josecelano josecelano force-pushed the issue-266-crate-docs-for-http-tracker-mod branch 3 times, most recently from 5abf54b to d5d6996 Compare March 31, 2023 16:48
@josecelano
Copy link
Member Author

Hi @da2ce7 @WarmBeer , for the time being, I'm not going to write docs for these modules:

The torrust_tracker::servers::http::v1::launcher::Launcher is used only for testing, and it would be not very clear to add documentation since the test code does not appear in the documentation unless you add it as a doc comment.

Regarding the src/servers/http/server.rs, the HttpServerLauncher is not used in production either. I think the only code used in production is:

pub fn start(socket_addr: std::net::SocketAddr, tracker: Arc<Tracker>) -> impl Future<Output = hyper::Result<()>> {
    let app = router(tracker);

    let server = axum::Server::bind(&socket_addr).serve(app.into_make_service_with_connect_info::<std::net::SocketAddr>());

    server.with_graceful_shutdown(async move {
        tokio::signal::ctrl_c().await.expect("Failed to listen to shutdown signal.");
        info!("Stopping Torrust HTTP tracker server on http://{} ...", socket_addr);
    })
}

pub fn start_tls(
    socket_addr: std::net::SocketAddr,
    ssl_config: RustlsConfig,
    tracker: Arc<Tracker>,
) -> impl Future<Output = Result<(), std::io::Error>> {
    let app = router(tracker);

    let handle = Handle::new();
    let shutdown_handle = handle.clone();

    tokio::spawn(async move {
        tokio::signal::ctrl_c().await.expect("Failed to listen to shutdown signal.");
        info!("Stopping Torrust HTTP tracker server on https://{} ...", socket_addr);
        shutdown_handle.shutdown();
    });

    axum_server::bind_rustls(socket_addr, ssl_config)
        .handle(handle)
        .serve(app.into_make_service_with_connect_info::<std::net::SocketAddr>())
}

We can either:

  • Change production code to mirror testing bootstrapping.
  • Move the code that is only used for testing to the test mods until we start using in production.

I'd do the second after merging this PR and them and the documentation for the remaining code.

@josecelano josecelano force-pushed the issue-266-crate-docs-for-http-tracker-mod branch 2 times, most recently from db288cd to f001f0f Compare April 4, 2023 08:10
@josecelano josecelano force-pushed the issue-266-crate-docs-for-http-tracker-mod branch from f001f0f to 11d8731 Compare April 4, 2023 11:25
@josecelano josecelano marked this pull request as ready for review April 4, 2023 11:32
@josecelano josecelano merged commit 6126679 into torrust:develop Apr 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Documentation Improves Instructions, Guides, and Notices

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

crate docs: for servers::http mod (HTTP tracker)

1 participant