-
Notifications
You must be signed in to change notification settings - Fork 68
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
Listen on multiple sockets #66
Comments
This feature makes sense but can't be done without sacrificing integration with axum. Currently, for axum to extract I have been delaying answering because I think this would be a good addition to new upcoming server in hyper-util (which will ideally make this crate obsolete). axum will certainly work with that new server since it will be the "official" one. |
That's not the case - in fact prior to hyper 1.x it was possible to do exactly this via acceptors. For example, here's some code from my own application: // Allow one of several different connection types to be used.
pub enum AnyConnection {
// Direct TCP connection
AddrStream(AddrStream),
// TLS connection
TlsStream(TlsStream),
// Ngrok connection
NgrokConn(ngrok::Conn),
}
// Allow getting the remote address from the underlying connection
impl Connected<&AnyConnection> for SocketAddr {
fn connect_info(target: &AnyConnection) -> Self {
match target {
AnyConnection::AddrStream(inner) => inner.remote_addr(),
AnyConnection::TlsStream(inner) => inner.io().expect("Stream errored").remote_addr(),
AnyConnection::NgrokConn(inner) => inner.remote_addr(),
}
}
} Which made it super easy to accept connections from any number of places. Unfortunately the new |
I really do like the easy of working with axum and axum-server. It is straightforward to set up TLS and reload it, which is awesome when used with certificates that need to renewed often.
I would be genuinely interested in binding a server to multiple sockets of different types. For example, to accept an arbitrary list of TCP and unix domain sockets via systemd socket activation:
Having the same app listening on multiple sockets greatly improves usability and integration with many systems, such as systemd. Unix domain sockets are often used to provide a service to other local services, such as reverse proxies or load balancers. A second TCP listener is often spawned e.g. for debugging or monitoring purposes.
Does this feature sound reasonable for axum-server?
The text was updated successfully, but these errors were encountered: