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

Unix socket support #2

Open
girvo opened this issue Jun 6, 2016 · 8 comments
Open

Unix socket support #2

girvo opened this issue Jun 6, 2016 · 8 comments

Comments

@girvo
Copy link

girvo commented Jun 6, 2016

Nim recently merged a PR that adds Unix socket support, I've been working on my own Docker client for Nim using that but came across this repo. Mind if I write a PR to add support for Unix sockets for this? Would save me a metric tonne of work.

@tulayang
Copy link
Owner

tulayang commented Jun 6, 2016

@girvo

Just do it, Unix sockets support is required. Welcome!

@girvo
Copy link
Author

girvo commented Jun 6, 2016

@tulayang Beautiful, will do!

I've also been adding tar format support to Nim, so that docker build can be achieved without relying on an external cmdEx call. Would you also be interested in a pull-request adding tar support?

@tulayang
Copy link
Owner

tulayang commented Jun 6, 2016

@girvo

O, that would be great support! Could you provide a new overloaded version for build and putArchive without modifying them?

@girvo
Copy link
Author

girvo commented Jun 6, 2016

Sounds good to me 😄

@dustinlacewell
Copy link

Any progress on this?

@girvo
Copy link
Author

girvo commented Mar 13, 2017

@dustinlacewell Coincidentally, yes!

https://github.com/girvo/dup/blob/docker-socket/docker_socket/docker_socket.nim

I'm currently working on the TAR impl. again, which I expect to have completed shortly. Communication with Docker's API via the Unix socket works perfectly, though I had to write my own (slightly dodgy) HTTP parser for it, and it still needs gzip handling (though I'll likely just use zlib for that).

What's left is making the socket non-blocking and wrapping it with asyncdispatch properly, so we can integrate it into this!

@girvo
Copy link
Author

girvo commented Mar 18, 2017

@tulayang @dustinlacewell

So I've been working on this today, and have a query; I'm currently using the reactor library to achieve async AF_UNIX socket communication in my proof-of-concept, but I'm assuming that wouldn't be what you'd want @tulayang as it'd add another dependency. Have you seen reactor?

https://github.com/zielmicha/reactor.nim

The Unix socket support is pretty excellent, whereas I'm going to write a few lower level primitives for standard asyncdispatch -- https://github.com/zielmicha/reactor.nim/blob/master/reactor/uv/uvunix.nim

@tulayang
Copy link
Owner

tulayang commented Mar 18, 2017

@girvo

Yes, I had seen reactor. But I found there are many wrong imports in reactor and the abstraction is not convenient enough. And, reactor is conflict with future of standlib.

To extend the http io of standlib is difficult. So I'm writting a similar lib named nimnode which refer to nodejs based on libuv. I hope that could provide an extensible socket server httpparser httpchannel etc, an example:

var channel = new HttpChannel(8000, "127.0.0.1")
await channel.request("/logs/123")
await channel.writeHead(...)
await channel.writeChunck(...)
await channel.writeChunck(...)
await channel.writeEnd()
var headers = await channel.readerHead(...)
while true:
  var n = await channel.readChunk(...)
  # doTask(a data chunk)
  if n = 0:
    break
# A request done do something

# next request, keepalive supported
await channel.request("/users")
# ...

You can try to write unix socket support for asyncdispatch. I will merge that when you finished it.

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

No branches or pull requests

3 participants