-
Notifications
You must be signed in to change notification settings - Fork 47
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
Using unix domain socket #147
Comments
Yep, I very much like this functionality. I have a few thoughts about this. It looks to me like tokio models the incoming streams as separate structs. I don't have enough knowledge about why they're doing this, probably because of tcp vs unix data streams, but I bet they have good reasons. With that in mind, I'd like to propose adding
This could then be used just like
Thoughts? This seems less invasive than adding it to a trait, and less work than maintaining a third set of ThrusterServer implementations. |
I've been thinking about it. async fn build_on_hyper_builder(mut self, builder: hyper::server::Builder) and then we just have to use this new method for writing the async fn build(mut self, host: &str, port: u16) {
let addr = (host, port).to_socket_addrs().unwrap().next().unwrap();
let builder = Server::bind(&addr);
self.build_on_hyper_builder(builder);
} This seems it covers more use cases, is still easy to build on unix socket for my use case let mut listener = tokio::net::UnixListener::bind("/tmp/thruster.sock").unwrap();
let incoming = listener.incoming();
let incoming = hyper::server::accept::from_stream(incoming);
let builder = Server::builder(incoming);
let server = HyperServer::new(app);
tokio::runtime::Runtime::new()
.unwrap()
.block_on(server.build_on_hyper_builder(builder)); |
Mmm, yes, I like that solution very much. Feel free to open a PR, otherwise
I'll hopefully get to this midweek!
…On Sun, Apr 5, 2020 at 1:52 PM encendre ***@***.***> wrote:
I've been doing some thinking and I think the best solution would be to
implement a method that allows the application to build on any hyper server
configuration.
async fn build_on_hyper_builder(mut self, builder: hyper::server::Builder)
and then we just have to use this new method for writing the build method
required by the ThrusterServer trait, like this
async fn build(mut self, host: &str, port: u16) {
let addr = (host, port).to_socket_addrs().unwrap().next().unwrap();
let builder = Server::bind(&addr);
self.build_on_hyper_builder(builder);
}
This seems it covers more use cases and is still easy to build on unix
socket
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#147 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAJWOLKFZ5WIZJZUVKHUBSTRLDANTANCNFSM4L66HAOA>
.
|
I tried to implement it but since I'm pretty new to rust I didn't succeed. |
I can try this out today, not to worry! I'll post the PR here when it's done so you can compare with what you were doing and hopefully see where you were going astray :) |
So after some noodling, I realized that hyper doesn't actually natively support unix sockets! I had to use hyperlocal in order to get all of the traits on the correct Unix streams. With that in mind, I thought it easiest to add |
Hello, is there any way to use thruster with unix domain sockets?
If they is no way to do that now, I wonder if is possible to add a method
.build_from_incoming
which usehyper::Server::builder
insteadhyper::Server::bind
for create the underlyinghyper::Server
or maybe just a new type of server
thruster::UsdHyperServer
which impl theThrusterServer
trait but ignoring theport
argument, like this:The text was updated successfully, but these errors were encountered: