Skip to content

hyper-util: add Server::from_tcp #3474

Open
@punkeel

Description

@punkeel

Is your feature request related to a problem? Please describe.
Server::from_tcp was supported before 0.1 (and exposed in Axum 0.6), but removed with the stabilization - and so, removed from Axum 0.7.
This was introduced by bb4c5e2, from what I can tell.

We use it with systemd socket activation: we get the fd (or default to a Tokio TCP Listener), then start the server on this.

With axum 0.6, the following code worked:

pub async fn run(listener: TcpListener) {
    let app = Router::new(); // snip the router

    axum::Server::from_tcp(listener)
}

Starting with axum 0.7, we need a lot more boilerplate (see below).

Describe the solution you'd like
Bring back Server::from_fd - either in hyper or hyper-util.

Describe alternatives you've considered
https://github.com/tokio-rs/axum/blob/2b486ea174b263e4335490794637ea50eb04765c/examples/unix-domain-socket/src/main.rs#L55-L83

This is the current workaround - sadly it's very verbose, error prone (and hard to review when we're not tokio+axum+hyper experts).

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-serverArea: server.C-featureCategory: feature. This is adding a new feature.E-mediumEffort: medium. Some knowledge of how hyper internal works would be useful.K-hyper-utilCrate: hyper-util

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions