aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/python/grpcio/grpc/beta
diff options
context:
space:
mode:
authorGravatar Christian Svensson <blue@cmd.nu>2016-03-10 17:04:11 +0100
committerGravatar Christian Svensson <blue@cmd.nu>2016-03-20 18:41:51 +0100
commite73e9e1a98600dfbf405c9bcbbfdcd4bd05d78f4 (patch)
tree4b9d8d68437f55956ef0666cf20ccf8162e4cb76 /src/python/grpcio/grpc/beta
parent0640711b86d1d8387ba908edf329f08fa58ab289 (diff)
Allow directly specifiying connection path
Make insecure_channel / secure_channel accept port=None and only use the 'host' argument. This enables using UNIX sockets without mangling the path of the socket. Signed-off-by: Christian Svensson <blue@cmd.nu>
Diffstat (limited to 'src/python/grpcio/grpc/beta')
-rw-r--r--src/python/grpcio/grpc/beta/implementations.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/python/grpcio/grpc/beta/implementations.py b/src/python/grpcio/grpc/beta/implementations.py
index a0ca330d2c..6f1ca2bb5e 100644
--- a/src/python/grpcio/grpc/beta/implementations.py
+++ b/src/python/grpcio/grpc/beta/implementations.py
@@ -1,4 +1,4 @@
-# Copyright 2015, Google Inc.
+# Copyright 2015-2016, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -187,12 +187,13 @@ def insecure_channel(host, port):
Args:
host: The name of the remote host to which to connect.
port: The port of the remote host to which to connect.
+ If None only the 'host' part will be used.
Returns:
A Channel to the remote host through which RPCs may be conducted.
"""
intermediary_low_channel = _intermediary_low.Channel(
- '%s:%d' % (host, port), None)
+ '%s:%d' % (host, port) if port else host, None)
return Channel(intermediary_low_channel._internal, intermediary_low_channel) # pylint: disable=protected-access
@@ -202,13 +203,15 @@ def secure_channel(host, port, channel_credentials):
Args:
host: The name of the remote host to which to connect.
port: The port of the remote host to which to connect.
+ If None only the 'host' part will be used.
channel_credentials: A ChannelCredentials.
Returns:
A secure Channel to the remote host through which RPCs may be conducted.
"""
intermediary_low_channel = _intermediary_low.Channel(
- '%s:%d' % (host, port), channel_credentials._low_credentials)
+ '%s:%d' % (host, port) if port else host,
+ channel_credentials._low_credentials)
return Channel(intermediary_low_channel._internal, intermediary_low_channel) # pylint: disable=protected-access