Skip to content
This repository has been archived by the owner on Mar 8, 2020. It is now read-only.

Commit

Permalink
Allow to create Clients with an instanced grpc channel as suggested b…
Browse files Browse the repository at this point in the history
…y Vadim

Signed-off-by: Juanjo Alvarez <juanjo@sourced.tech>
  • Loading branch information
Juanjo Alvarez committed Dec 18, 2018
1 parent a020666 commit 9b094aa
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions bblfsh/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)

Expand Down

0 comments on commit 9b094aa

Please sign in to comment.