Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hyper-util: add Server::from_tcp #3474

Open
punkeel opened this issue Dec 11, 2023 · 0 comments
Open

hyper-util: add Server::from_tcp #3474

punkeel opened this issue Dec 11, 2023 · 0 comments
Labels
A-server Area: server. C-feature Category: feature. This is adding a new feature. E-medium Effort: medium. Some knowledge of how hyper internal works would be useful. K-hyper-util Crate: hyper-util

Comments

@punkeel
Copy link

punkeel commented Dec 11, 2023

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).

@punkeel punkeel added the C-feature Category: feature. This is adding a new feature. label Dec 11, 2023
@dswij dswij added K-hyper-util Crate: hyper-util A-server Area: server. E-medium Effort: medium. Some knowledge of how hyper internal works would be useful. labels Mar 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-server Area: server. C-feature Category: feature. This is adding a new feature. E-medium Effort: medium. Some knowledge of how hyper internal works would be useful. K-hyper-util Crate: hyper-util
Projects
None yet
Development

No branches or pull requests

2 participants