python-sdk icon indicating copy to clipboard operation
python-sdk copied to clipboard

Support domain socket

Open daixiang0 opened this issue 3 years ago • 6 comments

Describe the proposal

Ref https://github.com/dapr/dapr/issues/2864

Release Note

RELEASE NOTE: ADD support domain socket.

daixiang0 avatar Aug 20 '21 00:08 daixiang0

This issue has been automatically marked as stale because it has not had activity in the last 60 days. It will be closed in the next 7 days unless it is tagged (pinned, good first issue, help wanted or triaged/resolved) or other activity occurs. Thank you for your contributions.

dapr-bot avatar Mar 20 '22 21:03 dapr-bot

This issue has been automatically closed because it has not had activity in the last 67 days. If this issue is still valid, please ping a maintainer and ask them to label it as pinned, good first issue, help wanted or triaged/resolved. Thank you for your contributions.

dapr-bot avatar Mar 27 '22 21:03 dapr-bot

@daixiang0

I think this won't be as useful until the CLI can actually return the UDS path in an environment variable: https://github.com/dapr/cli/issues/969

Once that is complete I am happy to add support for UDS (and it will be easier for us to test too).

Implementing UDS support isn't hard for gRPC, but is trickier for HTTP.

berndverst avatar Apr 25 '22 23:04 berndverst

I am curious why it is trickier for HTTP, listen one UDS likes addr+port both for gRPC and HTTP, do you mean the limit of python-sdk itself.

daixiang0 avatar Apr 26 '22 01:04 daixiang0

@daixiang0 because the Python requests library - the most commonly used HTTP client - does not have support for UDS. I am against replacing this library.

I found the following https://pypi.org/project/requests-unixsocket/ but I do not trust this package so far.

Perhaps monkeypatching as described here https://github.com/msabramo/requests-unixsocket might be possible -- in this case I prefer using a context manager instead of global monkey patching to avoid any unintended side effects.

https://github.com/msabramo/requests-unixsocket#implicit-monkeypatching

berndverst avatar Aug 03 '22 22:08 berndverst

/assign

tmacam avatar Aug 03 '22 22:08 tmacam

This is already supported for gRPC, but will not be implemented for HTTP which only supports service invocation anyway.

Example: dapr run -u /Users/bverst/testfolder this will create a dapr-$appid-grpc.socket file in this folder.

Now in Python we can use this socket like so:

from dapr.clients import DaprClient
d = DaprClient(address='unix:///Users/bverst/testfolder/dapr-flying-giraffe-grpc.socket')
d.get_metadata()

berndverst avatar Apr 19 '23 00:04 berndverst

Ironically this was supported all along thanks to the underlying gRPC library!

berndverst avatar Apr 19 '23 00:04 berndverst