python-sdk
python-sdk copied to clipboard
Support domain socket
Describe the proposal
Ref https://github.com/dapr/dapr/issues/2864
Release Note
RELEASE NOTE: ADD support domain socket.
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.
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.
@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.
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 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
/assign
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()
Ironically this was supported all along thanks to the underlying gRPC library!