python-trio / purerpc

Native, async Python gRPC client and server implementation supporting asyncio, uvloop, and trio
Apache License 2.0
217 stars 15 forks source link

Support creating channels on unix sockets #27

Closed decentral1se closed 3 years ago

decentral1se commented 4 years ago

I need to read/write from a unix socket in my rpc client.

I had a little dig around and it seems like the current implementation here assumes a tcp stream.

https://github.com/standy66/purerpc/blob/5faa35f2cdf5b36d1398a1aa6a9e681c5344060f/src/purerpc/client.py#L23

Seems like anyio does support unix sockets:

https://anyio.readthedocs.io/en/stable/networking.html#working-with-unix-sockets

I am not sure how you imagine this to work in the current insecure_channel API? Or would it be another API method?

If you provide some direction, I can try to submit the patch. Or otherwise, help test it.

Thanks for this rad library :hand:

FYI they pushed a fix for this in the gRPC implementation over at https://github.com/grpc/grpc/pull/5701.

decentral1se commented 4 years ago

Similar kinda hacky but backwards compat approach to https://github.com/grpc/grpc/pull/5701 might be what I'm hacking around on in https://github.com/decentral1se/purerpc/commit/0e0cd7a880121f55cef973e466f572f326b0d77e. I've manually tested this and I can connect to a unix socket but some slightly messy threading of a is_unix_socket bool was necessary to inform the underlying logic. I can't seem to send a message yet though :thinking: