From 9b094aa37668c787507a2c059d248457cd56c0c4 Mon Sep 17 00:00:00 2001 From: Juanjo Alvarez Date: Tue, 18 Dec 2018 14:09:05 +0100 Subject: [PATCH] Allow to create Clients with an instanced grpc channel as suggested by Vadim Signed-off-by: Juanjo Alvarez --- bblfsh/client.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bblfsh/client.py b/bblfsh/client.py index ac27050..fc975c3 100644 --- a/bblfsh/client.py +++ b/bblfsh/client.py @@ -18,7 +18,7 @@ class BblfshClient: Babelfish gRPC client. """ - def __init__(self, endpoint: str) -> None: + def __init__(self, endpoint: Union[str, grpc.Channel]) -> None: """ Initializes a new instance of BblfshClient. @@ -27,7 +27,11 @@ def __init__(self, endpoint: str) -> None: :type endpoint: str """ - self._channel = grpc.insecure_channel(endpoint) + if isinstance(endpoint, str): + self._channel = grpc.insecure_channel(endpoint) + else: + self._channel = grpc.endpoint + self._stub_v1 = ProtocolServiceStub(self._channel) self._stub_v2 = DriverStub(self._channel)