hyperium / hyperium/hyper

hyper-util: add `Server::from_tcp`

Open
#3,474 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-server C-feature E-medium K-hyper-util
Dominant language
Rust
Stars
16.3k
Forks
1.8k
Avg merge
1d 22h
Merged PRs (30d)
14

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing hyper-util's server API and the workaround in examples/unix-domain-socket/src/main.rs, especially the section linked in the issue. Determine whether the supported entry point belongs in hyper or hyper-util, and finish with an API that accepts the activated Tokio TCP listener without the current verbose setup.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
api, backend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.