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

Support for domain sockets #607

Open
maleadt opened this issue Oct 27, 2020 · 2 comments
Open

Support for domain sockets #607

maleadt opened this issue Oct 27, 2020 · 2 comments

Comments

@maleadt
Copy link

maleadt commented Oct 27, 2020

I was trying to communicate with a local domain socket that accepts HTTP, which I'm currently doing like so:

docker = connect("/var/run/docker.sock")
write(docker, """
    GET /info HTTP/1.1
    Host: localhost
    Accept: application/json


    """)
@show read(docker, String)
close(docker)

That doesn't really work with HTTP.jl right now, the connection layer doesn't support these sockets, and there isn't a way to separate the path to the socket from the path to request. One interesting approach by https://github.com/msabramo/requests-unixsocket is using the following URI format: http+unix://%2Fvar%2Frun%2Fdocker.sock/info.

@quinnj
Copy link
Member

quinnj commented May 27, 2022

Yeah, I don't think this would be too hard; we already have some mechanisms that theoretically help support this by allowing the user to pass a socket_type keyword arg and then we just have to ensure a ConnectionPool.getconnection method is defined for it. You can see how we overload those in the tests for a "loopback interface" (test/loopback.jl).

Going to mark this as an "enhancement" + "help wanted" and the 1.X milestone as this wouldn't require breaking changes (it touches only pretty internal code).

@quinnj quinnj added this to the 1.X milestone May 27, 2022
@quinnj
Copy link
Member

quinnj commented Jun 18, 2022

Note I recently learned of PipeEndpoint and PipeServer which exist precisely to provide the LibuvStream interface like TcpSocket. And the server code should already "just work" by passing a PipeServer as the server socket argument.

So we'd really just need to have a getconnection method in ConnectionPool that has an overload for PipeEndpoint and handled opening the connection (or perhaps we can just reuse the TcpSocket code already since they should have the same interface?).

So the last piece is really just figuring out how users specify that a PipeEndpoint should be used instead of a TcpSocket for doing the client request; either a custom schema as @maleadt mentioned above, or just some keyword argument?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants